webcoreui 0.0.11 → 0.1.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.
- package/README.md +42 -11
- package/astro.d.ts +4 -0
- package/astro.js +4 -0
- package/components/Accordion/Accordion.astro +10 -8
- package/components/Accordion/Accordion.svelte +8 -8
- package/components/Accordion/Accordion.tsx +7 -6
- package/components/Accordion/accordion.module.scss +65 -0
- package/components/Alert/Alert.astro +11 -7
- package/components/Alert/Alert.svelte +9 -7
- package/components/Alert/Alert.tsx +11 -7
- package/components/Alert/alert.module.scss +51 -0
- package/components/Alert/alert.ts +3 -1
- package/components/Avatar/Avatar.astro +4 -4
- package/components/Avatar/Avatar.svelte +13 -7
- package/components/Avatar/Avatar.tsx +11 -9
- package/components/Avatar/{avatar.scss → avatar.module.scss} +11 -8
- package/components/Badge/Badge.astro +8 -8
- package/components/Badge/Badge.svelte +25 -13
- package/components/Badge/Badge.tsx +26 -8
- package/components/Badge/badge.module.scss +86 -0
- package/components/Badge/badge.ts +8 -1
- package/components/Button/Button.astro +9 -7
- package/components/Button/Button.svelte +13 -11
- package/components/Button/Button.tsx +10 -8
- package/components/Button/button.module.scss +87 -0
- package/components/Button/button.ts +6 -2
- package/components/Card/Card.astro +7 -15
- package/components/Card/Card.svelte +16 -13
- package/components/Card/Card.tsx +15 -11
- package/components/Card/card.module.scss +38 -0
- package/components/Checkbox/Checkbox.astro +10 -10
- package/components/Checkbox/Checkbox.svelte +19 -18
- package/components/Checkbox/Checkbox.tsx +12 -11
- package/components/Checkbox/checkbox.module.scss +70 -0
- package/components/Checkbox/checkbox.ts +5 -1
- package/components/ConditionalWrapper/ConditionalWrapper.svelte +1 -1
- package/components/Icon/Icon.astro +2 -2
- package/components/Icon/Icon.svelte +1 -8
- package/components/Icon/Icon.tsx +1 -8
- package/components/Icon/map.ts +23 -0
- package/components/Input/Input.astro +50 -52
- package/components/Input/Input.svelte +52 -52
- package/components/Input/Input.tsx +59 -59
- package/components/Input/input.module.scss +79 -0
- package/components/Input/input.ts +8 -2
- package/components/Menu/Menu.astro +107 -0
- package/components/Menu/Menu.svelte +88 -0
- package/components/Menu/Menu.tsx +107 -0
- package/components/Menu/menu.module.scss +141 -0
- package/components/Menu/menu.ts +21 -0
- package/components/Progress/Progress.astro +42 -40
- package/components/Progress/Progress.svelte +40 -38
- package/components/Progress/Progress.tsx +48 -47
- package/components/Progress/progress.module.scss +70 -0
- package/components/Radio/Radio.astro +57 -57
- package/components/Radio/Radio.svelte +58 -56
- package/components/Radio/Radio.tsx +69 -68
- package/components/Radio/radio.module.scss +84 -0
- package/components/Radio/radio.ts +4 -0
- package/components/Rating/Rating.astro +13 -10
- package/components/Rating/Rating.svelte +15 -15
- package/components/Rating/Rating.tsx +22 -11
- package/components/Rating/rating.module.scss +45 -0
- package/components/Rating/rating.ts +1 -1
- package/components/Spinner/Spinner.astro +44 -42
- package/components/Spinner/Spinner.svelte +40 -38
- package/components/Spinner/Spinner.tsx +45 -44
- package/components/Spinner/{spinner.scss → spinner.module.scss} +50 -41
- package/components/Switch/Switch.astro +13 -11
- package/components/Switch/Switch.svelte +26 -24
- package/components/Switch/Switch.tsx +14 -12
- package/components/Switch/switch.module.scss +82 -0
- package/components/Switch/switch.ts +8 -4
- package/components/Table/Table.astro +60 -60
- package/components/Table/Table.svelte +56 -54
- package/components/Table/Table.tsx +64 -63
- package/components/Table/{table.scss → table.module.scss} +60 -65
- package/components/Tabs/Tabs.astro +76 -76
- package/components/Tabs/Tabs.svelte +56 -54
- package/components/Tabs/Tabs.tsx +70 -69
- package/components/Tabs/tabs.module.scss +125 -0
- package/components/ThemeSwitcher/ThemeSwitcher.astro +106 -0
- package/components/ThemeSwitcher/ThemeSwitcher.svelte +76 -0
- package/components/ThemeSwitcher/ThemeSwitcher.tsx +89 -0
- package/components/ThemeSwitcher/themeswitcher.module.scss +76 -0
- package/components/ThemeSwitcher/themeswitcher.ts +13 -0
- package/components/Timeline/Timeline.astro +36 -34
- package/components/Timeline/Timeline.svelte +32 -30
- package/components/Timeline/Timeline.tsx +38 -37
- package/components/Timeline/{timeline.scss → timeline.module.scss} +76 -71
- package/components/TimelineItem/TimelineItem.astro +27 -26
- package/components/TimelineItem/TimelineItem.svelte +24 -22
- package/components/TimelineItem/TimelineItem.tsx +33 -32
- package/components/TimelineItem/timelineitem.module.scss +29 -0
- package/components/Toast/Toast.astro +41 -30
- package/components/Toast/Toast.svelte +32 -21
- package/components/Toast/Toast.tsx +38 -28
- package/components/Toast/toast.module.scss +40 -0
- package/components/Toast/toast.ts +8 -6
- package/icons/moon.svg +3 -0
- package/icons/sun.svg +3 -0
- package/icons.d.ts +11 -0
- package/icons.js +9 -0
- package/index.js +3 -0
- package/package.json +5 -1
- package/react.d.ts +4 -0
- package/react.js +4 -0
- package/scss/config/color-palette.scss +23 -0
- package/scss/config/css-values.scss +44 -0
- package/scss/config/layout.scss +41 -0
- package/scss/config/mixins.scss +395 -9
- package/scss/config/typography.scss +66 -0
- package/scss/config.scss +6 -1
- package/scss/global/elements.scss +22 -2
- package/scss/global/scrollbar.scss +24 -0
- package/scss/global/theme.scss +140 -0
- package/scss/global/tooltip.scss +47 -39
- package/scss/global/utility.scss +33 -4
- package/scss/global.scss +2 -1
- package/scss/resets.scss +64 -11
- package/scss/setup.scss +25 -31
- package/svelte.d.ts +16 -12
- package/svelte.js +4 -0
- package/utils/classNames.ts +4 -0
- package/utils/cookies.ts +28 -0
- package/utils/event.ts +17 -0
- package/utils/toast.ts +15 -11
- package/components/Accordion/accordion.scss +0 -63
- package/components/Alert/alert.scss +0 -53
- package/components/Badge/badge.scss +0 -85
- package/components/Button/button.scss +0 -91
- package/components/Card/card.scss +0 -37
- package/components/Checkbox/checkbox.scss +0 -85
- package/components/Input/input.scss +0 -83
- package/components/Progress/progress.scss +0 -66
- package/components/Radio/radio.scss +0 -92
- package/components/Rating/rating.scss +0 -37
- package/components/Switch/switch.scss +0 -84
- package/components/Tabs/tabs.scss +0 -134
- package/components/TimelineItem/timelineitem.scss +0 -31
- package/components/Toast/toast.scss +0 -43
|
@@ -4,7 +4,7 @@ import ConditionalWrapper from '../ConditionalWrapper/ConditionalWrapper.astro'
|
|
|
4
4
|
|
|
5
5
|
import check from '../../icons/check.svg?raw'
|
|
6
6
|
|
|
7
|
-
import './checkbox.scss'
|
|
7
|
+
import styles from './checkbox.module.scss'
|
|
8
8
|
|
|
9
9
|
interface Props extends CheckboxProps {}
|
|
10
10
|
|
|
@@ -13,14 +13,14 @@ const {
|
|
|
13
13
|
label,
|
|
14
14
|
subText,
|
|
15
15
|
disabled,
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
color,
|
|
17
|
+
className
|
|
18
18
|
} = Astro.props
|
|
19
19
|
|
|
20
20
|
const classes = [
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
styles.checkbox,
|
|
22
|
+
label && subText && styles.col,
|
|
23
|
+
className
|
|
24
24
|
]
|
|
25
25
|
|
|
26
26
|
const style = color
|
|
@@ -30,21 +30,21 @@ const style = color
|
|
|
30
30
|
|
|
31
31
|
<label class:list={classes} style={style}>
|
|
32
32
|
<ConditionalWrapper condition={!!(label && subText)}>
|
|
33
|
-
<div class=
|
|
33
|
+
<div class={styles.wrapper} slot="wrapper">
|
|
34
34
|
children
|
|
35
35
|
</div>
|
|
36
36
|
<input type="checkbox" checked={checked} disabled={disabled} />
|
|
37
|
-
<span class=
|
|
37
|
+
<span class={styles.check}>
|
|
38
38
|
<Fragment set:html={check} />
|
|
39
39
|
</span>
|
|
40
40
|
{label && (
|
|
41
|
-
<span class=
|
|
41
|
+
<span class={styles.label}>
|
|
42
42
|
<Fragment set:html={label} />
|
|
43
43
|
</span>
|
|
44
44
|
)}
|
|
45
45
|
</ConditionalWrapper>
|
|
46
46
|
{label && subText && (
|
|
47
|
-
<span class=
|
|
47
|
+
<span class={styles.text}>
|
|
48
48
|
<Fragment set:html={subText} />
|
|
49
49
|
</span>
|
|
50
50
|
)}
|
|
@@ -1,24 +1,25 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import type {
|
|
2
|
+
import type { SvelteCheckboxProps } from './checkbox'
|
|
3
3
|
import ConditionalWrapper from '../ConditionalWrapper/ConditionalWrapper.svelte'
|
|
4
4
|
|
|
5
5
|
import check from '../../icons/check.svg?raw'
|
|
6
6
|
|
|
7
|
-
import './checkbox.scss'
|
|
7
|
+
import styles from './checkbox.module.scss'
|
|
8
|
+
import { classNames } from '../../utils/classNames'
|
|
8
9
|
|
|
9
|
-
export let checked:
|
|
10
|
-
export let label:
|
|
11
|
-
export let subText:
|
|
12
|
-
export let disabled:
|
|
13
|
-
export let
|
|
14
|
-
export let
|
|
15
|
-
export let onClick:
|
|
10
|
+
export let checked: SvelteCheckboxProps['checked'] = false
|
|
11
|
+
export let label: SvelteCheckboxProps['label'] = ''
|
|
12
|
+
export let subText: SvelteCheckboxProps['subText'] = ''
|
|
13
|
+
export let disabled: SvelteCheckboxProps['disabled'] = false
|
|
14
|
+
export let color: SvelteCheckboxProps['color'] = ''
|
|
15
|
+
export let className: SvelteCheckboxProps['className'] = ''
|
|
16
|
+
export let onClick: SvelteCheckboxProps['onClick'] = () => {}
|
|
16
17
|
|
|
17
|
-
const classes = [
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
]
|
|
18
|
+
const classes = classNames([
|
|
19
|
+
styles.checkbox,
|
|
20
|
+
label && subText && styles.col,
|
|
21
|
+
className
|
|
22
|
+
])
|
|
22
23
|
|
|
23
24
|
const style = color
|
|
24
25
|
? `--w-checkbox-color: ${color};`
|
|
@@ -29,7 +30,7 @@
|
|
|
29
30
|
<ConditionalWrapper
|
|
30
31
|
condition={!!(label && subText)}
|
|
31
32
|
element="div"
|
|
32
|
-
class=
|
|
33
|
+
class={styles.wrapper}
|
|
33
34
|
>
|
|
34
35
|
<input
|
|
35
36
|
type="checkbox"
|
|
@@ -37,16 +38,16 @@
|
|
|
37
38
|
disabled={disabled}
|
|
38
39
|
on:click={onClick}
|
|
39
40
|
/>
|
|
40
|
-
<span class=
|
|
41
|
+
<span class={styles.check}>
|
|
41
42
|
{@html check}
|
|
42
43
|
</span>
|
|
43
44
|
{#if label}
|
|
44
|
-
<span class=
|
|
45
|
+
<span class={styles.label}>
|
|
45
46
|
{@html label}
|
|
46
47
|
</span>
|
|
47
48
|
{/if}
|
|
48
49
|
</ConditionalWrapper>
|
|
49
50
|
{#if label && subText}
|
|
50
|
-
<span class=
|
|
51
|
+
<span class={styles.text}>{@html subText}</span>
|
|
51
52
|
{/if}
|
|
52
53
|
</label>
|
|
@@ -4,22 +4,23 @@ import ConditionalWrapper from '../ConditionalWrapper/ConditionalWrapper.tsx'
|
|
|
4
4
|
|
|
5
5
|
import check from '../../icons/check.svg?raw'
|
|
6
6
|
|
|
7
|
-
import './checkbox.scss'
|
|
7
|
+
import styles from './checkbox.module.scss'
|
|
8
|
+
import { classNames } from '../../utils/classNames'
|
|
8
9
|
|
|
9
10
|
const Checkbox = ({
|
|
10
11
|
checked,
|
|
11
12
|
label,
|
|
12
13
|
subText,
|
|
13
14
|
disabled,
|
|
14
|
-
boxed,
|
|
15
15
|
color,
|
|
16
|
+
className,
|
|
16
17
|
onClick
|
|
17
18
|
}: ReactCheckboxProps) => {
|
|
18
|
-
const classes = [
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
]
|
|
19
|
+
const classes = classNames([
|
|
20
|
+
styles.checkbox,
|
|
21
|
+
label && subText && styles.col,
|
|
22
|
+
className
|
|
23
|
+
])
|
|
23
24
|
|
|
24
25
|
const style = color
|
|
25
26
|
? { '--w-checkbox-color': color } as React.CSSProperties
|
|
@@ -30,7 +31,7 @@ const Checkbox = ({
|
|
|
30
31
|
<ConditionalWrapper
|
|
31
32
|
condition={!!(label && subText)}
|
|
32
33
|
wrapper={children => (
|
|
33
|
-
<div className=
|
|
34
|
+
<div className={styles.wrapper}>
|
|
34
35
|
{children}
|
|
35
36
|
</div>
|
|
36
37
|
)}
|
|
@@ -42,19 +43,19 @@ const Checkbox = ({
|
|
|
42
43
|
onClick={onClick}
|
|
43
44
|
/>
|
|
44
45
|
<span
|
|
45
|
-
className=
|
|
46
|
+
className={styles.check}
|
|
46
47
|
dangerouslySetInnerHTML={{ __html: check }}
|
|
47
48
|
/>
|
|
48
49
|
{label && (
|
|
49
50
|
<span
|
|
50
|
-
className=
|
|
51
|
+
className={styles.label}
|
|
51
52
|
dangerouslySetInnerHTML={{ __html: label }}
|
|
52
53
|
/>
|
|
53
54
|
)}
|
|
54
55
|
</ConditionalWrapper>
|
|
55
56
|
{label && subText && (
|
|
56
57
|
<span
|
|
57
|
-
className=
|
|
58
|
+
className={styles.text}
|
|
58
59
|
dangerouslySetInnerHTML={{ __html: subText }}
|
|
59
60
|
/>
|
|
60
61
|
)}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
@use '../../scss/config.scss' as *;
|
|
2
|
+
|
|
3
|
+
body {
|
|
4
|
+
--w-checkbox-color: var(--w-color-primary);
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
.checkbox {
|
|
8
|
+
@include layout(inline-flex, sm);
|
|
9
|
+
@include typography(md, hmd);
|
|
10
|
+
|
|
11
|
+
cursor: pointer;
|
|
12
|
+
|
|
13
|
+
&.col {
|
|
14
|
+
@include layout(column, h-start, v-start, none);
|
|
15
|
+
|
|
16
|
+
.wrapper {
|
|
17
|
+
@include layout(flex, sm);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
input {
|
|
22
|
+
display: none;
|
|
23
|
+
|
|
24
|
+
&:checked + span {
|
|
25
|
+
@include background(var(--w-checkbox-color));
|
|
26
|
+
|
|
27
|
+
svg {
|
|
28
|
+
@include position(absolute, center);
|
|
29
|
+
@include typography(primary-50);
|
|
30
|
+
@include size(10px);
|
|
31
|
+
|
|
32
|
+
display: block;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
&:disabled + span {
|
|
37
|
+
@include background(primary-40);
|
|
38
|
+
@include border(primary-40);
|
|
39
|
+
cursor: no-drop;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.check {
|
|
44
|
+
@include size(15px);
|
|
45
|
+
@include position(relative);
|
|
46
|
+
@include border-radius(sm);
|
|
47
|
+
@include spacing(mt-xs);
|
|
48
|
+
|
|
49
|
+
display: inline-block;
|
|
50
|
+
min-width: 15px;
|
|
51
|
+
border: 1px solid var(--w-checkbox-color);
|
|
52
|
+
|
|
53
|
+
svg {
|
|
54
|
+
@include visibility(none);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.text {
|
|
59
|
+
@include spacing(ml-lg);
|
|
60
|
+
@include typography(sm, primary-20);
|
|
61
|
+
|
|
62
|
+
a {
|
|
63
|
+
@include typography(primary-20);
|
|
64
|
+
|
|
65
|
+
&:hover {
|
|
66
|
+
@include typography(primary);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
@@ -3,10 +3,14 @@ export type CheckboxProps = {
|
|
|
3
3
|
label?: string
|
|
4
4
|
subText?: string
|
|
5
5
|
disabled?: boolean
|
|
6
|
-
boxed?: boolean
|
|
7
6
|
color?: string
|
|
7
|
+
className?: string
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
+
export type SvelteCheckboxProps = {
|
|
11
|
+
onClick?: (key: any) => any
|
|
12
|
+
} & CheckboxProps
|
|
13
|
+
|
|
10
14
|
export type ReactCheckboxProps = {
|
|
11
15
|
onClick?: (key: any) => any
|
|
12
16
|
} & CheckboxProps
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
import type { IconProps } from './icon'
|
|
3
|
+
import iconMap from './map'
|
|
3
4
|
|
|
4
5
|
interface Props extends IconProps {}
|
|
5
6
|
|
|
@@ -9,8 +10,7 @@ const {
|
|
|
9
10
|
color
|
|
10
11
|
} = Astro.props
|
|
11
12
|
|
|
12
|
-
const
|
|
13
|
-
const icon = markup
|
|
13
|
+
const icon = iconMap[type as keyof typeof iconMap]
|
|
14
14
|
.replace('width="24"', `width=${size}`)
|
|
15
15
|
.replace('height="24"', color
|
|
16
16
|
? `height=${size} color=${color}`
|
|
@@ -1,18 +1,11 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import type { IconProps } from './icon'
|
|
3
|
-
|
|
4
|
-
import Github from '../../icons/github.svg?raw'
|
|
5
|
-
import ArrowDown from '../../icons/arrow-down.svg?raw'
|
|
3
|
+
import iconMap from './map'
|
|
6
4
|
|
|
7
5
|
export let type: IconProps['type'] = ''
|
|
8
6
|
export let size: IconProps['size'] = 24
|
|
9
7
|
export let color: IconProps['color'] = ''
|
|
10
8
|
|
|
11
|
-
const iconMap = {
|
|
12
|
-
'github': Github,
|
|
13
|
-
'arrow-down': ArrowDown
|
|
14
|
-
}
|
|
15
|
-
|
|
16
9
|
const icon = iconMap[type as keyof typeof iconMap]
|
|
17
10
|
.replace('width="24"', `width=${size}`)
|
|
18
11
|
.replace('height="24"', color
|
package/components/Icon/Icon.tsx
CHANGED
|
@@ -1,13 +1,6 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
2
|
import type { IconProps } from './icon'
|
|
3
|
-
|
|
4
|
-
import Github from '../../icons/github.svg?raw'
|
|
5
|
-
import ArrowDown from '../../icons/arrow-down.svg?raw'
|
|
6
|
-
|
|
7
|
-
const iconMap = {
|
|
8
|
-
'github': Github,
|
|
9
|
-
'arrow-down': ArrowDown
|
|
10
|
-
}
|
|
3
|
+
import iconMap from './map'
|
|
11
4
|
|
|
12
5
|
const Icon = ({
|
|
13
6
|
type,
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import Alert from '../../icons/alert.svg?raw'
|
|
2
|
+
import ArrowDown from '../../icons/arrow-down.svg?raw'
|
|
3
|
+
import Check from '../../icons/check.svg?raw'
|
|
4
|
+
import CircleCheck from '../../icons/circle-check.svg?raw'
|
|
5
|
+
import Github from '../../icons/github.svg?raw'
|
|
6
|
+
import Info from '../../icons/info.svg?raw'
|
|
7
|
+
import Moon from '../../icons/moon.svg?raw'
|
|
8
|
+
import Sun from '../../icons/sun.svg?raw'
|
|
9
|
+
import Warning from '../../icons/warning.svg?raw'
|
|
10
|
+
|
|
11
|
+
const iconMap = {
|
|
12
|
+
'alert': Alert,
|
|
13
|
+
'arrow-down': ArrowDown,
|
|
14
|
+
'check': Check,
|
|
15
|
+
'circle-check': CircleCheck,
|
|
16
|
+
'github': Github,
|
|
17
|
+
'info': Info,
|
|
18
|
+
'moon': Moon,
|
|
19
|
+
'sun': Sun,
|
|
20
|
+
'warning': Warning
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export default iconMap
|
|
@@ -1,52 +1,50 @@
|
|
|
1
|
-
---
|
|
2
|
-
import type { InputProps } from './input'
|
|
3
|
-
import ConditionalWrapper from '
|
|
4
|
-
|
|
5
|
-
import './input.scss'
|
|
6
|
-
|
|
7
|
-
interface Props extends InputProps {}
|
|
8
|
-
|
|
9
|
-
const {
|
|
10
|
-
type = 'text',
|
|
11
|
-
theme,
|
|
12
|
-
label,
|
|
13
|
-
subText,
|
|
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
|
-
</ConditionalWrapper>
|
|
1
|
+
---
|
|
2
|
+
import type { InputProps } from './input'
|
|
3
|
+
import ConditionalWrapper from '../ConditionalWrapper/ConditionalWrapper.astro'
|
|
4
|
+
|
|
5
|
+
import styles from './input.module.scss'
|
|
6
|
+
|
|
7
|
+
interface Props extends InputProps {}
|
|
8
|
+
|
|
9
|
+
const {
|
|
10
|
+
type = 'text',
|
|
11
|
+
theme,
|
|
12
|
+
label,
|
|
13
|
+
subText,
|
|
14
|
+
className,
|
|
15
|
+
...rest
|
|
16
|
+
} = Astro.props
|
|
17
|
+
|
|
18
|
+
const classes = [
|
|
19
|
+
styles.input,
|
|
20
|
+
theme && styles[theme],
|
|
21
|
+
className
|
|
22
|
+
]
|
|
23
|
+
|
|
24
|
+
const useLabel = !!(label || subText || Astro.slots.has('default'))
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
<ConditionalWrapper condition={useLabel}>
|
|
28
|
+
<label slot="wrapper" class={styles['input-label']}>
|
|
29
|
+
{label && (
|
|
30
|
+
<div class={styles.label}>{label}</div>
|
|
31
|
+
)}
|
|
32
|
+
<ConditionalWrapper condition={Astro.slots.has('default')}>
|
|
33
|
+
<div class={styles.wrapper} slot="wrapper">
|
|
34
|
+
children
|
|
35
|
+
</div>
|
|
36
|
+
<slot />
|
|
37
|
+
children
|
|
38
|
+
</ConditionalWrapper>
|
|
39
|
+
{subText && (
|
|
40
|
+
<div class={styles.subtext}>
|
|
41
|
+
<Fragment set:html={subText} />
|
|
42
|
+
</div>
|
|
43
|
+
)}
|
|
44
|
+
</label>
|
|
45
|
+
<input
|
|
46
|
+
type={type}
|
|
47
|
+
class:list={classes}
|
|
48
|
+
{...rest}
|
|
49
|
+
/>
|
|
50
|
+
</ConditionalWrapper>
|
|
@@ -1,52 +1,52 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import type {
|
|
3
|
-
import ConditionalWrapper from '
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
export let
|
|
9
|
-
export let
|
|
10
|
-
export let
|
|
11
|
-
export let
|
|
12
|
-
export let
|
|
13
|
-
export let
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
className
|
|
20
|
-
]
|
|
21
|
-
|
|
22
|
-
const useLabel = !!(label || subText || $$slots.
|
|
23
|
-
</script>
|
|
24
|
-
|
|
25
|
-
<ConditionalWrapper
|
|
26
|
-
condition={useLabel}
|
|
27
|
-
element="label"
|
|
28
|
-
class=
|
|
29
|
-
>
|
|
30
|
-
{#if label}
|
|
31
|
-
<div class=
|
|
32
|
-
{/if}
|
|
33
|
-
<ConditionalWrapper
|
|
34
|
-
condition={$$slots.
|
|
35
|
-
element="div"
|
|
36
|
-
class=
|
|
37
|
-
>
|
|
38
|
-
<slot
|
|
39
|
-
<input
|
|
40
|
-
type={type}
|
|
41
|
-
class={classes}
|
|
42
|
-
on:change={onChange}
|
|
43
|
-
on:keyup={onKeyUp}
|
|
44
|
-
{...$$restProps}
|
|
45
|
-
/>
|
|
46
|
-
</ConditionalWrapper>
|
|
47
|
-
{#if label}
|
|
48
|
-
<div class=
|
|
49
|
-
{@html subText}
|
|
50
|
-
</div>
|
|
51
|
-
{/if}
|
|
52
|
-
</ConditionalWrapper>
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { SvelteInputProps } from './input'
|
|
3
|
+
import ConditionalWrapper from '../ConditionalWrapper/ConditionalWrapper.svelte'
|
|
4
|
+
|
|
5
|
+
import styles from './input.module.scss'
|
|
6
|
+
import { classNames } from '../../utils/classNames'
|
|
7
|
+
|
|
8
|
+
export let type: SvelteInputProps['type'] = 'text'
|
|
9
|
+
export let theme: SvelteInputProps['theme'] = null
|
|
10
|
+
export let label: SvelteInputProps['label'] = ''
|
|
11
|
+
export let subText: SvelteInputProps['subText'] = ''
|
|
12
|
+
export let className: SvelteInputProps['className'] = ''
|
|
13
|
+
export let onChange: SvelteInputProps['onChange'] = () => {}
|
|
14
|
+
export let onKeyUp: SvelteInputProps['onKeyUp'] = () => {}
|
|
15
|
+
|
|
16
|
+
const classes = classNames([
|
|
17
|
+
styles.input,
|
|
18
|
+
theme && styles[theme],
|
|
19
|
+
className
|
|
20
|
+
])
|
|
21
|
+
|
|
22
|
+
const useLabel = !!(label || subText || $$slots.default)
|
|
23
|
+
</script>
|
|
24
|
+
|
|
25
|
+
<ConditionalWrapper
|
|
26
|
+
condition={useLabel}
|
|
27
|
+
element="label"
|
|
28
|
+
class={styles['input-label']}
|
|
29
|
+
>
|
|
30
|
+
{#if label}
|
|
31
|
+
<div class={styles.label}>{label}</div>
|
|
32
|
+
{/if}
|
|
33
|
+
<ConditionalWrapper
|
|
34
|
+
condition={$$slots.default}
|
|
35
|
+
element="div"
|
|
36
|
+
class={styles.wrapper}
|
|
37
|
+
>
|
|
38
|
+
<slot />
|
|
39
|
+
<input
|
|
40
|
+
type={type}
|
|
41
|
+
class={classes}
|
|
42
|
+
on:change={onChange}
|
|
43
|
+
on:keyup={onKeyUp}
|
|
44
|
+
{...$$restProps}
|
|
45
|
+
/>
|
|
46
|
+
</ConditionalWrapper>
|
|
47
|
+
{#if label}
|
|
48
|
+
<div class={styles.subtext}>
|
|
49
|
+
{@html subText}
|
|
50
|
+
</div>
|
|
51
|
+
{/if}
|
|
52
|
+
</ConditionalWrapper>
|