Summary Files Commits Branches @commit @diff @stats
path: root / src / carousels.less
blob: e82684027bd9d41ac1de84ac89f93680465905f5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
// Carousels
.carousel {
  background: @bg-color;
  display: block;
  height: 50vh;
  overflow: hidden;
  position: relative;
  width: 100%;

  .carousel-container {
    height: 100%;
    left: 0;
    position: relative;
    //animation: carousel-autoplay 15s infinite;

    .carousel-item {
      animation: carousel-slideout 1s 1;
      height: 100%;
      left: 0;
      margin: 0;
      opacity: 0;
      position: absolute;
      top: 0;
      width: 100%;
    }
  }

  .carousel-locator {
    display: none;

    &:nth-of-type(1):checked ~ .carousel-container .carousel-item:nth-of-type(1),
    &:nth-of-type(2):checked ~ .carousel-container .carousel-item:nth-of-type(2),
    &:nth-of-type(3):checked ~ .carousel-container .carousel-item:nth-of-type(3),
    &:nth-of-type(4):checked ~ .carousel-container .carousel-item:nth-of-type(4) {
      animation: carousel-slidein .75s 1;
      opacity: 1;
      z-index: 99;
    }
    &:nth-of-type(1):checked ~ .carousel-nav .nav-item:nth-of-type(1),
    &:nth-of-type(2):checked ~ .carousel-nav .nav-item:nth-of-type(2),
    &:nth-of-type(3):checked ~ .carousel-nav .nav-item:nth-of-type(3),
    &:nth-of-type(4):checked ~ .carousel-nav .nav-item:nth-of-type(4) {
      color: @light-gray-color;
    }
  }

  .carousel-nav {
    bottom: 1rem;
    display: flex;
    justify-content: center;
    left: 50%;
    position: absolute;
    transform: translateX(-50%);
    width: 20rem;
    z-index: 999;

    .nav-item {
      color: fade(@light-gray-color, 50%);
      display: block;
      flex: 1 0 auto;
      height: 4rem;
      margin: .4rem;
      max-width: 5rem;
      position: relative;

      &::before {
        background: currentColor;
        content: "";
        display: block;
        height: .3rem;
        position: absolute;
        top: 2rem;
        width: 100%;
      }
    }
  }
}

@supports (object-fit: cover) {
  .carousel-item {
    img {
      height: 100%;
      object-fit: cover;
      width: 100%;
    }
  }
}

@keyframes carousel-autoplay {
  0% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-25%);
  }
  50% {
    transform: translateX(-50%);
  }
  75% {
    transform: translateX(-75%);
  }
  100% {
    transform: translateX(0);
  }
}
@keyframes carousel-slidein {
  0% {
    transform: translateX(100%);
  }
  100% {
    transform: translateX(0);
  }
}
@keyframes carousel-slideout {
  0% {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
  100% {
    opacity: 0;
    transform: translateX(-50%) scale(.95);
  }
}