📦 EqualifyEverything / equalify

📄 selects.scss · 112 lines
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@use "./variables.module.scss";
@use "./fonts.scss";

select {
  appearance: base-select;
  color: variables.$black;
  background-color: variables.$paper;
  min-width: 120px;
  box-sizing: border-box;
  margin-top:calc(variables.$spacing/2);
  padding: calc(variables.$spacing/2) calc(variables.$spacing);
  border: 1px solid variables.$gray;
  border-radius: calc(0.5rem - 2px);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
  cursor: pointer;
  @include fonts.font-size-small;

  & > button {
    display: flex;
    width: 100%;
    font-family: inherit;
    color: currentColor;

    & > svg {
      margin: 0 0 0 auto;
      //width: 1.2rem;
      //height: 1.2rem;
    }
  }

  &:has(option:not([hidden]):checked) {
    color: variables.$black;
    align-items: center;
  }

  &:focus-visible {
    outline: 2px solid variables.$gray;
    outline-offset: -1px;
  }

  &::picker-icon {
    content: "";
    display: block;
    width: 24px;
    height: 24px;
    position: relative;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' aria-hidden='true'%3E%3Cpath d='m6 9 6 6 6-6'%3E%3C/path%3E%3C/svg%3E");
  }

  &::picker(select) {
    appearance: base-select;
    border: 1px solid variables.$gray;
    padding: 0.25rem;
    margin-top: 0.25rem;
    border-radius: calc(variables.$spacing);
    box-shadow:
      0 4px 6px -1px rgba(0, 0, 0, 0.1),
      0 2px 4px -2px rgba(0, 0, 0, 0.1);
    cursor: default;
    transition:
      opacity 225ms ease-in-out,
      transform 225ms ease-in-out;
    transform-origin: top;
    transform: translateY(0);
    opacity: 1;

    @starting-style {
      transform: translateY(-0.25rem) scale(0.95);
      opacity: 0;
    }
  }

  & optgroup label {
    display: block;
    padding: 0.375rem 0.5rem;
  }

  & option {
    padding: 0.375rem 0.5rem;
    border-radius: calc(0.5rem - 4px);
    outline: none;

    &::after {
      content: "";
      width: 1rem;
      height: 1.5rem;
      margin-left: auto;
      opacity: 0;
      background: center / contain no-repeat
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%2318181b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'%3E%3C/path%3E%3C/svg%3E");
    }

    &::checkmark {
      display: none;
    }

    &:checked {
      background-color: transparent;

      &::after {
        opacity: 1;
      }
    }

    &:hover,
    &:focus-visible {
      background-color: variables.$gray;
      color: variables.$black;
    }
  }
}