webcoreui 0.1.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (93) hide show
  1. package/README.md +37 -1
  2. package/astro.d.ts +12 -0
  3. package/astro.js +12 -0
  4. package/components/Accordion/accordion.module.scss +1 -2
  5. package/components/Alert/Alert.tsx +4 -1
  6. package/components/Alert/alert.module.scss +3 -3
  7. package/components/Avatar/avatar.module.scss +2 -0
  8. package/components/Badge/badge.module.scss +1 -1
  9. package/components/Button/button.module.scss +2 -2
  10. package/components/Button/button.ts +1 -1
  11. package/components/Card/card.module.scss +0 -1
  12. package/components/Checkbox/checkbox.module.scss +4 -4
  13. package/components/Collapsible/Collapsible.astro +63 -0
  14. package/components/Collapsible/Collapsible.svelte +48 -0
  15. package/components/Collapsible/Collapsible.tsx +54 -0
  16. package/components/Collapsible/collapsible.module.scss +29 -0
  17. package/components/Collapsible/collapsible.ts +14 -0
  18. package/components/Icon/map.ts +2 -0
  19. package/components/Input/input.module.scss +2 -2
  20. package/components/Menu/Menu.astro +7 -3
  21. package/components/Menu/Menu.svelte +11 -3
  22. package/components/Menu/Menu.tsx +7 -1
  23. package/components/Menu/menu.module.scss +4 -1
  24. package/components/Menu/menu.ts +1 -0
  25. package/components/Modal/Modal.astro +70 -0
  26. package/components/Modal/Modal.svelte +71 -0
  27. package/components/Modal/Modal.tsx +76 -0
  28. package/components/Modal/modal.module.scss +103 -0
  29. package/components/Modal/modal.ts +18 -0
  30. package/components/Popover/Popover.astro +23 -0
  31. package/components/Popover/Popover.svelte +21 -0
  32. package/components/Popover/Popover.tsx +27 -0
  33. package/components/Popover/popover.module.scss +51 -0
  34. package/components/Popover/popover.ts +8 -0
  35. package/components/Progress/progress.module.scss +3 -3
  36. package/components/Radio/radio.module.scss +1 -2
  37. package/components/Rating/Rating.astro +2 -2
  38. package/components/Rating/Rating.svelte +2 -2
  39. package/components/Rating/Rating.tsx +2 -2
  40. package/components/Rating/rating.module.scss +1 -1
  41. package/components/Sheet/Sheet.astro +29 -0
  42. package/components/Sheet/Sheet.svelte +24 -0
  43. package/components/Sheet/Sheet.tsx +32 -0
  44. package/components/Sheet/sheet.module.scss +68 -0
  45. package/components/Sheet/sheet.ts +10 -0
  46. package/components/Slider/Slider.astro +44 -0
  47. package/components/Slider/Slider.svelte +42 -0
  48. package/components/Slider/Slider.tsx +48 -0
  49. package/components/Slider/slider.module.scss +68 -0
  50. package/components/Slider/slider.ts +20 -0
  51. package/components/Switch/switch.module.scss +1 -1
  52. package/components/Table/Table.astro +6 -1
  53. package/components/Table/Table.svelte +3 -1
  54. package/components/Table/Table.tsx +7 -1
  55. package/components/Table/table.module.scss +11 -1
  56. package/components/Table/table.ts +1 -0
  57. package/components/Tabs/tabs.module.scss +6 -1
  58. package/components/Textarea/Textarea.astro +44 -0
  59. package/components/Textarea/Textarea.svelte +45 -0
  60. package/components/Textarea/Textarea.tsx +50 -0
  61. package/components/Textarea/textarea.module.scss +36 -0
  62. package/components/Textarea/textarea.ts +18 -0
  63. package/components/ThemeSwitcher/ThemeSwitcher.astro +1 -0
  64. package/components/ThemeSwitcher/ThemeSwitcher.svelte +2 -1
  65. package/components/ThemeSwitcher/ThemeSwitcher.tsx +2 -1
  66. package/components/Timeline/timeline.module.scss +4 -4
  67. package/components/TimelineItem/TimelineItem.tsx +1 -6
  68. package/components/TimelineItem/timelineitem.module.scss +2 -3
  69. package/components/TimelineItem/timelineitem.ts +5 -0
  70. package/components/Toast/Toast.svelte +11 -6
  71. package/icons/close.svg +3 -0
  72. package/icons.d.ts +1 -0
  73. package/icons.js +1 -0
  74. package/index.d.ts +69 -0
  75. package/index.js +4 -0
  76. package/package.json +2 -1
  77. package/react.d.ts +14 -2
  78. package/react.js +12 -0
  79. package/scss/config/color-palette.scss +1 -0
  80. package/scss/config/mixins.scss +152 -155
  81. package/scss/config/typography.scss +8 -9
  82. package/scss/global/theme.scss +71 -38
  83. package/scss/global/tooltip.scss +5 -3
  84. package/scss/global/utility.scss +76 -58
  85. package/scss/resets.scss +10 -5
  86. package/scss/setup.scss +2 -2
  87. package/svelte.d.ts +12 -0
  88. package/svelte.js +12 -0
  89. package/utils/debounce.ts +24 -0
  90. package/utils/interpolate.ts +23 -0
  91. package/utils/modal.ts +59 -0
  92. package/utils/popover.ts +201 -0
  93. package/utils/toast.ts +0 -6
package/README.md CHANGED
@@ -99,7 +99,7 @@ The `Setup` mixin can also accept the following options:
99
99
  | Property | Default value | Purpose |
100
100
  |-----------|---------------|---------|
101
101
  | `includeResets` | `true` | Include reset styles. Set to `false` if you want to use your own CSS resets. |
102
- | `includeHelperClasses` | `true` | Adds global helper classes for CSS. All global helper classes are defined [here](https://github.com/Frontendland/webcoreui/tree/main/src/scss/global). |
102
+ | `includeUtilities` | `true` | Adds utility classes for CSS. Read more about the available utility classes [here](https://webcoreui.dev/docs/layout). |
103
103
  | `includeTooltip` | `true` | Adds styles for using tooltips.
104
104
  | `includeScrollbarStyles` | `true` | Adds styles for scrollbars.
105
105
 
@@ -107,30 +107,60 @@ Default component styles can be changed by overriding the following CSS variable
107
107
 
108
108
  ```scss
109
109
  html body {
110
+ // Avatar component
110
111
  --w-avatar-border: var(--w-color-primary-70);
112
+
113
+ // Checkbox component
111
114
  --w-checkbox-color: var(--w-color-primary);
115
+
116
+ // Collapsible
117
+ --w-collapsible-initial-height: 0;
118
+ --w-collapsible-max-height: 100%;
119
+
120
+ // Progress component
112
121
  --w-progress-color: var(--w-color-primary);
113
122
  --w-progress-background: var(--w-color-primary-50);
114
123
  --w-progress-stripe-light: var(--w-color-primary);
115
124
  --w-progress-stripe-dark: var(--w-color-primary-10);
125
+
126
+ // Radio component
116
127
  --w-radio-color: var(--w-color-primary);
128
+
129
+ // Rating component
117
130
  --w-rating-color: var(--w-color-primary);
118
131
  --w-rating-empty-color: var(--w-color-primary);
119
132
  --w-rating-empty-background: var(--w-color-primary-70);
120
133
  --w-rating-size: 18px;
134
+
135
+ // Scrollbars
121
136
  --w-scrollbar-bg: var(--w-color-primary-60);
122
137
  --w-scrollbar-fg: var(--w-color-primary-50);
138
+
139
+ // Slider component
140
+ --w-slider-background: var(--w-color-primary-50);
141
+ --w-slider-color: var(--w-color-primary);
142
+ --w-slider-thumb: var(--w-color-primary-50);
143
+
144
+ // Spinner component
123
145
  --w-spinner-color: var(--w-color-primary);
124
146
  --w-spinner-width: 2px;
125
147
  --w-spinner-speed: 2s;
126
148
  --w-spinner-size: 30px;
127
149
  --w-spinner-dash: 8;
150
+
151
+ // Switch component
128
152
  --w-switch-off-color: var(--w-color-primary-50);
129
153
  --w-switch-on-color: var(--w-color-primary);
154
+
155
+ // ThemeSwitcher component
130
156
  --w-theme-switcher-size: 20px;
157
+
158
+ // Timeline component
131
159
  --w-timeline-color: var(--w-color-primary-50);
132
160
  --w-timeline-text-color: var(--w-color-primary);
133
161
  --w-timeline-counter: decimal;
162
+
163
+ // Tooltips
134
164
  --w-tooltip-background: var(--w-color-primary);
135
165
  --w-tooltip-color: var(--w-color-primary-70);
136
166
 
@@ -171,17 +201,23 @@ import { Accordion } from 'webcoreui/react'
171
201
  - [Button](https://github.com/Frontendland/webcoreui/tree/main/src/components/Button)
172
202
  - [Card](https://github.com/Frontendland/webcoreui/tree/main/src/components/Card)
173
203
  - [Checkbox](https://github.com/Frontendland/webcoreui/tree/main/src/components/Checkbox)
204
+ - [Collapsible](https://github.com/Frontendland/webcoreui/tree/main/src/components/Collapsible)
174
205
  - [ConditionalWrapper](https://github.com/Frontendland/webcoreui/tree/main/src/components/ConditionalWrapper)
175
206
  - [Icon](https://github.com/Frontendland/webcoreui/tree/main/src/components/Icon)
176
207
  - [Input](https://github.com/Frontendland/webcoreui/tree/main/src/components/Input)
177
208
  - [Menu](https://github.com/Frontendland/webcoreui/tree/main/src/components/Menu)
209
+ - [Modal](https://github.com/Frontendland/webcoreui/tree/main/src/components/Modal)
210
+ - [Popover](https://github.com/Frontendland/webcoreui/tree/main/src/components/Popover)
178
211
  - [Progress](https://github.com/Frontendland/webcoreui/tree/main/src/components/Progress)
179
212
  - [Radio](https://github.com/Frontendland/webcoreui/tree/main/src/components/Radio)
180
213
  - [Rating](https://github.com/Frontendland/webcoreui/tree/main/src/components/Rating)
214
+ - [Sheet](https://github.com/Frontendland/webcoreui/tree/main/src/components/Sheet)
215
+ - [Slider](https://github.com/Frontendland/webcoreui/tree/main/src/components/Slider)
181
216
  - [Spinner](https://github.com/Frontendland/webcoreui/tree/main/src/components/Spinner)
182
217
  - [Switch](https://github.com/Frontendland/webcoreui/tree/main/src/components/Switch)
183
218
  - [Table](https://github.com/Frontendland/webcoreui/tree/main/src/components/Table)
184
219
  - [Tabs](https://github.com/Frontendland/webcoreui/tree/main/src/components/Tabs)
220
+ - [Textarea](https://github.com/Frontendland/webcoreui/tree/main/src/components/Textarea)
185
221
  - [ThemeSwitcher](https://github.com/Frontendland/webcoreui/tree/main/src/components/ThemeSwitcher)
186
222
  - [Timeline](https://github.com/Frontendland/webcoreui/blob/main/src/pages/timeline.astro)
187
223
  - [Toast](https://github.com/Frontendland/webcoreui/tree/main/src/components/Toast)
package/astro.d.ts CHANGED
@@ -5,17 +5,23 @@ import type { BadgeProps } from './components/Badge/badge'
5
5
  import type { ButtonProps } from './components/Button/button'
6
6
  import type { CardProps } from './components/Card/card'
7
7
  import type { CheckboxProps } from './components/Checkbox/checkbox'
8
+ import type { CollapsibleProps } from './components/Collapsible/collapsible'
8
9
  import type { ConditionalWrapperProps } from './components/ConditionalWrapper/conditionalwrapper'
9
10
  import type { IconProps } from './components/Icon/icon'
10
11
  import type { InputProps } from './components/Input/input'
11
12
  import type { MenuProps } from './components/Menu/menu'
13
+ import type { ModalProps } from './components/Modal/modal'
14
+ import type { PopoverProps } from './components/Popover/popover'
12
15
  import type { ProgressProps } from './components/Progress/progress'
13
16
  import type { RadioProps } from './components/Radio/radio'
14
17
  import type { RatingProps } from './components/Rating/rating'
18
+ import type { SheetProps } from './components/Sheet/sheet'
19
+ import type { SliderProps } from './components/Slider/slider'
15
20
  import type { SpinnerProps } from './components/Spinner/spinner'
16
21
  import type { SwitchProps } from './components/Switch/switch'
17
22
  import type { TableProps } from './components/Table/table'
18
23
  import type { TabsProps } from './components/Tabs/tabs'
24
+ import type { TextareaProps } from './components/Textarea/textarea'
19
25
  import type { ThemeSwitcherProps } from './components/ThemeSwitcher/themeswitcher'
20
26
  import type { TimelineProps } from './components/Timeline/timeline'
21
27
  import type { TimelineItemProps } from './components/TimelineItem/timelineitem'
@@ -29,17 +35,23 @@ declare module 'webcoreui/astro' {
29
35
  export function Button(_props: ButtonProps): any
30
36
  export function Card(_props: CardProps): any
31
37
  export function Checkbox(_props: CheckboxProps): any
38
+ export function Collapsible(_props: CollapsibleProps): any
32
39
  export function ConditionalWrapper(_props: ConditionalWrapperProps): any
33
40
  export function Icon(_props: IconProps): any
34
41
  export function Input(_props: InputProps): any
35
42
  export function Menu(_props: MenuProps): any
43
+ export function Modal(_props: ModalProps): any
44
+ export function Popover(_props: PopoverProps): any
36
45
  export function Progress(_props: ProgressProps): any
37
46
  export function Radio(_props: RadioProps): any
38
47
  export function Rating(_props: RatingProps): any
48
+ export function Sheet(_props: SheetProps): any
49
+ export function Slider(_props: SliderProps): any
39
50
  export function Spinner(_props: SpinnerProps): any
40
51
  export function Switch(_props: SwitchProps): any
41
52
  export function Table(_props: TableProps): any
42
53
  export function Tabs(_props: TabsProps): any
54
+ export function Textarea(_props: TextareaProps): any
43
55
  export function ThemeSwitcher(_props: ThemeSwitcherProps): any
44
56
  export function Timeline(_props: TimelineProps): any
45
57
  export function TimelineItem(_props: TimelineItemProps): any
package/astro.js CHANGED
@@ -5,17 +5,23 @@ import BadgeComponent from './components/Badge/Badge.astro'
5
5
  import ButtonComponent from './components/Button/Button.astro'
6
6
  import CardComponent from './components/Card/Card.astro'
7
7
  import CheckboxComponent from './components/Checkbox/Checkbox.astro'
8
+ import CollapsibleComponent from './components/Collapsible/Collapsible.astro'
8
9
  import ConditionalWrapperComponent from './components/ConditionalWrapper/ConditionalWrapper.astro'
9
10
  import IconComponent from './components/Icon/Icon.astro'
10
11
  import InputComponent from './components/Input/Input.astro'
11
12
  import MenuComponent from './components/Menu/Menu.astro'
13
+ import ModalComponent from './components/Modal/Modal.astro'
14
+ import PopoverComponent from './components/Popover/Popover.astro'
12
15
  import ProgressComponent from './components/Progress/Progress.astro'
13
16
  import RadioComponent from './components/Radio/Radio.astro'
14
17
  import RatingComponent from './components/Rating/Rating.astro'
18
+ import SheetComponent from './components/Sheet/Sheet.astro'
19
+ import SliderComponent from './components/Slider/Slider.astro'
15
20
  import SpinnerComponent from './components/Spinner/Spinner.astro'
16
21
  import SwitchComponent from './components/Switch/Switch.astro'
17
22
  import TableComponent from './components/Table/Table.astro'
18
23
  import TabsComponent from './components/Tabs/Tabs.astro'
24
+ import TextareaComponent from './components/Textarea/Textarea.astro'
19
25
  import ThemeSwitcherComponent from './components/ThemeSwitcher/ThemeSwitcher.astro'
20
26
  import TimelineComponent from './components/Timeline/Timeline.astro'
21
27
  import TimelineItemComponent from './components/TimelineItem/TimelineItem.astro'
@@ -28,17 +34,23 @@ export const Badge = BadgeComponent
28
34
  export const Button = ButtonComponent
29
35
  export const Card = CardComponent
30
36
  export const Checkbox = CheckboxComponent
37
+ export const Collapsible = CollapsibleComponent
31
38
  export const ConditionalWrapper = ConditionalWrapperComponent
32
39
  export const Icon = IconComponent
33
40
  export const Input = InputComponent
34
41
  export const Menu = MenuComponent
42
+ export const Modal = ModalComponent
43
+ export const Popover = PopoverComponent
35
44
  export const Progress = ProgressComponent
36
45
  export const Radio = RadioComponent
37
46
  export const Rating = RatingComponent
47
+ export const Sheet = SheetComponent
48
+ export const Slider = SliderComponent
38
49
  export const Spinner = SpinnerComponent
39
50
  export const Switch = SwitchComponent
40
51
  export const Table = TableComponent
41
52
  export const Tabs = TabsComponent
53
+ export const Textarea = TextareaComponent
42
54
  export const ThemeSwitcher = ThemeSwitcherComponent
43
55
  export const Timeline = TimelineComponent
44
56
  export const TimelineItem = TimelineItemComponent
@@ -7,7 +7,6 @@
7
7
  li {
8
8
  @include border(primary-50, bottom);
9
9
  @include spacing(py-sm, px-none, m0);
10
- @include typography(md);
11
10
 
12
11
  &:first-child {
13
12
  padding-top: 0;
@@ -20,7 +19,7 @@
20
19
 
21
20
  .title {
22
21
  @include layout(flex, h-between, v-center, sm);
23
- @include typography(md, primary, left);
22
+ @include typography(default, primary, left);
24
23
  @include size('w100%');
25
24
  @include spacing(p0);
26
25
  @include border(0);
@@ -38,7 +38,10 @@ const Alert = ({
38
38
  return (
39
39
  <Element className={classes} {...rest}>
40
40
  {icon && icon}
41
- {!icon && theme && <div dangerouslySetInnerHTML={{ __html: iconMap[theme] }} />}
41
+ {!icon && theme && <div
42
+ dangerouslySetInnerHTML={{ __html: iconMap[theme] }}
43
+ style={{ height: '20px' }}
44
+ />}
42
45
 
43
46
  <ConditionalWrapper condition={!!(icon || theme)} wrapper={children => (
44
47
  <div className={styles.wrapper}>
@@ -37,15 +37,15 @@
37
37
  svg {
38
38
  @include size(20px);
39
39
  min-width: 20px;
40
- margin-top: 1px;
40
+ margin-top: 2.5px;
41
41
  }
42
42
 
43
43
  .title {
44
- @include spacing(mb-xs);
44
+ @include typography(lg, hmd);
45
45
  display: block;
46
46
  }
47
47
 
48
48
  .body {
49
- @include typography(primary-20, md, hmd);
49
+ @include typography(primary-20, hmd);
50
50
  }
51
51
  }
@@ -7,6 +7,8 @@ body {
7
7
  .avatar {
8
8
  @include border-radius(max);
9
9
 
10
+ object-fit: cover;
11
+
10
12
  &:not(.borderless) {
11
13
  border: 3px solid var(--w-avatar-border);
12
14
  }
@@ -5,7 +5,7 @@
5
5
  @include spacing(py-xs, px-sm);
6
6
  @include border-radius(xs);
7
7
  @include layout(inline-flex, v-center, xs);
8
- @include typography(xs, primary-50);
8
+ @include typography(sm, primary-50);
9
9
  @include border(0);
10
10
  @include background(primary);
11
11
 
@@ -1,8 +1,8 @@
1
1
  @use '../../scss/config.scss' as *;
2
2
 
3
3
  .button {
4
- @include layout(inline-flex, v-center, xs);
5
- @include typography(md, primary-50, none);
4
+ @include layout(inline-flex, center, xs);
5
+ @include typography(default, primary-50, none);
6
6
  @include spacing(py-sm, px-md);
7
7
  @include border-radius(xs);
8
8
  @include border(0);
@@ -18,5 +18,5 @@ export type SvelteButtonProps = {
18
18
 
19
19
  export type ReactButtonProps = {
20
20
  onClick?: () => any
21
- children: React.ReactNode
21
+ children?: React.ReactNode
22
22
  } & ButtonProps
@@ -16,7 +16,6 @@
16
16
  .title {
17
17
  @include spacing(p-default);
18
18
  @include border(primary-50, bottom);
19
- @include typography(md);
20
19
  display: block;
21
20
  }
22
21
 
@@ -6,7 +6,7 @@ body {
6
6
 
7
7
  .checkbox {
8
8
  @include layout(inline-flex, sm);
9
- @include typography(md, hmd);
9
+ @include typography(hmd);
10
10
 
11
11
  cursor: pointer;
12
12
 
@@ -34,8 +34,8 @@ body {
34
34
  }
35
35
 
36
36
  &:disabled + span {
37
- @include background(primary-40);
38
- @include border(primary-40);
37
+ @include background(primary-30);
38
+ @include border(primary-30);
39
39
  cursor: no-drop;
40
40
  }
41
41
  }
@@ -57,7 +57,7 @@ body {
57
57
 
58
58
  .text {
59
59
  @include spacing(ml-lg);
60
- @include typography(sm, primary-20);
60
+ @include typography(md, primary-20);
61
61
 
62
62
  a {
63
63
  @include typography(primary-20);
@@ -0,0 +1,63 @@
1
+ ---
2
+ import type { CollapsibleProps } from './collapsible'
3
+
4
+ import styles from './collapsible.module.scss'
5
+ import { classNames } from '../../utils/classNames'
6
+
7
+ interface Props extends CollapsibleProps {}
8
+
9
+ const {
10
+ initialHeight,
11
+ maxHeight,
12
+ toggled,
13
+ className,
14
+ togglesClassName
15
+ } = Astro.props
16
+
17
+ const classes = [
18
+ styles.collapsible,
19
+ maxHeight && styles.animated,
20
+ className
21
+ ]
22
+
23
+ const styleVariables = classNames([
24
+ initialHeight && `--w-collapsible-initial-height: ${initialHeight};`,
25
+ maxHeight && `--w-collapsible-max-height: ${maxHeight};`
26
+ ])
27
+ ---
28
+
29
+ <div
30
+ class:list={classes}
31
+ data-toggled={toggled ? 'true' : undefined}
32
+ data-id="w-collapsible"
33
+ >
34
+ <div
35
+ class={styles.wrapper}
36
+ style={styleVariables}
37
+ >
38
+ <slot />
39
+ </div>
40
+ <div class:list={togglesClassName}>
41
+ <div data-toggle-on="true"><slot name="on" /></div>
42
+ <div data-toggle-off="true"><slot name="off" /></div>
43
+ </div>
44
+ </div>
45
+
46
+ <script>
47
+ const collapsibles = document.querySelectorAll('[data-id="w-collapsible"]')
48
+
49
+ Array.from(collapsibles).forEach(element => {
50
+ element.addEventListener('click', event => {
51
+ const collapsible = event.currentTarget as HTMLDivElement
52
+ const target = event.target as HTMLDivElement
53
+
54
+ if (target.parentElement?.dataset.toggleOn) {
55
+ collapsible.dataset.toggled = 'true'
56
+ }
57
+
58
+ if (target.parentElement?.dataset.toggleOff) {
59
+ collapsible.dataset.toggled = 'false'
60
+ }
61
+ })
62
+ })
63
+ </script>
@@ -0,0 +1,48 @@
1
+ <script lang="ts">
2
+ import type { CollapsibleProps } from './collapsible'
3
+
4
+ import styles from './collapsible.module.scss'
5
+ import { classNames } from '../../utils/classNames'
6
+
7
+ export let initialHeight: CollapsibleProps['initialHeight'] = ''
8
+ export let maxHeight: CollapsibleProps['maxHeight'] = ''
9
+ export let toggled: CollapsibleProps['toggled'] = false
10
+ export let className: CollapsibleProps['className'] = ''
11
+ export let togglesClassName: CollapsibleProps['togglesClassName'] = ''
12
+
13
+ const classes = classNames([
14
+ styles.collapsible,
15
+ maxHeight && styles.animated,
16
+ className
17
+ ])
18
+
19
+ const styleVariables = classNames([
20
+ initialHeight && `--w-collapsible-initial-height: ${initialHeight};`,
21
+ maxHeight && `--w-collapsible-max-height: ${maxHeight};`
22
+ ])
23
+ </script>
24
+
25
+ <div
26
+ class={classes}
27
+ data-toggled={toggled ? 'true' : undefined}
28
+ >
29
+ <div
30
+ class={styles.wrapper}
31
+ style={styleVariables}
32
+ >
33
+ <slot />
34
+ </div>
35
+ <div
36
+ on:click={() => toggled = !toggled}
37
+ on:keyup={() => toggled = !toggled}
38
+ role="button"
39
+ tabindex={0}
40
+ class={togglesClassName}
41
+ >
42
+ {#if toggled}
43
+ <slot name="off" />
44
+ {:else}
45
+ <slot name="on" />
46
+ {/if}
47
+ </div>
48
+ </div>
@@ -0,0 +1,54 @@
1
+ import React, { useState } from 'react'
2
+ import type { ReactCollapsibleProps } from './collapsible'
3
+
4
+ import styles from './collapsible.module.scss'
5
+ import { classNames } from '../../utils/classNames'
6
+
7
+ const Collapsible = ({
8
+ initialHeight,
9
+ maxHeight,
10
+ toggled,
11
+ on,
12
+ off,
13
+ children,
14
+ className,
15
+ togglesClassName
16
+ }: ReactCollapsibleProps) => {
17
+ const [toggle, setToggled] = useState(toggled)
18
+
19
+ const classes = classNames([
20
+ styles.collapsible,
21
+ maxHeight && styles.animated,
22
+ className
23
+ ])
24
+
25
+ const styleVariables = {
26
+ ...(initialHeight && { '--w-collapsible-initial-height': initialHeight }),
27
+ ...(maxHeight && { '--w-collapsible-max-height': maxHeight })
28
+ } as React.CSSProperties
29
+
30
+ return (
31
+ <div
32
+ className={classes}
33
+ data-toggled={toggle ? 'true' : undefined}
34
+ >
35
+ <div
36
+ className={styles.wrapper}
37
+ style={styleVariables}
38
+ >
39
+ {children}
40
+ </div>
41
+ <div
42
+ onClick={() => setToggled(!toggle)}
43
+ onKeyUp={() => setToggled(!toggle)}
44
+ role="button"
45
+ tabIndex={0}
46
+ className={togglesClassName}
47
+ >
48
+ {toggle ? off : on}
49
+ </div>
50
+ </div>
51
+ )
52
+ }
53
+
54
+ export default Collapsible
@@ -0,0 +1,29 @@
1
+ @import '../../scss/config.scss';
2
+
3
+ body {
4
+ --w-collapsible-initial-height: 0;
5
+ --w-collapsible-max-height: 100%;
6
+ }
7
+
8
+ .collapsible {
9
+ @include layout(flex, column, xs);
10
+
11
+ &:not([data-toggled="true"]) [data-toggle-off],
12
+ &[data-toggled="true"] [data-toggle-on] {
13
+ @include visibility(none);
14
+ }
15
+
16
+ &[data-toggled="true"] .wrapper {
17
+ max-height: var(--w-collapsible-max-height);
18
+ }
19
+
20
+ &.animated .wrapper {
21
+ @include transition(max-height, .5s);
22
+ }
23
+
24
+ .wrapper {
25
+ @include visibility(hidden);
26
+
27
+ max-height: var(--w-collapsible-initial-height);
28
+ }
29
+ }
@@ -0,0 +1,14 @@
1
+ export type CollapsibleProps = {
2
+ initialHeight?: string
3
+ maxHeight?: string
4
+ toggled?: boolean
5
+ className?: string
6
+ togglesClassName?: string
7
+ }
8
+
9
+ export type ReactCollapsibleProps = {
10
+ on: React.ReactNode
11
+ off: React.ReactNode
12
+ children?: React.ReactNode
13
+ } & CollapsibleProps
14
+
@@ -2,6 +2,7 @@ import Alert from '../../icons/alert.svg?raw'
2
2
  import ArrowDown from '../../icons/arrow-down.svg?raw'
3
3
  import Check from '../../icons/check.svg?raw'
4
4
  import CircleCheck from '../../icons/circle-check.svg?raw'
5
+ import Close from '../../icons/close.svg?raw'
5
6
  import Github from '../../icons/github.svg?raw'
6
7
  import Info from '../../icons/info.svg?raw'
7
8
  import Moon from '../../icons/moon.svg?raw'
@@ -13,6 +14,7 @@ const iconMap = {
13
14
  'arrow-down': ArrowDown,
14
15
  'check': Check,
15
16
  'circle-check': CircleCheck,
17
+ 'close': Close,
16
18
  'github': Github,
17
19
  'info': Info,
18
20
  'moon': Moon,
@@ -54,7 +54,7 @@
54
54
  @include layout(flex, column);
55
55
 
56
56
  .label {
57
- @include typography(md, primary-20);
57
+ @include typography(primary-20);
58
58
  @include spacing(mb-xs);
59
59
  }
60
60
 
@@ -73,7 +73,7 @@
73
73
  }
74
74
 
75
75
  .subtext {
76
- @include typography(sm, primary-30);
76
+ @include typography(md, primary-30);
77
77
  @include spacing(mt-xs);
78
78
  }
79
79
  }
@@ -45,7 +45,7 @@ const wrapMenu = (logo?.url || logo?.html) && items?.length && Astro.slots.has('
45
45
  )}
46
46
 
47
47
  {!centerLogo && logo?.html && (
48
- <a href="/">
48
+ <a href="/" aria-label={logo.alt || 'Logo'}>
49
49
  <Fragment set:html={logo.html} />
50
50
  </a>
51
51
  )}
@@ -54,7 +54,11 @@ const wrapMenu = (logo?.url || logo?.html) && items?.length && Astro.slots.has('
54
54
  <ul>
55
55
  {items.map(item => (
56
56
  <li>
57
- <a href={item.url} target={item.target}>
57
+ <a
58
+ href={item.url}
59
+ target={item.target}
60
+ class:list={[item.active && styles.active]}
61
+ >
58
62
  {item.name}
59
63
  </a>
60
64
  </li>
@@ -73,7 +77,7 @@ const wrapMenu = (logo?.url || logo?.html) && items?.length && Astro.slots.has('
73
77
  )}
74
78
 
75
79
  {centerLogo && logo?.html && (
76
- <a href="/">
80
+ <a href="/" aria-label={logo.alt || 'Logo'}>
77
81
  <Fragment set:html={logo.html} />
78
82
  </a>
79
83
  )}
@@ -43,14 +43,20 @@
43
43
  {/if}
44
44
 
45
45
  {#if !centerLogo && logo?.html}
46
- <a href="/">{@html logo.html}</a>
46
+ <a href="/" aria-label={logo.alt || 'Logo'}>
47
+ {@html logo.html}
48
+ </a>
47
49
  {/if}
48
50
 
49
51
  {#if items?.length}
50
52
  <ul>
51
53
  {#each items as item}
52
54
  <li>
53
- <a href={item.url} target={item.target}>
55
+ <a
56
+ href={item.url}
57
+ target={item.target}
58
+ class={item.active ? styles.active : null}
59
+ >
54
60
  {item.name}
55
61
  </a>
56
62
  </li>
@@ -69,7 +75,9 @@
69
75
  {/if}
70
76
 
71
77
  {#if centerLogo && logo?.html}
72
- <a href="/">{@html logo.html}</a>
78
+ <a href="/" aria-label={logo.alt || 'Logo'}>
79
+ {@html logo.html}
80
+ </a>
73
81
  {/if}
74
82
 
75
83
  {#if logo?.url && centerLogo}
@@ -55,6 +55,7 @@ const Menu = ({
55
55
  <a
56
56
  href="/"
57
57
  dangerouslySetInnerHTML={{ __html: logo.html }}
58
+ aria-label={logo.alt || 'Logo'}
58
59
  />
59
60
  )}
60
61
 
@@ -62,7 +63,11 @@ const Menu = ({
62
63
  <ul>
63
64
  {items.map((item, index) => (
64
65
  <li key={index}>
65
- <a href={item.url} target={item.target}>
66
+ <a
67
+ href={item.url}
68
+ target={item.target}
69
+ className={item.active ? styles.active : undefined}
70
+ >
66
71
  {item.name}
67
72
  </a>
68
73
  </li>
@@ -84,6 +89,7 @@ const Menu = ({
84
89
  <a
85
90
  href="/"
86
91
  dangerouslySetInnerHTML={{ __html: logo.html }}
92
+ aria-label={logo.alt || 'Logo'}
87
93
  />
88
94
  )}
89
95