summaryrefslogtreecommitdiffhomepage
path: root/packages/ui/src/components/accordion.css
blob: 5724307cd2a099355162433151769e87bf75891e (plain)
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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
[data-component="accordion"] {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0px;
  align-self: stretch;

  [data-slot="accordion-item"] {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0px;
    align-self: stretch;
    overflow: clip;

    [data-slot="accordion-header"] {
      width: 100%;
      display: flex;
      align-items: center;
      margin: 0;
      padding: 0;

      [data-slot="accordion-trigger"] {
        width: 100%;
        display: flex;
        height: 32px;
        padding: 8px 12px;
        justify-content: space-between;
        align-items: center;
        align-self: stretch;
        cursor: default;
        user-select: none;

        background-color: var(--surface-base);
        border: 1px solid var(--border-weak-base);
        overflow: clip;
        color: var(--text-strong);
        transition: background-color 0.15s ease;

        /* text-12-regular */
        font-family: var(--font-family-sans);
        font-size: var(--font-size-small);
        font-style: normal;
        font-weight: var(--font-weight-regular);
        line-height: var(--line-height-large); /* 166.667% */
        letter-spacing: var(--letter-spacing-normal);

        &:hover {
          background-color: var(--surface-base);
        }
        &:focus-visible {
          outline: none;
        }
        &[data-disabled] {
          cursor: not-allowed;
        }
      }
    }

    &[data-expanded] {
      margin-top: 8px;
      margin-bottom: 8px;

      [data-slot="accordion-trigger"] {
        border-top-left-radius: var(--radius-md);
        border-top-right-radius: var(--radius-md);
      }

      [data-slot="accordion-content"] {
        border: 1px solid var(--border-weak-base);
        border-top: none;
        border-bottom-left-radius: var(--radius-md);
        border-bottom-right-radius: var(--radius-md);
      }

      & + [data-slot="accordion-item"] {
        margin-top: 8px;

        [data-slot="accordion-trigger"] {
          border-top-left-radius: var(--radius-md);
          border-top-right-radius: var(--radius-md);
        }
      }
    }

    &:has(+ [data-slot="accordion-item"][data-expanded]) {
      margin-bottom: 8px;

      &[data-closed] {
        border-bottom-left-radius: var(--radius-md);
        border-bottom-right-radius: var(--radius-md);

        [data-slot="accordion-trigger"] {
          border-bottom-left-radius: var(--radius-md);
          border-bottom-right-radius: var(--radius-md);
        }
      }
    }

    &[data-closed] + &[data-closed] {
      [data-slot="accordion-trigger"] {
        border-top: none;
      }
    }

    &:first-child {
      margin-top: 0px;

      &[data-closed] {
        [data-slot="accordion-trigger"] {
          border-top-left-radius: var(--radius-md);
          border-top-right-radius: var(--radius-md);
        }
      }
    }

    &:last-child {
      margin-bottom: 0px;

      &[data-closed] {
        [data-slot="accordion-trigger"] {
          border-bottom-left-radius: var(--radius-md);
          border-bottom-right-radius: var(--radius-md);
        }
      }
    }

    [data-slot="accordion-content"] {
      overflow: hidden;
      width: 100%;

      /* animation: slideUp 250ms cubic-bezier(0.87, 0, 0.13, 1); */
      /**/
      /* &[data-expanded] { */
      /*   animation: slideDown 250ms cubic-bezier(0.87, 0, 0.13, 1); */
      /* } */
    }
  }
}

@keyframes slideDown {
  from {
    height: 0;
  }
  to {
    height: var(--kb-accordion-content-height);
  }
}

@keyframes slideUp {
  from {
    height: var(--kb-accordion-content-height);
  }
  to {
    height: 0;
  }
}