webcoreui 0.0.11 → 0.0.12

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 (122) hide show
  1. package/README.md +33 -7
  2. package/astro.d.ts +4 -0
  3. package/astro.js +4 -0
  4. package/components/Accordion/Accordion.astro +10 -8
  5. package/components/Accordion/Accordion.svelte +8 -8
  6. package/components/Accordion/Accordion.tsx +7 -6
  7. package/components/Accordion/{accordion.scss → accordion.module.scss} +18 -10
  8. package/components/Alert/Alert.astro +11 -7
  9. package/components/Alert/Alert.svelte +9 -7
  10. package/components/Alert/Alert.tsx +11 -7
  11. package/components/Alert/alert.module.scss +54 -0
  12. package/components/Alert/alert.ts +3 -1
  13. package/components/Avatar/Avatar.astro +4 -4
  14. package/components/Avatar/Avatar.svelte +13 -7
  15. package/components/Avatar/Avatar.tsx +11 -9
  16. package/components/Avatar/{avatar.scss → avatar.module.scss} +2 -2
  17. package/components/Badge/Badge.astro +8 -8
  18. package/components/Badge/Badge.svelte +25 -13
  19. package/components/Badge/Badge.tsx +26 -8
  20. package/components/Badge/badge.module.scss +89 -0
  21. package/components/Badge/badge.ts +8 -1
  22. package/components/Button/Button.astro +10 -6
  23. package/components/Button/Button.svelte +15 -11
  24. package/components/Button/Button.tsx +11 -7
  25. package/components/Button/button.module.scss +94 -0
  26. package/components/Button/button.ts +6 -1
  27. package/components/Card/Card.astro +7 -15
  28. package/components/Card/Card.svelte +16 -13
  29. package/components/Card/Card.tsx +15 -11
  30. package/components/Card/card.module.scss +33 -0
  31. package/components/Checkbox/Checkbox.astro +10 -10
  32. package/components/Checkbox/Checkbox.svelte +19 -18
  33. package/components/Checkbox/Checkbox.tsx +12 -11
  34. package/components/Checkbox/{checkbox.scss → checkbox.module.scss} +16 -17
  35. package/components/Checkbox/checkbox.ts +5 -1
  36. package/components/ConditionalWrapper/ConditionalWrapper.svelte +1 -1
  37. package/components/Icon/Icon.svelte +1 -8
  38. package/components/Icon/Icon.tsx +1 -8
  39. package/components/Icon/map.ts +23 -0
  40. package/components/Input/Input.astro +50 -52
  41. package/components/Input/Input.svelte +52 -52
  42. package/components/Input/Input.tsx +59 -59
  43. package/components/Input/{input.scss → input.module.scss} +87 -83
  44. package/components/Input/input.ts +8 -2
  45. package/components/Menu/Menu.astro +107 -0
  46. package/components/Menu/Menu.svelte +88 -0
  47. package/components/Menu/Menu.tsx +107 -0
  48. package/components/Menu/menu.module.scss +144 -0
  49. package/components/Menu/menu.ts +21 -0
  50. package/components/Progress/Progress.astro +42 -40
  51. package/components/Progress/Progress.svelte +40 -38
  52. package/components/Progress/Progress.tsx +48 -47
  53. package/components/Progress/{progress.scss → progress.module.scss} +66 -66
  54. package/components/Radio/Radio.astro +57 -57
  55. package/components/Radio/Radio.svelte +58 -56
  56. package/components/Radio/Radio.tsx +69 -68
  57. package/components/Radio/{radio.scss → radio.module.scss} +92 -92
  58. package/components/Radio/radio.ts +4 -0
  59. package/components/Rating/Rating.astro +13 -10
  60. package/components/Rating/Rating.svelte +15 -15
  61. package/components/Rating/Rating.tsx +22 -11
  62. package/components/Rating/{rating.scss → rating.module.scss} +10 -9
  63. package/components/Rating/rating.ts +1 -1
  64. package/components/Spinner/Spinner.astro +44 -42
  65. package/components/Spinner/Spinner.svelte +40 -38
  66. package/components/Spinner/Spinner.tsx +45 -44
  67. package/components/Spinner/{spinner.scss → spinner.module.scss} +41 -41
  68. package/components/Switch/Switch.astro +13 -11
  69. package/components/Switch/Switch.svelte +26 -24
  70. package/components/Switch/Switch.tsx +14 -12
  71. package/components/Switch/{switch.scss → switch.module.scss} +4 -4
  72. package/components/Switch/switch.ts +8 -4
  73. package/components/Table/Table.astro +60 -60
  74. package/components/Table/Table.svelte +56 -54
  75. package/components/Table/Table.tsx +64 -63
  76. package/components/Table/{table.scss → table.module.scss} +64 -65
  77. package/components/Tabs/Tabs.astro +77 -76
  78. package/components/Tabs/Tabs.svelte +56 -54
  79. package/components/Tabs/Tabs.tsx +70 -69
  80. package/components/Tabs/{tabs.scss → tabs.module.scss} +30 -31
  81. package/components/ThemeSwitcher/ThemeSwitcher.astro +106 -0
  82. package/components/ThemeSwitcher/ThemeSwitcher.svelte +76 -0
  83. package/components/ThemeSwitcher/ThemeSwitcher.tsx +89 -0
  84. package/components/ThemeSwitcher/themeswitcher.module.scss +74 -0
  85. package/components/ThemeSwitcher/themeswitcher.ts +13 -0
  86. package/components/Timeline/Timeline.astro +36 -34
  87. package/components/Timeline/Timeline.svelte +32 -30
  88. package/components/Timeline/Timeline.tsx +38 -37
  89. package/components/Timeline/{timeline.scss → timeline.module.scss} +71 -71
  90. package/components/TimelineItem/TimelineItem.astro +27 -26
  91. package/components/TimelineItem/TimelineItem.svelte +24 -22
  92. package/components/TimelineItem/TimelineItem.tsx +33 -32
  93. package/components/TimelineItem/{timelineitem.scss → timelineitem.module.scss} +31 -31
  94. package/components/Toast/Toast.astro +41 -30
  95. package/components/Toast/Toast.svelte +32 -21
  96. package/components/Toast/Toast.tsx +38 -28
  97. package/components/Toast/{toast.scss → toast.module.scss} +44 -43
  98. package/components/Toast/toast.ts +3 -6
  99. package/icons/moon.svg +3 -0
  100. package/icons/sun.svg +3 -0
  101. package/index.js +3 -0
  102. package/package.json +3 -1
  103. package/react.d.ts +4 -0
  104. package/react.js +4 -0
  105. package/scss/global/elements.scss +1 -1
  106. package/scss/global/scrollbar.scss +21 -0
  107. package/scss/global/theme.scss +140 -0
  108. package/scss/global/tooltip.scss +8 -5
  109. package/scss/global/utility.scss +29 -0
  110. package/scss/global.scss +2 -0
  111. package/scss/resets.scss +5 -5
  112. package/scss/setup.scss +39 -18
  113. package/svelte.d.ts +16 -12
  114. package/svelte.js +4 -0
  115. package/utils/classNames.ts +4 -0
  116. package/utils/cookies.ts +28 -0
  117. package/utils/event.ts +17 -0
  118. package/utils/toast.ts +12 -9
  119. package/components/Alert/alert.scss +0 -53
  120. package/components/Badge/badge.scss +0 -85
  121. package/components/Button/button.scss +0 -91
  122. package/components/Card/card.scss +0 -37
package/README.md CHANGED
@@ -23,7 +23,7 @@
23
23
  </p>
24
24
 
25
25
  > [!IMPORTANT]
26
- > This library is still in early development. New changes can break existing functionality, and no functionality should be considered final. The library will be considered stable once it reaches v1.0.
26
+ > This library is still in early development. New changes can break existing functionality, and no functionality should be considered final at this stage. The library will be considered stable once it reaches v1.0.
27
27
 
28
28
  ---
29
29
  ## Table of Contents
@@ -39,7 +39,7 @@
39
39
 
40
40
  ## Documentation
41
41
 
42
- Full documentation coming soon on [webcoreui.dev/docs](https://webcoreui.dev/docs).
42
+ Full documentation available on [webcoreui.dev](https://webcoreui.dev).
43
43
 
44
44
  ## Getting Started
45
45
 
@@ -101,15 +101,39 @@ The `Setup` mixin can also accept the following options:
101
101
  | `includeResets` | `true` | Include reset styles. Set to `false` if you want to use your own CSS resets. |
102
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). |
103
103
  | `includeElementStyles` | `true` | Adds styles for native HTML elements, such as `code`, `pre`, or `ul`.
104
+ | `includeTooltip` | `true` | Adds styles for using tooltips.
105
+ | `includeScrollbarStyles` | `true` | Adds styles for scrollbars.
104
106
 
105
- Default component styles can also be changed by overriding the following CSS variables:
107
+ Default component styles can be changed by overriding the following CSS variables:
106
108
 
107
109
  ```css
108
- :root {
109
- --w-avatar-border: #000;
110
- --w-rating-color: #FFF;
111
- --w-rating-empty-color: #BBB;
110
+ body {
111
+ --w-avatar-border: var(--w-color-primary-70);
112
+ --w-checkbox-color: var(--w-color-primary);
113
+ --w-progress-color: var(--w-color-primary);
114
+ --w-progress-background: var(--w-color-primary-50);
115
+ --w-progress-stripe-light: var(--w-color-primary);
116
+ --w-progress-stripe-dark: var(--w-color-primary-10);
117
+ --w-radio-color: var(--w-color-primary);
118
+ --w-rating-color: var(--w-color-primary);
119
+ --w-rating-empty-color: var(--w-color-primary);
120
+ --w-rating-empty-background: var(--w-color-primary-70);
112
121
  --w-rating-size: 18px;
122
+ --w-scrollbar-bg: var(--w-color-primary-60);
123
+ --w-scrollbar-fg: var(--w-color-primary-50);
124
+ --w-spinner-color: var(--w-color-primary);
125
+ --w-spinner-width: 2px;
126
+ --w-spinner-speed: 2s;
127
+ --w-spinner-size: 30px;
128
+ --w-spinner-dash: 8;
129
+ --w-switch-off-color: var(--w-color-primary-50);
130
+ --w-switch-on-color: var(--w-color-primary);
131
+ --w-theme-switcher-size: 20px;
132
+ --w-timeline-color: var(--w-color-primary-50);
133
+ --w-timeline-text-color: var(--w-color-primary);
134
+ --w-timeline-counter: decimal;
135
+ --w-tooltip-background: var(--w-color-primary);
136
+ --w-tooltip-color: var(--w-color-primary-70);
113
137
  }
114
138
  ```
115
139
 
@@ -145,6 +169,7 @@ import { Accordion } from 'webcoreui/react'
145
169
  - [ConditionalWrapper](https://github.com/Frontendland/webcoreui/tree/main/src/components/ConditionalWrapper)
146
170
  - [Icon](https://github.com/Frontendland/webcoreui/tree/main/src/components/Icon)
147
171
  - [Input](https://github.com/Frontendland/webcoreui/tree/main/src/components/Input)
172
+ - [Menu](https://github.com/Frontendland/webcoreui/tree/main/src/components/Menu)
148
173
  - [Progress](https://github.com/Frontendland/webcoreui/tree/main/src/components/Progress)
149
174
  - [Radio](https://github.com/Frontendland/webcoreui/tree/main/src/components/Radio)
150
175
  - [Rating](https://github.com/Frontendland/webcoreui/tree/main/src/components/Rating)
@@ -152,6 +177,7 @@ import { Accordion } from 'webcoreui/react'
152
177
  - [Switch](https://github.com/Frontendland/webcoreui/tree/main/src/components/Switch)
153
178
  - [Table](https://github.com/Frontendland/webcoreui/tree/main/src/components/Table)
154
179
  - [Tabs](https://github.com/Frontendland/webcoreui/tree/main/src/components/Tabs)
180
+ - [ThemeSwitcher](https://github.com/Frontendland/webcoreui/tree/main/src/components/ThemeSwitcher)
155
181
  - [Timeline](https://github.com/Frontendland/webcoreui/blob/main/src/pages/timeline.astro)
156
182
  - [Toast](https://github.com/Frontendland/webcoreui/tree/main/src/components/Toast)
157
183
  - [Tooltip](https://github.com/Frontendland/webcoreui/blob/main/src/pages/tooltip.astro)
package/astro.d.ts CHANGED
@@ -8,6 +8,7 @@ import type { CheckboxProps } from './components/Checkbox/checkbox'
8
8
  import type { ConditionalWrapperProps } from './components/ConditionalWrapper/conditionalwrapper'
9
9
  import type { IconProps } from './components/Icon/icon'
10
10
  import type { InputProps } from './components/Input/input'
11
+ import type { MenuProps } from './components/Menu/menu'
11
12
  import type { ProgressProps } from './components/Progress/progress'
12
13
  import type { RadioProps } from './components/Radio/radio'
13
14
  import type { RatingProps } from './components/Rating/rating'
@@ -15,6 +16,7 @@ import type { SpinnerProps } from './components/Spinner/spinner'
15
16
  import type { SwitchProps } from './components/Switch/switch'
16
17
  import type { TableProps } from './components/Table/table'
17
18
  import type { TabsProps } from './components/Tabs/tabs'
19
+ import type { ThemeSwitcherProps } from './components/ThemeSwitcher/themeswitcher'
18
20
  import type { TimelineProps } from './components/Timeline/timeline'
19
21
  import type { TimelineItemProps } from './components/TimelineItem/timelineitem'
20
22
  import type { ToastProps } from './components/Toast/toast'
@@ -30,6 +32,7 @@ declare module 'webcoreui/astro' {
30
32
  export function ConditionalWrapper(_props: ConditionalWrapperProps): any
31
33
  export function Icon(_props: IconProps): any
32
34
  export function Input(_props: InputProps): any
35
+ export function Menu(_props: MenuProps): any
33
36
  export function Progress(_props: ProgressProps): any
34
37
  export function Radio(_props: RadioProps): any
35
38
  export function Rating(_props: RatingProps): any
@@ -37,6 +40,7 @@ declare module 'webcoreui/astro' {
37
40
  export function Switch(_props: SwitchProps): any
38
41
  export function Table(_props: TableProps): any
39
42
  export function Tabs(_props: TabsProps): any
43
+ export function ThemeSwitcher(_props: ThemeSwitcherProps): any
40
44
  export function Timeline(_props: TimelineProps): any
41
45
  export function TimelineItem(_props: TimelineItemProps): any
42
46
  export function Toast(_props: ToastProps): any
package/astro.js CHANGED
@@ -8,6 +8,7 @@ import CheckboxComponent from './components/Checkbox/Checkbox.astro'
8
8
  import ConditionalWrapperComponent from './components/ConditionalWrapper/ConditionalWrapper.astro'
9
9
  import IconComponent from './components/Icon/Icon.astro'
10
10
  import InputComponent from './components/Input/Input.astro'
11
+ import MenuComponent from './components/Menu/Menu.astro'
11
12
  import ProgressComponent from './components/Progress/Progress.astro'
12
13
  import RadioComponent from './components/Radio/Radio.astro'
13
14
  import RatingComponent from './components/Rating/Rating.astro'
@@ -15,6 +16,7 @@ import SpinnerComponent from './components/Spinner/Spinner.astro'
15
16
  import SwitchComponent from './components/Switch/Switch.astro'
16
17
  import TableComponent from './components/Table/Table.astro'
17
18
  import TabsComponent from './components/Tabs/Tabs.astro'
19
+ import ThemeSwitcherComponent from './components/ThemeSwitcher/ThemeSwitcher.astro'
18
20
  import TimelineComponent from './components/Timeline/Timeline.astro'
19
21
  import TimelineItemComponent from './components/TimelineItem/TimelineItem.astro'
20
22
  import ToastComponent from './components/Toast/Toast.astro'
@@ -29,6 +31,7 @@ export const Checkbox = CheckboxComponent
29
31
  export const ConditionalWrapper = ConditionalWrapperComponent
30
32
  export const Icon = IconComponent
31
33
  export const Input = InputComponent
34
+ export const Menu = MenuComponent
32
35
  export const Progress = ProgressComponent
33
36
  export const Radio = RadioComponent
34
37
  export const Rating = RatingComponent
@@ -36,6 +39,7 @@ export const Spinner = SpinnerComponent
36
39
  export const Switch = SwitchComponent
37
40
  export const Table = TableComponent
38
41
  export const Tabs = TabsComponent
42
+ export const ThemeSwitcher = ThemeSwitcherComponent
39
43
  export const Timeline = TimelineComponent
40
44
  export const TimelineItem = TimelineItemComponent
41
45
  export const Toast = ToastComponent
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  import type { AccordionProps } from './accordion'
3
3
  import ArrowDown from '../../icons/arrow-down.svg?raw'
4
- import './accordion.scss'
4
+ import styles from './accordion.module.scss'
5
5
 
6
6
  interface Props extends AccordionProps {}
7
7
 
@@ -10,15 +10,15 @@ const {
10
10
  } = Astro.props
11
11
  ---
12
12
 
13
- <ul class="w-accordion" data-id="w-accordion">
13
+ <ul class={styles.accordion} data-id="w-accordion">
14
14
  {items.map((item: AccordionProps['items'][0]) => (
15
15
  <li>
16
- <div class="accordion-title">
16
+ <button class={styles.title} data-toggle="true">
17
17
  {item.title}
18
18
  <Fragment set:html={ArrowDown} />
19
- </div>
20
- <div class="accordion-wrapper">
21
- <div class="accordion-content">
19
+ </button>
20
+ <div class={styles.wrapper}>
21
+ <div class={styles.content}>
22
22
  <Fragment set:html={item.content} />
23
23
  </div>
24
24
  </div>
@@ -33,8 +33,10 @@ const {
33
33
  element.addEventListener('click', event => {
34
34
  const target = event.target as HTMLDivElement
35
35
 
36
- if (target.classList.contains('accordion-title')) {
37
- target.classList.toggle('open')
36
+ if (target.dataset.toggle) {
37
+ target.dataset.open = target.dataset.open === 'true'
38
+ ? 'false'
39
+ : 'true'
38
40
  }
39
41
  })
40
42
  })
@@ -1,7 +1,7 @@
1
1
  <script lang="ts">
2
2
  import type { AccordionProps } from './accordion'
3
3
  import ArrowDown from '../../icons/arrow-down.svg?raw'
4
- import './accordion.scss'
4
+ import styles from './accordion.module.scss'
5
5
 
6
6
  export let items: AccordionProps['items']
7
7
 
@@ -15,19 +15,19 @@
15
15
  }
16
16
  </script>
17
17
 
18
- <ul class="w-accordion">
18
+ <ul class={styles.accordion}>
19
19
  {#each items as item, index}
20
20
  <li>
21
- <div
22
- class="accordion-title"
23
- class:open={state[index]}
21
+ <button
22
+ class={styles.title}
23
+ data-open={state[index]}
24
24
  on:click={() => toggle(index)}
25
25
  >
26
26
  {item.title}
27
27
  {@html ArrowDown}
28
- </div>
29
- <div class="accordion-wrapper">
30
- <div class="accordion-content">
28
+ </button>
29
+ <div class={styles.wrapper}>
30
+ <div class={styles.content}>
31
31
  {@html item.content}
32
32
  </div>
33
33
  </div>
@@ -1,7 +1,7 @@
1
1
  import React, { useState } from 'react'
2
2
  import type { AccordionProps } from './accordion'
3
3
  import ArrowDown from '../../icons/arrow-down.svg?raw'
4
- import './accordion.scss'
4
+ import styles from './accordion.module.scss'
5
5
 
6
6
  const Accordion = ({ items }: AccordionProps) => {
7
7
  const [state, setState] = useState(Array(items.length).fill(false))
@@ -14,16 +14,17 @@ const Accordion = ({ items }: AccordionProps) => {
14
14
  }
15
15
 
16
16
  return (
17
- <ul className="w-accordion">
17
+ <ul className={styles.accordion}>
18
18
  {items.map((item, index) => (
19
19
  <li key={index}>
20
- <div
21
- className={state[index] ? 'accordion-title open' : 'accordion-title'}
20
+ <button
21
+ className={styles.title}
22
+ data-open={state[index]}
22
23
  onClick={() => toggle(index)}
23
24
  dangerouslySetInnerHTML={{ __html: `${item.title} ${ArrowDown}` }}
24
25
  />
25
- <div className="accordion-wrapper">
26
- <div className="accordion-content">
26
+ <div className={styles.wrapper}>
27
+ <div className={styles.content}>
27
28
  <div dangerouslySetInnerHTML={{ __html: item.content }} />
28
29
  </div>
29
30
  </div>
@@ -1,12 +1,12 @@
1
1
  @import '../../scss/config.scss';
2
2
 
3
- .w-accordion {
3
+ .accordion {
4
4
  margin: 0;
5
5
  padding: 0;
6
6
  list-style-type: none;
7
7
 
8
8
  li {
9
- border-bottom: 1px solid #252525;
9
+ border-bottom: 1px solid var(--w-color-primary-50);
10
10
  padding: 10px 0;
11
11
  font-size: 16px;
12
12
 
@@ -19,45 +19,53 @@
19
19
  padding-bottom: 0;
20
20
  }
21
21
 
22
- .accordion-title {
22
+ .title {
23
23
  display: flex;
24
24
  justify-content: space-between;
25
25
  align-items: center;
26
+ gap: 10px;
27
+ width: 100%;
28
+ background: transparent;
29
+ border: 0;
30
+ color: var(--w-color-primary);
31
+ font-size: 16px;
32
+ padding: 0;
26
33
  cursor: pointer;
34
+ text-align: left;
27
35
 
28
36
  svg {
29
37
  @include Transition(transform);
30
- color: #BBB;
38
+ color: var(--w-color-primary-20);
31
39
  width: 15px;
32
40
  height: 15px;
33
41
  pointer-events: none;
34
42
  }
35
43
 
36
- &.open {
44
+ &[data-open="true"] {
37
45
  svg {
38
46
  transform: rotate(180deg);
39
47
  }
40
48
 
41
- + .accordion-wrapper {
49
+ + .wrapper {
42
50
  grid-template-rows: 1fr;
43
51
 
44
- .accordion-content {
52
+ .content {
45
53
  padding: 10px 0;
46
54
  }
47
55
  }
48
56
  }
49
57
  }
50
58
 
51
- .accordion-wrapper {
59
+ .wrapper {
52
60
  @include Transition(grid-template-rows);
53
61
  display: grid;
54
62
  grid-template-rows: 0fr;
55
63
  }
56
64
 
57
- .accordion-content {
65
+ .content {
58
66
  @include Transition();
59
67
  overflow: hidden;
60
- color: #BBB;
68
+ color: var(--w-color-primary-20);
61
69
  }
62
70
  }
63
71
  }
@@ -7,7 +7,7 @@ import success from '../../icons/circle-check.svg?raw'
7
7
  import warning from '../../icons/warning.svg?raw'
8
8
  import alert from '../../icons/alert.svg?raw'
9
9
 
10
- import './alert.scss'
10
+ import styles from './alert.module.scss'
11
11
 
12
12
  interface Props extends AlertProps {}
13
13
 
@@ -22,6 +22,8 @@ const {
22
22
  element = 'section',
23
23
  title,
24
24
  titleTag = 'strong',
25
+ titleProps,
26
+ bodyProps,
25
27
  className,
26
28
  theme,
27
29
  ...rest
@@ -32,9 +34,9 @@ const Title = titleTag
32
34
  const hasCustomIcon = Astro.slots.has('icon')
33
35
 
34
36
  const classes = [
35
- 'w-alert',
36
- (!hasCustomIcon && !theme) && 'col',
37
- theme,
37
+ styles['w-alert'],
38
+ (!hasCustomIcon && !theme) && styles.col,
39
+ theme && styles[theme],
38
40
  className
39
41
  ].filter(Boolean).join(' ')
40
42
 
@@ -49,13 +51,15 @@ const props = {
49
51
  {!hasCustomIcon && theme && <Fragment set:html={iconMap[theme]} />}
50
52
 
51
53
  <ConditionalWrapper condition={!!(hasCustomIcon || theme)}>
52
- <div class="alert-wrapper" slot="wrapper">
54
+ <div class={styles.wrapper} slot="wrapper">
53
55
  children
54
56
  </div>
55
57
  {title && (
56
- <Title class:list="alert-title">{title}</Title>
58
+ <Title class:list={styles.title} {...titleProps}>
59
+ {title}
60
+ </Title>
57
61
  )}
58
- <div class="alert-body">
62
+ <div class={styles.body} {...bodyProps}>
59
63
  <slot />
60
64
  </div>
61
65
  </ConditionalWrapper>
@@ -7,11 +7,13 @@
7
7
  import warning from '../../icons/warning.svg?raw'
8
8
  import alert from '../../icons/alert.svg?raw'
9
9
 
10
- import './alert.scss'
10
+ import styles from './alert.module.scss'
11
11
 
12
12
  export let element: AlertProps['element'] = 'section'
13
13
  export let title: AlertProps['title'] = null
14
14
  export let titleTag: AlertProps['title'] = 'strong'
15
+ export let titleProps: AlertProps['titleProps'] = null
16
+ export let bodyProps: AlertProps['bodyProps'] = null
15
17
  export let className: AlertProps['className'] = null
16
18
  export let theme: AlertProps['theme'] = null
17
19
 
@@ -25,9 +27,9 @@
25
27
  const hasCustomIcon = $$slots.icon
26
28
 
27
29
  const classes = [
28
- 'w-alert',
29
- (!hasCustomIcon && !theme) && 'col',
30
- theme,
30
+ styles['w-alert'],
31
+ (!hasCustomIcon && !theme) && styles.col,
32
+ theme && styles[theme],
31
33
  className
32
34
  ].filter(Boolean).join(' ')
33
35
  </script>
@@ -42,14 +44,14 @@
42
44
  <ConditionalWrapper
43
45
  condition={!!(hasCustomIcon || theme)}
44
46
  element="div"
45
- class="alert-wrapper"
47
+ class={styles.wrapper}
46
48
  >
47
49
  {#if title}
48
- <svelte:element this={titleTag} class="alert-title">
50
+ <svelte:element this={titleTag} class={styles.title} {...titleProps}>
49
51
  {title}
50
52
  </svelte:element>
51
53
  {/if}
52
- <div class="alert-body">
54
+ <div class={styles.body} {...bodyProps}>
53
55
  <slot />
54
56
  </div>
55
57
  </ConditionalWrapper>
@@ -7,7 +7,7 @@ import success from '../../icons/circle-check.svg?raw'
7
7
  import warning from '../../icons/warning.svg?raw'
8
8
  import alert from '../../icons/alert.svg?raw'
9
9
 
10
- import './alert.scss'
10
+ import styles from './alert.module.scss'
11
11
 
12
12
  const iconMap = {
13
13
  info,
@@ -20,6 +20,8 @@ const Alert = ({
20
20
  Element = 'section',
21
21
  title,
22
22
  TitleTag = 'strong',
23
+ titleProps,
24
+ bodyProps,
23
25
  className,
24
26
  theme,
25
27
  children,
@@ -27,9 +29,9 @@ const Alert = ({
27
29
  ...rest
28
30
  }: ReactAlertProps) => {
29
31
  const classes = [
30
- 'w-alert',
31
- (!icon && !theme) && 'col',
32
- theme,
32
+ styles['w-alert'],
33
+ (!icon && !theme) && styles.col,
34
+ theme && styles[theme],
33
35
  className
34
36
  ].filter(Boolean).join(' ')
35
37
 
@@ -39,14 +41,16 @@ const Alert = ({
39
41
  {!icon && theme && <div dangerouslySetInnerHTML={{ __html: iconMap[theme] }} />}
40
42
 
41
43
  <ConditionalWrapper condition={!!(icon || theme)} wrapper={children => (
42
- <div className="alert-wrapper">
44
+ <div className={styles.wrapper}>
43
45
  {children}
44
46
  </div>
45
47
  )}>
46
48
  {title && (
47
- <TitleTag className="alert-title">{title}</TitleTag>
49
+ <TitleTag className={styles.title} {...titleProps}>
50
+ {title}
51
+ </TitleTag>
48
52
  )}
49
- <div className="alert-body">
53
+ <div className={styles.body} {...bodyProps}>
50
54
  {children}
51
55
  </div>
52
56
  </ConditionalWrapper>
@@ -0,0 +1,54 @@
1
+ @import '../../scss/config.scss';
2
+
3
+ .w-alert {
4
+ border: 1px solid var(--w-color-primary-50);
5
+ border-radius: 5px;
6
+ padding: 15px;
7
+ display: flex;
8
+
9
+ &.col {
10
+ flex-direction: column;
11
+ }
12
+
13
+ &:not(.col) {
14
+ gap: 10px;
15
+ }
16
+
17
+ &.info {
18
+ border: 1px solid var(--w-color-info);
19
+ color: var(--w-color-info);
20
+ }
21
+
22
+ &.success {
23
+ border: 1px solid var(--w-color-success);
24
+ color: var(--w-color-success);
25
+ }
26
+
27
+ &.warning {
28
+ border: 1px solid var(--w-color-warning);
29
+ color: var(--w-color-warning);
30
+ }
31
+
32
+ &.alert {
33
+ border: 1px solid var(--w-color-alert);
34
+ color: var(--w-color-alert);
35
+ }
36
+
37
+ svg {
38
+ width: 20px;
39
+ height: 20px;
40
+ min-width: 20px;
41
+ margin-top: 1px;
42
+ }
43
+
44
+ .title {
45
+ display: block;
46
+ margin-bottom: 5px;
47
+ }
48
+
49
+ .body {
50
+ font-size: 16px;
51
+ color: var(--w-color-primary-20);
52
+ line-height: 1.5;
53
+ }
54
+ }
@@ -2,7 +2,8 @@ export type AlertProps = {
2
2
  element?: string
3
3
  title?: string | null
4
4
  titleTag?: string
5
- icon?: string | null
5
+ titleProps?: any
6
+ bodyProps?: any
6
7
  className?: string | null
7
8
  theme?: 'info'
8
9
  | 'success'
@@ -14,5 +15,6 @@ export type AlertProps = {
14
15
  export type ReactAlertProps = {
15
16
  Element?: keyof JSX.IntrinsicElements
16
17
  TitleTag?: keyof JSX.IntrinsicElements
18
+ icon?: React.ReactNode
17
19
  children: React.ReactNode
18
20
  } & Omit<AlertProps, 'titleTag' | 'element'>
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  import type { AvatarProps } from './avatar'
3
- import './avatar.scss'
3
+ import styles from './avatar.module.scss'
4
4
 
5
5
  interface Props extends AvatarProps {}
6
6
 
@@ -16,14 +16,14 @@ const {
16
16
  } = Astro.props
17
17
 
18
18
  const classes = [
19
- 'w-avatar',
20
- borderless && 'borderless',
19
+ styles.avatar,
20
+ borderless && styles.borderless,
21
21
  className
22
22
  ]
23
23
  ---
24
24
 
25
25
  {Array.isArray(img) ? (
26
- <div class:list={['w-avatar-group', reverse && 'reverse']}
26
+ <div class:list={[styles.group, reverse && styles.reverse]}
27
27
  style={borderColor ? `--w-avatar-border: ${borderColor};` : null}
28
28
  >
29
29
  {img.map((img, index) => (
@@ -1,6 +1,8 @@
1
1
  <script lang="ts">
2
2
  import type { AvatarProps } from './avatar'
3
- import './avatar.scss'
3
+
4
+ import styles from './avatar.module.scss'
5
+ import { classNames } from '../../utils/classNames'
4
6
 
5
7
  export let img: AvatarProps['img'] = ''
6
8
  export let alt: AvatarProps['alt'] = 'Avatar'
@@ -11,16 +13,20 @@
11
13
  export let reverse: AvatarProps['reverse'] = false
12
14
  export let className: AvatarProps['className'] = ''
13
15
 
14
- const classes = [
15
- 'w-avatar',
16
- borderless && 'borderless',
16
+ const classes = classNames([
17
+ styles.avatar,
18
+ borderless && styles.borderless,
17
19
  className
18
- ].filter(Boolean).join(' ')
20
+ ])
21
+
22
+ const groupStyles = classNames([
23
+ styles.group,
24
+ reverse && styles.reverse
25
+ ])
19
26
  </script>
20
27
 
21
28
  {#if Array.isArray(img)}
22
- <div class="w-avatar-group"
23
- class:reverse
29
+ <div class={groupStyles}
24
30
  style={borderColor ? `--w-avatar-border: ${borderColor};` : null}
25
31
  >
26
32
  {#each img as img, index}
@@ -1,6 +1,8 @@
1
1
  import React from 'react'
2
2
  import type { AvatarProps } from './avatar'
3
- import './avatar.scss'
3
+
4
+ import styles from './avatar.module.scss'
5
+ import { classNames } from '../../utils/classNames'
4
6
 
5
7
  const Avatar = ({
6
8
  img,
@@ -12,16 +14,16 @@ const Avatar = ({
12
14
  reverse,
13
15
  className,
14
16
  }: AvatarProps) => {
15
- const classes = [
16
- 'w-avatar',
17
- borderless && 'borderless',
17
+ const classes = classNames([
18
+ styles.avatar,
19
+ borderless && styles.borderless,
18
20
  className
19
- ].filter(Boolean).join(' ')
21
+ ])
20
22
 
21
- const groupStyles = [
22
- 'w-avatar-group',
23
- reverse && 'reverse'
24
- ].filter(Boolean).join(' ')
23
+ const groupStyles = classNames([
24
+ styles.group,
25
+ reverse && styles.reverse
26
+ ])
25
27
 
26
28
  const borderColorStyle = borderColor
27
29
  ? { '--w-avatar-border': borderColor } as React.CSSProperties
@@ -1,6 +1,6 @@
1
1
  @import '../../scss/config.scss';
2
2
 
3
- .w-avatar {
3
+ .avatar {
4
4
  border-radius: 100%;
5
5
 
6
6
  &:not(.borderless) {
@@ -8,7 +8,7 @@
8
8
  }
9
9
  }
10
10
 
11
- .w-avatar-group {
11
+ .group {
12
12
  display: inline-flex;
13
13
  align-items: center;
14
14