webcoreui 0.0.8 → 0.0.9

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 (52) hide show
  1. package/README.md +18 -1
  2. package/astro.d.ts +10 -0
  3. package/astro.js +11 -1
  4. package/components/Alert/Alert.astro +3 -5
  5. package/components/Alert/Alert.svelte +3 -5
  6. package/components/Alert/Alert.tsx +9 -2
  7. package/components/Alert/alert.ts +0 -1
  8. package/components/Avatar/Avatar.astro +51 -0
  9. package/components/Avatar/Avatar.svelte +48 -0
  10. package/components/Avatar/Avatar.tsx +63 -0
  11. package/components/Avatar/avatar.scss +35 -0
  12. package/components/Avatar/avatar.ts +10 -0
  13. package/components/Badge/Badge.astro +1 -5
  14. package/components/Badge/Badge.svelte +1 -4
  15. package/components/Badge/Badge.tsx +5 -1
  16. package/components/Badge/badge.ts +0 -1
  17. package/components/Button/Button.astro +1 -4
  18. package/components/Button/Button.svelte +1 -4
  19. package/components/Button/Button.tsx +5 -1
  20. package/components/Button/button.ts +1 -1
  21. package/components/Card/Card.astro +2 -5
  22. package/components/Card/Card.svelte +1 -4
  23. package/components/Card/Card.tsx +7 -1
  24. package/components/Card/card.ts +1 -0
  25. package/components/Checkbox/Checkbox.astro +51 -0
  26. package/components/Checkbox/Checkbox.svelte +52 -0
  27. package/components/Checkbox/Checkbox.tsx +69 -0
  28. package/components/Checkbox/checkbox.scss +85 -0
  29. package/components/Checkbox/checkbox.ts +8 -0
  30. package/components/Radio/Radio.astro +57 -0
  31. package/components/Radio/Radio.svelte +56 -0
  32. package/components/Radio/Radio.tsx +72 -0
  33. package/components/Radio/radio.scss +92 -0
  34. package/components/Radio/radio.ts +13 -0
  35. package/components/Rating/Rating.astro +66 -0
  36. package/components/Rating/Rating.svelte +70 -0
  37. package/components/Rating/Rating.tsx +67 -0
  38. package/components/Rating/rating.scss +37 -0
  39. package/components/Rating/rating.ts +16 -0
  40. package/components/Switch/Switch.astro +38 -0
  41. package/components/Switch/Switch.svelte +42 -0
  42. package/components/Switch/Switch.tsx +50 -0
  43. package/components/Switch/switch.scss +84 -0
  44. package/components/Switch/switch.ts +11 -0
  45. package/icons/check.svg +1 -2
  46. package/icons/circle-check.svg +4 -0
  47. package/package.json +3 -2
  48. package/react.d.ts +10 -0
  49. package/react.js +11 -1
  50. package/scss/setup.scss +11 -0
  51. package/svelte.d.ts +10 -0
  52. package/svelte.js +11 -1
package/README.md CHANGED
@@ -108,6 +108,18 @@ The `Setup` mixin can also accept the following options:
108
108
  |-----------|---------------|---------|
109
109
  | `includeResets` | `true` | Include reset styles. Set to `false` if you want to use your own CSS resets. |
110
110
  | `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). |
111
+ | `includeElementStyles` | `true` | Adds styles for native HTML elements, such as `code`, `pre`, or `ul`.
112
+
113
+ Default component styles can also be changed by overriding the following CSS variables:
114
+
115
+ ```css
116
+ :root {
117
+ --w-avatar-border: #000;
118
+ --w-rating-color: #FFF;
119
+ --w-rating-empty-color: #BBB;
120
+ --w-rating-size: 18px;
121
+ }
122
+ ```
111
123
 
112
124
  ### Using Components
113
125
 
@@ -133,8 +145,13 @@ import { Accordion } from 'webcoreui/react'
133
145
 
134
146
  - [Accordion](https://github.com/Frontendland/webcoreui/tree/main/src/components/Accordion)
135
147
  - [Alert](https://github.com/Frontendland/webcoreui/tree/main/src/components/Alert)
136
- - [ConditionalWrapper](https://github.com/Frontendland/webcoreui/tree/main/src/components/ConditionalWrapper)
148
+ - [Avatar](https://github.com/Frontendland/webcoreui/tree/main/src/components/Avatar)
137
149
  - [Badge](https://github.com/Frontendland/webcoreui/tree/main/src/components/Badge)
138
150
  - [Button](https://github.com/Frontendland/webcoreui/tree/main/src/components/Button)
139
151
  - [Card](https://github.com/Frontendland/webcoreui/tree/main/src/components/Card)
152
+ - [Checkbox](https://github.com/Frontendland/webcoreui/tree/main/src/components/Checkbox)
153
+ - [ConditionalWrapper](https://github.com/Frontendland/webcoreui/tree/main/src/components/ConditionalWrapper)
140
154
  - [Icon](https://github.com/Frontendland/webcoreui/tree/main/src/components/Icon)
155
+ - [Radio](https://github.com/Frontendland/webcoreui/tree/main/src/components/Radio)
156
+ - [Rating](https://github.com/Frontendland/webcoreui/tree/main/src/components/Rating)
157
+ - [Switch](https://github.com/Frontendland/webcoreui/tree/main/src/components/Switch)
package/astro.d.ts CHANGED
@@ -2,18 +2,28 @@
2
2
  declare module 'webcoreui/astro' {
3
3
  import type { AccordionProps } from './components/Accordion/accordion'
4
4
  import type { AlertProps } from './components/Alert/alert'
5
+ import type { AvatarProps } from './components/Avatar/avatar'
5
6
  import type { BadgeProps } from './components/Badge/badge'
6
7
  import type { ButtonProps } from './components/Button/button'
7
8
  import type { CardProps } from './components/Card/card'
9
+ import type { CheckboxProps } from './components/Checkbox/checkbox'
8
10
  import type { ConditionalWrapperProps } from './components/ConditionalWrapper/conditionalwrapper'
9
11
  import type { IconProps } from './components/Icon/icon'
12
+ import type { RadioProps } from './components/Radio/radio'
13
+ import type { RatingProps } from './components/Rating/rating'
14
+ import type { SwitchProps } from './components/Switch/switch'
10
15
 
11
16
  export function Accordion(_props: AccordionProps): any
12
17
  export function Alert(_props: AlertProps): any
18
+ export function Avatar(_props: AvatarProps): any
13
19
  export function Badge(_props: BadgeProps): any
14
20
  export function Button(_props: ButtonProps): any
15
21
  export function Card(_props: CardProps): any
22
+ export function Checkbox(_props: CheckboxProps): any
16
23
  export function ConditionalWrapper(_props: ConditionalWrapperProps): any
17
24
  export function Icon(_props: IconProps): any
25
+ export function Radio(_props: RadioProps): any
26
+ export function Rating(_props: RatingProps): any
27
+ export function Switch(_props: SwitchProps): any
18
28
  }
19
29
 
package/astro.js CHANGED
@@ -1,15 +1,25 @@
1
1
  import AccordionComponent from './components/Accordion/Accordion.astro'
2
2
  import AlertComponent from './components/Alert/Alert.astro'
3
+ import AvatarComponent from './components/Avatar/Avatar.astro'
3
4
  import BadgeComponent from './components/Badge/Badge.astro'
4
5
  import ButtonComponent from './components/Button/Button.astro'
5
6
  import CardComponent from './components/Card/Card.astro'
7
+ import CheckboxComponent from './components/Checkbox/Checkbox.astro'
6
8
  import ConditionalWrapperComponent from './components/ConditionalWrapper/ConditionalWrapper.astro'
7
9
  import IconComponent from './components/Icon/Icon.astro'
10
+ import RadioComponent from './components/Radio/Radio.astro'
11
+ import RatingComponent from './components/Rating/Rating.astro'
12
+ import SwitchComponent from './components/Switch/Switch.astro'
8
13
 
9
14
  export const Accordion = AccordionComponent
10
15
  export const Alert = AlertComponent
16
+ export const Avatar = AvatarComponent
11
17
  export const Badge = BadgeComponent
12
18
  export const Button = ButtonComponent
13
19
  export const Card = CardComponent
20
+ export const Checkbox = CheckboxComponent
14
21
  export const ConditionalWrapper = ConditionalWrapperComponent
15
- export const Icon = IconComponent
22
+ export const Icon = IconComponent
23
+ export const Radio = RadioComponent
24
+ export const Rating = RatingComponent
25
+ export const Switch = SwitchComponent
@@ -3,10 +3,12 @@ import type { AlertProps } from './alert'
3
3
  import ConditionalWrapper from '../ConditionalWrapper/ConditionalWrapper.astro'
4
4
 
5
5
  import info from '../../icons/info.svg?raw'
6
- import success from '../../icons/check.svg?raw'
6
+ 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'
11
+
10
12
  interface Props extends AlertProps {}
11
13
 
12
14
  const iconMap = {
@@ -58,7 +60,3 @@ const props = {
58
60
  </div>
59
61
  </ConditionalWrapper>
60
62
  </Component>
61
-
62
- <style lang="scss">
63
- @import './alert.scss';
64
- </style>
@@ -3,10 +3,12 @@
3
3
  import ConditionalWrapper from '../ConditionalWrapper/ConditionalWrapper.svelte'
4
4
 
5
5
  import info from '../../icons/info.svg?raw'
6
- import success from '../../icons/check.svg?raw'
6
+ 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'
11
+
10
12
  export let element: AlertProps['element'] = 'section'
11
13
  export let title: AlertProps['title'] = null
12
14
  export let titleTag: AlertProps['title'] = 'strong'
@@ -52,7 +54,3 @@
52
54
  </div>
53
55
  </ConditionalWrapper>
54
56
  </svelte:element>
55
-
56
- <style lang="scss">
57
- @import './alert.scss';
58
- </style>
@@ -3,7 +3,7 @@ import type { AlertProps } from './alert'
3
3
  import ConditionalWrapper from '../ConditionalWrapper/ConditionalWrapper.tsx'
4
4
 
5
5
  import info from '../../icons/info.svg?raw'
6
- import success from '../../icons/check.svg?raw'
6
+ 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
 
@@ -16,6 +16,13 @@ const iconMap = {
16
16
  alert
17
17
  }
18
18
 
19
+ type ReactAlertProps = {
20
+ Element?: keyof JSX.IntrinsicElements
21
+ TitleTag?: keyof JSX.IntrinsicElements
22
+ children: React.ReactNode
23
+ icon?: string
24
+ } & AlertProps
25
+
19
26
  const Alert = ({
20
27
  Element = 'section',
21
28
  title,
@@ -25,7 +32,7 @@ const Alert = ({
25
32
  children,
26
33
  icon,
27
34
  ...rest
28
- }: AlertProps & { icon?: any }) => {
35
+ }: ReactAlertProps) => {
29
36
  const classes = [
30
37
  'w-alert',
31
38
  (!icon && !theme) && 'col',
@@ -9,5 +9,4 @@ export type AlertProps = {
9
9
  | 'warning'
10
10
  | 'alert'
11
11
  | null
12
- [key: string]: any
13
12
  }
@@ -0,0 +1,51 @@
1
+ ---
2
+ import type { AvatarProps } from './avatar'
3
+ import './avatar.scss'
4
+
5
+ interface Props extends AvatarProps {}
6
+
7
+ const {
8
+ img,
9
+ alt = 'Avatar',
10
+ size = 40,
11
+ lazy = true,
12
+ borderColor,
13
+ borderless,
14
+ reverse,
15
+ className,
16
+ } = Astro.props
17
+
18
+ const classes = [
19
+ 'w-avatar',
20
+ borderless && 'borderless',
21
+ className
22
+ ]
23
+ ---
24
+
25
+ {Array.isArray(img) ? (
26
+ <div class:list={['w-avatar-group', reverse && 'reverse']}
27
+ style={borderColor ? `--w-avatar-border: ${borderColor};` : null}
28
+ >
29
+ {img.map((img, index) => (
30
+ <img
31
+ src={img}
32
+ alt={Array.isArray(alt) ? alt[index] : alt}
33
+ width={Array.isArray(size) ? size[index] : size}
34
+ height={Array.isArray(size) ? size[index] : size}
35
+ loading={lazy ? 'lazy' : null}
36
+ class:list={classes}
37
+ style={Array.isArray(size) ? `--w-avatar-index: ${size[index]}` : null}
38
+ />
39
+ ))}
40
+ </div>
41
+ ) : (
42
+ <img
43
+ src={img}
44
+ alt={Array.isArray(alt) ? alt[0] : alt}
45
+ width={Array.isArray(size) ? size[0] : size}
46
+ height={Array.isArray(size) ? size[0] : size}
47
+ class:list={classes}
48
+ loading={lazy ? 'lazy' : null}
49
+ style={borderColor ? `--w-avatar-border: ${borderColor};` : null}
50
+ />
51
+ )}
@@ -0,0 +1,48 @@
1
+ <script lang="ts">
2
+ import type { AvatarProps } from './avatar'
3
+ import './avatar.scss'
4
+
5
+ export let img: AvatarProps['img'] = ''
6
+ export let alt: AvatarProps['alt'] = 'Avatar'
7
+ export let size: AvatarProps['size'] = 40
8
+ export let lazy: AvatarProps['lazy'] = true
9
+ export let borderColor: AvatarProps['borderColor'] = ''
10
+ export let borderless: AvatarProps['borderless'] = false
11
+ export let reverse: AvatarProps['reverse'] = false
12
+ export let className: AvatarProps['className'] = ''
13
+
14
+ const classes = [
15
+ 'w-avatar',
16
+ borderless && 'borderless',
17
+ className
18
+ ].filter(Boolean).join(' ')
19
+ </script>
20
+
21
+ {#if Array.isArray(img)}
22
+ <div class="w-avatar-group"
23
+ class:reverse
24
+ style={borderColor ? `--w-avatar-border: ${borderColor};` : null}
25
+ >
26
+ {#each img as img, index}
27
+ <img
28
+ src={img}
29
+ alt={Array.isArray(alt) ? alt[index] : alt}
30
+ width={Array.isArray(size) ? size[index] : size}
31
+ height={Array.isArray(size) ? size[index] : size}
32
+ loading={lazy ? 'lazy' : null}
33
+ class={classes}
34
+ style={Array.isArray(size) ? `--w-avatar-index: ${size[index]}` : null}
35
+ />
36
+ {/each}
37
+ </div>
38
+ {:else}
39
+ <img
40
+ src={img}
41
+ alt={Array.isArray(alt) ? alt[0] : alt}
42
+ width={Array.isArray(size) ? size[0] : size}
43
+ height={Array.isArray(size) ? size[0] : size}
44
+ class={classes}
45
+ loading={lazy ? 'lazy' : null}
46
+ style={borderColor ? `--w-avatar-border: ${borderColor};` : null}
47
+ />
48
+ {/if}
@@ -0,0 +1,63 @@
1
+ import React from 'react'
2
+ import type { AvatarProps } from './avatar'
3
+ import './avatar.scss'
4
+
5
+ const Avatar = ({
6
+ img,
7
+ alt = 'Avatar',
8
+ size = 40,
9
+ lazy = true,
10
+ borderColor,
11
+ borderless,
12
+ reverse,
13
+ className,
14
+ }: AvatarProps) => {
15
+ const classes = [
16
+ 'w-avatar',
17
+ borderless && 'borderless',
18
+ className
19
+ ].filter(Boolean).join(' ')
20
+
21
+ const groupStyles = [
22
+ 'w-avatar-group',
23
+ reverse && 'reverse'
24
+ ].filter(Boolean).join(' ')
25
+
26
+ const borderColorStyle = borderColor
27
+ ? { '--w-avatar-border': borderColor } as React.CSSProperties
28
+ : undefined
29
+
30
+ return Array.isArray(img) ? (
31
+ <div className={groupStyles}
32
+ style={borderColorStyle}
33
+ >
34
+ {img.map((img, index) => (
35
+ <img
36
+ src={img}
37
+ alt={Array.isArray(alt) ? alt[index] : alt}
38
+ width={Array.isArray(size) ? size[index] : size}
39
+ height={Array.isArray(size) ? size[index] : size}
40
+ loading={lazy ? 'lazy' : undefined}
41
+ className={classes}
42
+ style={Array.isArray(size)
43
+ ? { '--w-avatar-index': size[index] } as React.CSSProperties
44
+ : undefined
45
+ }
46
+ />
47
+ ))}
48
+ </div>
49
+ ) : (
50
+ <img
51
+ src={img}
52
+ alt={Array.isArray(alt) ? alt[0] : alt}
53
+ width={Array.isArray(size) ? size[0] : size}
54
+ height={Array.isArray(size) ? size[0] : size}
55
+ className={classes}
56
+ loading={lazy ? 'lazy' : undefined}
57
+ style={borderColorStyle}
58
+ />
59
+ )
60
+
61
+ }
62
+
63
+ export default Avatar
@@ -0,0 +1,35 @@
1
+ @import '../../scss/config.scss';
2
+
3
+ .w-avatar {
4
+ border-radius: 100%;
5
+
6
+ &:not(.borderless) {
7
+ border: 3px solid var(--w-avatar-border);
8
+ }
9
+ }
10
+
11
+ .w-avatar-group {
12
+ display: inline-flex;
13
+ align-items: center;
14
+
15
+ &.reverse {
16
+ flex-direction: row-reverse;
17
+
18
+ img {
19
+ z-index: 1;
20
+ }
21
+
22
+ img:not(:first-child) {
23
+ margin-right: -10px;
24
+ margin-left: 0;
25
+ }
26
+ }
27
+
28
+ img:not(:first-child) {
29
+ margin-left: -10px;
30
+ }
31
+
32
+ img {
33
+ z-index: var(--w-avatar-index);
34
+ }
35
+ }
@@ -0,0 +1,10 @@
1
+ export type AvatarProps = {
2
+ img: string | string[]
3
+ alt?: string | string[]
4
+ size?: number | number[]
5
+ lazy?: boolean
6
+ borderColor?: string
7
+ borderless?: boolean
8
+ reverse?: boolean
9
+ className?: string
10
+ }
@@ -1,5 +1,6 @@
1
1
  ---
2
2
  import type { BadgeProps } from './badge'
3
+ import './badge.scss'
3
4
 
4
5
  interface Props extends BadgeProps {
5
6
  interactive?: boolean
@@ -20,8 +21,3 @@ const classes = [
20
21
  <span class:list={classes}>
21
22
  <slot />
22
23
  </span>
23
-
24
-
25
- <style lang="scss">
26
- @import './badge.scss';
27
- </style>
@@ -1,5 +1,6 @@
1
1
  <script lang="ts">
2
2
  import type { BadgeProps } from './badge'
3
+ import './badge.scss'
3
4
 
4
5
  export let theme: BadgeProps['theme'] = null
5
6
  export let onClick: BadgeProps['onClick'] = () => {}
@@ -14,7 +15,3 @@
14
15
  <span class={classes} on:click={onClick}>
15
16
  <slot />
16
17
  </span>
17
-
18
- <style lang="scss">
19
- @import './badge.scss';
20
- </style>
@@ -2,7 +2,11 @@ import React from 'react'
2
2
  import type { BadgeProps } from './badge'
3
3
  import './badge.scss'
4
4
 
5
- const Badge = ({ theme, onClick, children }: BadgeProps) => {
5
+ type ReactBadgeProps = {
6
+ children: React.ReactNode
7
+ } & BadgeProps
8
+
9
+ const Badge = ({ theme, onClick, children }: ReactBadgeProps) => {
6
10
  const classes = [
7
11
  'w-badge',
8
12
  theme || null,
@@ -8,5 +8,4 @@ export type BadgeProps = {
8
8
  | 'alert'
9
9
  | null
10
10
  onClick?: () => any
11
- [key: string]: any
12
11
  }
@@ -1,5 +1,6 @@
1
1
  ---
2
2
  import type { ButtonProps } from './button'
3
+ import './button.scss'
3
4
 
4
5
  interface Props extends ButtonProps {}
5
6
 
@@ -26,7 +27,3 @@ const classes = [
26
27
  <slot />
27
28
  </button>
28
29
  )}
29
-
30
- <style lang="scss">
31
- @import './button.scss';
32
- </style>
@@ -1,5 +1,6 @@
1
1
  <script lang="ts">
2
2
  import type { ButtonProps } from './button'
3
+ import './button.scss'
3
4
 
4
5
  export let theme: ButtonProps['theme'] = null
5
6
  export let bold: ButtonProps['bold'] = false
@@ -23,7 +24,3 @@
23
24
  <slot />
24
25
  </button>
25
26
  {/if}
26
-
27
- <style lang="scss">
28
- @import './button.scss';
29
- </style>
@@ -2,6 +2,10 @@ import React from 'react'
2
2
  import type { ButtonProps } from './button'
3
3
  import './button.scss'
4
4
 
5
+ type ReactButtonProps = {
6
+ children: React.ReactNode
7
+ } & ButtonProps
8
+
5
9
  const Button = ({
6
10
  theme,
7
11
  bold,
@@ -9,7 +13,7 @@ const Button = ({
9
13
  children,
10
14
  onClick,
11
15
  ...rest
12
- }: ButtonProps) => {
16
+ }: ReactButtonProps) => {
13
17
  const classes = [
14
18
  'w-button',
15
19
  bold && 'bold',
@@ -9,6 +9,6 @@ export type ButtonProps = {
9
9
  | null
10
10
  bold?: boolean
11
11
  href?: string
12
+ target?: string
12
13
  onClick?: () => any
13
- [key: string]: any
14
14
  }
@@ -1,5 +1,6 @@
1
1
  ---
2
2
  import type { CardProps } from './card'
3
+ import './card.scss'
3
4
 
4
5
  interface Props extends CardProps {}
5
6
 
@@ -29,7 +30,7 @@ const Title = titleTag
29
30
 
30
31
  <Component {...props} {...rest}>
31
32
  {title && (
32
- <Title class="card-title">{title}</Title>
33
+ <Title class:list="card-title">{title}</Title>
33
34
  )}
34
35
  <div class="card-body" class:list={[compact && 'compact']}>
35
36
  {compact && !secondary ? (
@@ -39,7 +40,3 @@ const Title = titleTag
39
40
  )}
40
41
  </div>
41
42
  </Component>
42
-
43
- <style lang="scss">
44
- @import './card.scss';
45
- </style>
@@ -1,5 +1,6 @@
1
1
  <script lang="ts">
2
2
  import type { CardProps } from './card'
3
+ import './card.scss'
3
4
 
4
5
  export let element: CardProps['element'] = 'section'
5
6
  export let title: CardProps['title'] = ''
@@ -29,7 +30,3 @@
29
30
  {/if}
30
31
  </div>
31
32
  </svelte:element>
32
-
33
- <style lang="scss">
34
- @import './card.scss';
35
- </style>
@@ -2,6 +2,12 @@ import React from 'react'
2
2
  import type { CardProps } from './card'
3
3
  import './card.scss'
4
4
 
5
+ type ReactCardProps = {
6
+ Element?: keyof JSX.IntrinsicElements
7
+ TitleTag?: keyof JSX.IntrinsicElements
8
+ children: React.ReactNode
9
+ } & CardProps
10
+
5
11
  const Card = ({
6
12
  Element = 'section',
7
13
  title,
@@ -11,7 +17,7 @@ const Card = ({
11
17
  secondary,
12
18
  children,
13
19
  ...rest
14
- }: CardProps) => {
20
+ }: ReactCardProps) => {
15
21
  const classes = [
16
22
  'w-card',
17
23
  className,
@@ -1,6 +1,7 @@
1
1
  export type CardProps = {
2
2
  element?: string
3
3
  title?: string
4
+ titleTag?: string
4
5
  compact?: boolean
5
6
  className?: string
6
7
  secondary?: boolean
@@ -0,0 +1,51 @@
1
+ ---
2
+ import type { CheckboxProps } from './checkbox'
3
+ import ConditionalWrapper from '../ConditionalWrapper/ConditionalWrapper.astro'
4
+
5
+ import check from '../../icons/check.svg?raw'
6
+
7
+ import './checkbox.scss'
8
+
9
+ interface Props extends CheckboxProps {}
10
+
11
+ const {
12
+ checked,
13
+ label,
14
+ subText,
15
+ disabled,
16
+ boxed,
17
+ color
18
+ } = Astro.props
19
+
20
+ const classes = [
21
+ 'w-checkbox',
22
+ boxed && 'boxed',
23
+ label && subText && 'col'
24
+ ]
25
+
26
+ const style = color
27
+ ? `--w-checkbox-color: ${color};`
28
+ : null
29
+ ---
30
+
31
+ <label class:list={classes} style={style}>
32
+ <ConditionalWrapper condition={!!(label && subText)}>
33
+ <div class="checkbox-wrapper" slot="wrapper">
34
+ children
35
+ </div>
36
+ <input type="checkbox" checked={checked} disabled={disabled} />
37
+ <span class="check">
38
+ <Fragment set:html={check} />
39
+ </span>
40
+ {label && (
41
+ <span class="label">
42
+ <Fragment set:html={label} />
43
+ </span>
44
+ )}
45
+ </ConditionalWrapper>
46
+ {label && subText && (
47
+ <span class="sub-text">
48
+ <Fragment set:html={subText} />
49
+ </span>
50
+ )}
51
+ </label>
@@ -0,0 +1,52 @@
1
+ <script lang="ts">
2
+ import type { CheckboxProps } from './checkbox'
3
+ import ConditionalWrapper from '../ConditionalWrapper/ConditionalWrapper.svelte'
4
+
5
+ import check from '../../icons/check.svg?raw'
6
+
7
+ import './checkbox.scss'
8
+
9
+ export let checked: CheckboxProps['checked'] = false
10
+ export let label: CheckboxProps['label'] = ''
11
+ export let subText: CheckboxProps['subText'] = ''
12
+ export let disabled: CheckboxProps['disabled'] = false
13
+ export let boxed: CheckboxProps['boxed'] = false
14
+ export let color: CheckboxProps['color'] = ''
15
+ export let onClick: () => any = () => {}
16
+
17
+ const classes = [
18
+ 'w-checkbox',
19
+ boxed && 'boxed',
20
+ label && subText && 'col'
21
+ ].filter(Boolean).join(' ')
22
+
23
+ const style = color
24
+ ? `--w-checkbox-color: ${color};`
25
+ : null
26
+ </script>
27
+
28
+ <label class={classes} style={style}>
29
+ <ConditionalWrapper
30
+ condition={!!(label && subText)}
31
+ element="div"
32
+ class="checkbox-wrapper"
33
+ >
34
+ <input
35
+ type="checkbox"
36
+ checked={checked}
37
+ disabled={disabled}
38
+ on:click={onClick}
39
+ />
40
+ <span class="check">
41
+ {@html check}
42
+ </span>
43
+ {#if label}
44
+ <span class="label">
45
+ {@html label}
46
+ </span>
47
+ {/if}
48
+ </ConditionalWrapper>
49
+ {#if label && subText}
50
+ <span class="sub-text">{@html subText}</span>
51
+ {/if}
52
+ </label>