webcoreui 0.8.1 → 0.10.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 +36 -6
- package/astro.d.ts +23 -0
- package/astro.js +8 -0
- package/components/Accordion/Accordion.astro +15 -10
- package/components/Accordion/Accordion.svelte +14 -12
- package/components/Accordion/Accordion.tsx +2 -2
- package/components/Accordion/accordion.module.scss +1 -0
- package/components/Alert/Alert.svelte +17 -12
- package/components/Alert/Alert.tsx +1 -1
- package/components/Alert/alert.ts +10 -3
- package/components/AspectRatio/AspectRatio.svelte +7 -4
- package/components/AspectRatio/aspectratio.ts +6 -0
- package/components/Avatar/Avatar.svelte +11 -9
- package/components/Badge/Badge.svelte +14 -10
- package/components/Badge/badge.ts +3 -2
- package/components/Banner/Banner.astro +10 -4
- package/components/Banner/Banner.svelte +14 -10
- package/components/Banner/Banner.tsx +1 -0
- package/components/Banner/banner.ts +6 -0
- package/components/BottomNavigation/BottomNavigation.astro +51 -0
- package/components/BottomNavigation/BottomNavigation.svelte +47 -0
- package/components/BottomNavigation/BottomNavigation.tsx +63 -0
- package/components/BottomNavigation/bottomnavigation.module.scss +70 -0
- package/components/BottomNavigation/bottomnavigation.ts +16 -0
- package/components/Breadcrumb/Breadcrumb.astro +1 -1
- package/components/Breadcrumb/Breadcrumb.svelte +8 -6
- package/components/Breadcrumb/Breadcrumb.tsx +2 -2
- package/components/Button/Button.svelte +12 -8
- package/components/Button/Button.tsx +2 -2
- package/components/Button/button.ts +2 -3
- package/components/Card/Card.svelte +14 -10
- package/components/Card/card.module.scss +1 -0
- package/components/Card/card.ts +6 -0
- package/components/Carousel/Carousel.astro +46 -41
- package/components/Carousel/carousel.ts +3 -0
- package/components/Checkbox/Checkbox.astro +8 -2
- package/components/Checkbox/Checkbox.svelte +12 -8
- package/components/Checkbox/Checkbox.tsx +3 -1
- package/components/Checkbox/checkbox.module.scss +4 -0
- package/components/Checkbox/checkbox.ts +1 -0
- package/components/Collapsible/Collapsible.astro +8 -5
- package/components/Collapsible/Collapsible.svelte +54 -49
- package/components/Collapsible/collapsible.ts +8 -0
- package/components/ConditionalWrapper/ConditionalWrapper.svelte +10 -6
- package/components/ConditionalWrapper/conditionalwrapper.ts +6 -0
- package/components/Copy/Copy.astro +80 -0
- package/components/Copy/Copy.svelte +68 -0
- package/components/Copy/Copy.tsx +74 -0
- package/components/Copy/copy.module.scss +37 -0
- package/components/Copy/copy.ts +20 -0
- package/components/DataTable/DataTable.astro +103 -93
- package/components/DataTable/DataTable.svelte +276 -272
- package/components/DataTable/datatable.ts +5 -2
- package/components/Flex/Flex.astro +34 -0
- package/components/Flex/Flex.svelte +31 -0
- package/components/Flex/Flex.tsx +30 -0
- package/components/Flex/flex.ts +28 -0
- package/components/Footer/Footer.svelte +12 -9
- package/components/Footer/footer.ts +6 -0
- package/components/Grid/Grid.astro +32 -0
- package/components/Grid/Grid.svelte +29 -0
- package/components/Grid/Grid.tsx +28 -0
- package/components/Grid/grid.ts +24 -0
- package/components/Group/Group.svelte +7 -4
- package/components/Group/group.ts +6 -0
- package/components/Icon/Icon.astro +19 -5
- package/components/Icon/Icon.svelte +23 -7
- package/components/Icon/Icon.tsx +19 -5
- package/components/Icon/icon.ts +10 -3
- package/components/Icon/map.ts +10 -10
- package/components/Input/Input.astro +1 -1
- package/components/Input/Input.svelte +26 -20
- package/components/Input/Input.tsx +4 -1
- package/components/Input/input.ts +10 -3
- package/components/Kbd/Kbd.svelte +7 -4
- package/components/Kbd/kbd.ts +6 -0
- package/components/List/List.astro +65 -60
- package/components/List/List.svelte +149 -147
- package/components/List/List.tsx +1 -1
- package/components/List/list.module.scss +3 -0
- package/components/Masonry/Masonry.svelte +12 -10
- package/components/Menu/Menu.astro +8 -3
- package/components/Menu/Menu.svelte +19 -10
- package/components/Menu/Menu.tsx +3 -1
- package/components/Menu/menu.ts +6 -0
- package/components/Modal/Modal.astro +1 -0
- package/components/Modal/Modal.svelte +18 -13
- package/components/Modal/Modal.tsx +2 -1
- package/components/Modal/modal.ts +6 -1
- package/components/Pagination/Pagination.astro +75 -69
- package/components/Pagination/Pagination.svelte +30 -26
- package/components/Pagination/Pagination.tsx +5 -4
- package/components/Pagination/pagination.module.scss +4 -0
- package/components/Popover/Popover.svelte +10 -6
- package/components/Popover/popover.ts +6 -0
- package/components/Progress/Progress.svelte +12 -10
- package/components/Progress/progress.ts +1 -1
- package/components/Radio/Radio.astro +3 -1
- package/components/Radio/Radio.svelte +14 -10
- package/components/Radio/Radio.tsx +5 -3
- package/components/Radio/radio.ts +5 -2
- package/components/Rating/Rating.svelte +16 -14
- package/components/Ribbon/Ribbon.svelte +9 -6
- package/components/Ribbon/ribbon.ts +6 -0
- package/components/Select/Select.astro +85 -42
- package/components/Select/Select.svelte +62 -21
- package/components/Select/Select.tsx +41 -7
- package/components/Select/select.ts +4 -1
- package/components/Sheet/Sheet.svelte +9 -5
- package/components/Sheet/sheet.ts +6 -2
- package/components/Sidebar/Sidebar.svelte +7 -4
- package/components/Sidebar/sidebar.ts +6 -0
- package/components/Skeleton/Skeleton.astro +2 -2
- package/components/Skeleton/Skeleton.svelte +11 -9
- package/components/Skeleton/Skeleton.tsx +2 -2
- package/components/Slider/Slider.svelte +15 -13
- package/components/Slider/slider.module.scss +4 -0
- package/components/Slider/slider.ts +4 -2
- package/components/Spinner/Spinner.svelte +7 -5
- package/components/Spoiler/Spoiler.astro +13 -8
- package/components/Spoiler/Spoiler.svelte +13 -10
- package/components/Spoiler/spoiler.ts +6 -0
- package/components/Stepper/Stepper.svelte +9 -7
- package/components/Switch/Switch.astro +3 -2
- package/components/Switch/Switch.svelte +15 -11
- package/components/Switch/Switch.tsx +3 -1
- package/components/Switch/switch.ts +1 -0
- package/components/Table/Table.svelte +11 -9
- package/components/Table/table.ts +1 -1
- package/components/Tabs/Tabs.astro +8 -5
- package/components/Tabs/Tabs.svelte +14 -11
- package/components/Tabs/tabs.ts +7 -1
- package/components/Textarea/Textarea.astro +3 -1
- package/components/Textarea/Textarea.svelte +51 -47
- package/components/Textarea/textarea.ts +24 -18
- package/components/ThemeSwitcher/ThemeSwitcher.astro +43 -37
- package/components/ThemeSwitcher/ThemeSwitcher.svelte +14 -10
- package/components/ThemeSwitcher/themeswitcher.ts +7 -0
- package/components/Timeline/Timeline.svelte +12 -9
- package/components/Timeline/timeline.ts +7 -2
- package/components/TimelineItem/TimelineItem.svelte +8 -5
- package/components/TimelineItem/timelineitem.ts +6 -0
- package/components/Toast/Toast.svelte +18 -10
- package/components/Toast/toast.ts +6 -1
- package/icons/alert.svg +2 -2
- package/icons/check.svg +2 -2
- package/icons/chevron-down.svg +3 -0
- package/icons/chevron-left.svg +3 -0
- package/icons/chevron-right.svg +3 -0
- package/icons/chevron-up.svg +3 -0
- package/icons/circle-check.svg +3 -3
- package/icons/copy.svg +3 -0
- package/icons/info.svg +3 -3
- package/icons.d.ts +5 -5
- package/icons.js +5 -5
- package/index.d.ts +75 -2
- package/index.js +2 -0
- package/package.json +31 -22
- package/react.d.ts +23 -0
- package/react.js +8 -0
- package/scss/global/utility.scss +48 -3
- package/svelte.d.ts +111 -88
- package/svelte.js +8 -0
- package/utils/DOMUtils.ts +2 -2
- package/utils/bodyFreeze.ts +13 -0
- package/utils/classNames.ts +1 -1
- package/utils/getLayoutClasses.ts +141 -0
- package/utils/modal.ts +16 -4
- package/utils/popover.ts +30 -4
- package/icons/arrow-down.svg +0 -3
- package/icons/arrow-left.svg +0 -3
- package/icons/arrow-right.svg +0 -3
- package/icons/components.svg +0 -3
- package/icons/file.svg +0 -3
- package/scss/webcore.config.scss +0 -0
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte'
|
|
2
|
+
|
|
1
3
|
export type BannerProps = {
|
|
2
4
|
top?: number
|
|
3
5
|
bottom?: boolean
|
|
@@ -7,6 +9,10 @@ export type BannerProps = {
|
|
|
7
9
|
className?: string
|
|
8
10
|
}
|
|
9
11
|
|
|
12
|
+
export type SvelteBannerProps = {
|
|
13
|
+
children: Snippet
|
|
14
|
+
} & BannerProps
|
|
15
|
+
|
|
10
16
|
export type ReactBannerProps = {
|
|
11
17
|
children: React.ReactNode
|
|
12
18
|
} & BannerProps
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
---
|
|
2
|
+
import type { BottomNavigationProps } from './bottomnavigation'
|
|
3
|
+
|
|
4
|
+
import Icon from '../Icon/Icon.astro'
|
|
5
|
+
|
|
6
|
+
import styles from './bottomnavigation.module.scss'
|
|
7
|
+
|
|
8
|
+
import type { IconProps } from '../Icon/icon'
|
|
9
|
+
|
|
10
|
+
interface Props extends BottomNavigationProps {}
|
|
11
|
+
|
|
12
|
+
const {
|
|
13
|
+
items,
|
|
14
|
+
separated,
|
|
15
|
+
floating,
|
|
16
|
+
maxWidth,
|
|
17
|
+
className
|
|
18
|
+
} = Astro.props
|
|
19
|
+
|
|
20
|
+
const classes = [
|
|
21
|
+
styles.nav,
|
|
22
|
+
separated && styles.separated,
|
|
23
|
+
maxWidth && styles.bordered,
|
|
24
|
+
floating && styles.floating,
|
|
25
|
+
className
|
|
26
|
+
]
|
|
27
|
+
|
|
28
|
+
const styleVariable = maxWidth
|
|
29
|
+
? `--w-bottom-navigation-max-width: ${maxWidth};`
|
|
30
|
+
: null
|
|
31
|
+
---
|
|
32
|
+
|
|
33
|
+
<nav class:list={classes} style={styleVariable}>
|
|
34
|
+
<ul>
|
|
35
|
+
{items?.map(item => ({ ...item, element: item.href ? 'a' : 'div' })).map(item => (
|
|
36
|
+
<li data-tooltip={item.tooltip} class:list={[item.icon && styles['with-icon']]}>
|
|
37
|
+
<item.element {...{ href: item.href, target: item.target, class: styles.item }}>
|
|
38
|
+
{item.icon && (
|
|
39
|
+
<Fragment>
|
|
40
|
+
{item.icon?.startsWith('<svg')
|
|
41
|
+
? <Fragment set:html={item.icon} />
|
|
42
|
+
: <Icon type={item.icon as IconProps['type']} />
|
|
43
|
+
}
|
|
44
|
+
</Fragment>
|
|
45
|
+
)}
|
|
46
|
+
{item.name}
|
|
47
|
+
</item.element>
|
|
48
|
+
</li>
|
|
49
|
+
))}
|
|
50
|
+
</ul>
|
|
51
|
+
</nav>
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { BottomNavigationProps } from './bottomnavigation'
|
|
3
|
+
|
|
4
|
+
import { classNames } from '../../utils/classNames'
|
|
5
|
+
|
|
6
|
+
import styles from './bottomnavigation.module.scss'
|
|
7
|
+
|
|
8
|
+
const {
|
|
9
|
+
items,
|
|
10
|
+
separated,
|
|
11
|
+
floating,
|
|
12
|
+
maxWidth,
|
|
13
|
+
className
|
|
14
|
+
}: BottomNavigationProps = $props()
|
|
15
|
+
|
|
16
|
+
const classes = classNames([
|
|
17
|
+
styles.nav,
|
|
18
|
+
separated && styles.separated,
|
|
19
|
+
maxWidth && styles.bordered,
|
|
20
|
+
floating && styles.floating,
|
|
21
|
+
className
|
|
22
|
+
])
|
|
23
|
+
|
|
24
|
+
const styleVariable = maxWidth
|
|
25
|
+
? `--w-bottom-navigation-max-width: ${maxWidth};`
|
|
26
|
+
: null
|
|
27
|
+
</script>
|
|
28
|
+
|
|
29
|
+
<nav class={classes} style={styleVariable}>
|
|
30
|
+
<ul>
|
|
31
|
+
{#each items as item}
|
|
32
|
+
<li data-tooltip={item.tooltip} class={classNames([item.icon && styles['with-icon']])}>
|
|
33
|
+
<svelte:element
|
|
34
|
+
this={item.href ? 'a' : 'div'}
|
|
35
|
+
href={item.href}
|
|
36
|
+
target={item.target}
|
|
37
|
+
class={styles.item}
|
|
38
|
+
>
|
|
39
|
+
{#if item.icon}
|
|
40
|
+
{@html item.icon}
|
|
41
|
+
{/if}
|
|
42
|
+
{item.name}
|
|
43
|
+
</svelte:element>
|
|
44
|
+
</li>
|
|
45
|
+
{/each}
|
|
46
|
+
</ul>
|
|
47
|
+
</nav>
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import type { BottomNavigationProps } from './bottomnavigation'
|
|
3
|
+
|
|
4
|
+
import { classNames } from '../../utils/classNames'
|
|
5
|
+
|
|
6
|
+
import styles from './bottomnavigation.module.scss'
|
|
7
|
+
|
|
8
|
+
type ElementType = BottomNavigationProps['items'][0] & {
|
|
9
|
+
className: string
|
|
10
|
+
dangerouslySetInnerHTML: {
|
|
11
|
+
__html: string
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const BottomNavigation = ({
|
|
16
|
+
items,
|
|
17
|
+
separated,
|
|
18
|
+
floating,
|
|
19
|
+
maxWidth,
|
|
20
|
+
className
|
|
21
|
+
}: BottomNavigationProps) => {
|
|
22
|
+
const classes = classNames([
|
|
23
|
+
styles.nav,
|
|
24
|
+
separated && styles.separated,
|
|
25
|
+
maxWidth && styles.bordered,
|
|
26
|
+
floating && styles.floating,
|
|
27
|
+
className
|
|
28
|
+
])
|
|
29
|
+
|
|
30
|
+
const styleVariable = maxWidth
|
|
31
|
+
? { '--w-bottom-navigation-max-width': maxWidth } as React.CSSProperties
|
|
32
|
+
: undefined
|
|
33
|
+
|
|
34
|
+
const Element = ({ href, ...rest }: ElementType) => href
|
|
35
|
+
? <a {...rest} />
|
|
36
|
+
: <div {...rest} />
|
|
37
|
+
|
|
38
|
+
return (
|
|
39
|
+
<nav className={classes} style={styleVariable}>
|
|
40
|
+
<ul>
|
|
41
|
+
{items?.map((item, index) => (
|
|
42
|
+
<li
|
|
43
|
+
key={index}
|
|
44
|
+
data-tooltip={item.tooltip}
|
|
45
|
+
className={classNames([item.icon && styles['with-icon']])}
|
|
46
|
+
>
|
|
47
|
+
<Element
|
|
48
|
+
href={item.href}
|
|
49
|
+
target={item.target}
|
|
50
|
+
className={styles.item}
|
|
51
|
+
dangerouslySetInnerHTML={{ __html: item.icon
|
|
52
|
+
? `${item.icon} ${item.name}`
|
|
53
|
+
: (item.name || '')
|
|
54
|
+
}}
|
|
55
|
+
/>
|
|
56
|
+
</li>
|
|
57
|
+
))}
|
|
58
|
+
</ul>
|
|
59
|
+
</nav>
|
|
60
|
+
)
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export default BottomNavigation
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
@use '../../scss/config.scss' as *;
|
|
2
|
+
|
|
3
|
+
body {
|
|
4
|
+
--w-bottom-navigation-max-width: auto;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
.nav {
|
|
8
|
+
@include background(primary-60);
|
|
9
|
+
@include position(fixed, b0, l0, r0);
|
|
10
|
+
@include layer(header);
|
|
11
|
+
@include border(top, primary-50);
|
|
12
|
+
|
|
13
|
+
&.separated ul li:not(:last-child) {
|
|
14
|
+
@include border(right, primary-50);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
&.separated.bordered ul {
|
|
18
|
+
@include border(left, primary-50);
|
|
19
|
+
@include border(right, primary-50);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
&.floating {
|
|
23
|
+
@include position(l20px, r20px, b20px);
|
|
24
|
+
@include border-radius(xl);
|
|
25
|
+
@include border(0);
|
|
26
|
+
|
|
27
|
+
&:not(.bordered) {
|
|
28
|
+
li:first-child .item {
|
|
29
|
+
@include border-radius(xl, left);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
li:last-child .item {
|
|
33
|
+
@include border-radius(xl, right);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
ul {
|
|
39
|
+
@include spacing(none-auto, p0);
|
|
40
|
+
@include layout(flex, h-center);
|
|
41
|
+
|
|
42
|
+
max-width: var(--w-bottom-navigation-max-width);
|
|
43
|
+
list-style-type: none;
|
|
44
|
+
|
|
45
|
+
li {
|
|
46
|
+
@include spacing(mb-0);
|
|
47
|
+
|
|
48
|
+
flex: 1;
|
|
49
|
+
|
|
50
|
+
&.with-icon .item {
|
|
51
|
+
@include spacing(pt-sm, pb-xs);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.item {
|
|
55
|
+
@include layout(flex, column, center, xs);
|
|
56
|
+
@include spacing(py-sm);
|
|
57
|
+
@include size('h100%');
|
|
58
|
+
@include transition(background);
|
|
59
|
+
@include typography(md, primary-10, none);
|
|
60
|
+
|
|
61
|
+
user-select: none;
|
|
62
|
+
cursor: pointer;
|
|
63
|
+
|
|
64
|
+
&:hover {
|
|
65
|
+
@include background(primary-50);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ButtonProps } from '../Button/button'
|
|
2
|
+
import type { IconProps } from '../Icon/icon'
|
|
3
|
+
|
|
4
|
+
export type BottomNavigationProps = {
|
|
5
|
+
items: {
|
|
6
|
+
name?: string
|
|
7
|
+
href?: string
|
|
8
|
+
target?: ButtonProps['target']
|
|
9
|
+
icon?: IconProps['type'] | string
|
|
10
|
+
tooltip?: string
|
|
11
|
+
}[]
|
|
12
|
+
separated?: boolean
|
|
13
|
+
floating?: boolean
|
|
14
|
+
maxWidth?: string
|
|
15
|
+
className?: string
|
|
16
|
+
}
|
|
@@ -5,13 +5,15 @@
|
|
|
5
5
|
|
|
6
6
|
import { classNames } from '../../utils/classNames'
|
|
7
7
|
|
|
8
|
-
import
|
|
8
|
+
import ChevronRight from '../../icons/chevron-right.svg?raw'
|
|
9
9
|
|
|
10
10
|
import styles from './breadcrumb.module.scss'
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
const {
|
|
13
|
+
items,
|
|
14
|
+
separator,
|
|
15
|
+
className
|
|
16
|
+
}: BreadcrumbProps = $props()
|
|
15
17
|
|
|
16
18
|
const classes = classNames([
|
|
17
19
|
styles.breadcrumb,
|
|
@@ -36,9 +38,9 @@
|
|
|
36
38
|
{/if}
|
|
37
39
|
</ConditionalWrapper>
|
|
38
40
|
</li>
|
|
39
|
-
{#if index < items.length - 1
|
|
41
|
+
{#if index < items.length - 1}
|
|
40
42
|
<li>
|
|
41
|
-
{@html separator ||
|
|
43
|
+
{@html separator || ChevronRight}
|
|
42
44
|
</li>
|
|
43
45
|
{/if}
|
|
44
46
|
{/each}
|
|
@@ -5,7 +5,7 @@ import ConditionalWrapper from '../ConditionalWrapper/ConditionalWrapper.tsx'
|
|
|
5
5
|
|
|
6
6
|
import { classNames } from '../../utils/classNames'
|
|
7
7
|
|
|
8
|
-
import
|
|
8
|
+
import ChevronRight from '../../icons/chevron-right.svg?raw'
|
|
9
9
|
|
|
10
10
|
import styles from './breadcrumb.module.scss'
|
|
11
11
|
|
|
@@ -38,7 +38,7 @@ const Breadcrumb = ({
|
|
|
38
38
|
<li>
|
|
39
39
|
{separator
|
|
40
40
|
? separator
|
|
41
|
-
: <span dangerouslySetInnerHTML={{ __html:
|
|
41
|
+
: <span dangerouslySetInnerHTML={{ __html: ChevronRight }} />
|
|
42
42
|
}
|
|
43
43
|
</li>
|
|
44
44
|
)}
|
|
@@ -5,10 +5,14 @@
|
|
|
5
5
|
|
|
6
6
|
import styles from './button.module.scss'
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
const {
|
|
9
|
+
theme,
|
|
10
|
+
href,
|
|
11
|
+
className,
|
|
12
|
+
onClick,
|
|
13
|
+
children,
|
|
14
|
+
...rest
|
|
15
|
+
}: SvelteButtonProps = $props()
|
|
12
16
|
|
|
13
17
|
const classes = classNames([
|
|
14
18
|
styles.button,
|
|
@@ -19,11 +23,11 @@
|
|
|
19
23
|
|
|
20
24
|
|
|
21
25
|
{#if href}
|
|
22
|
-
<a {
|
|
23
|
-
|
|
26
|
+
<a {...rest} href={href} class={classes}>
|
|
27
|
+
{@render children?.()}
|
|
24
28
|
</a>
|
|
25
29
|
{:else}
|
|
26
|
-
<button {
|
|
27
|
-
|
|
30
|
+
<button {...rest} class={classes} onclick={onClick}>
|
|
31
|
+
{@render children?.()}
|
|
28
32
|
</button>
|
|
29
33
|
{/if}
|
|
@@ -21,14 +21,14 @@ const Button = ({
|
|
|
21
21
|
|
|
22
22
|
if (href) {
|
|
23
23
|
return (
|
|
24
|
-
<a {...rest} href={href} className={classes
|
|
24
|
+
<a {...rest} href={href} className={classes}>
|
|
25
25
|
{children}
|
|
26
26
|
</a>
|
|
27
27
|
)
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
return (
|
|
31
|
-
<button {...rest} className={classes
|
|
31
|
+
<button {...rest} className={classes} onClick={onClick}>
|
|
32
32
|
{children}
|
|
33
33
|
</button>
|
|
34
34
|
)
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte'
|
|
1
2
|
import type { MouseEventHandler } from 'svelte/elements'
|
|
2
3
|
|
|
3
4
|
export type ButtonProps = {
|
|
@@ -8,15 +9,12 @@ export type ButtonProps = {
|
|
|
8
9
|
| 'success'
|
|
9
10
|
| 'warning'
|
|
10
11
|
| 'alert'
|
|
11
|
-
| null
|
|
12
|
-
| undefined
|
|
13
12
|
target?: '_self'
|
|
14
13
|
| '_blank'
|
|
15
14
|
| '_parent'
|
|
16
15
|
| '_top'
|
|
17
16
|
| '_unfencedTop'
|
|
18
17
|
| ''
|
|
19
|
-
| undefined
|
|
20
18
|
href?: string
|
|
21
19
|
className?: string
|
|
22
20
|
[key: string]: any
|
|
@@ -24,6 +22,7 @@ export type ButtonProps = {
|
|
|
24
22
|
|
|
25
23
|
export type SvelteButtonProps = {
|
|
26
24
|
onClick?: MouseEventHandler<HTMLButtonElement>
|
|
25
|
+
children: Snippet
|
|
27
26
|
} & ButtonProps
|
|
28
27
|
|
|
29
28
|
export type ReactButtonProps = {
|
|
@@ -1,17 +1,21 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import type {
|
|
2
|
+
import type { SvelteCardProps } from './card'
|
|
3
3
|
|
|
4
4
|
import { classNames } from '../../utils/classNames'
|
|
5
5
|
|
|
6
6
|
import styles from './card.module.scss'
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
8
|
+
const {
|
|
9
|
+
element = 'section',
|
|
10
|
+
title,
|
|
11
|
+
titleTag = 'span',
|
|
12
|
+
compact,
|
|
13
|
+
className,
|
|
14
|
+
bodyClassName,
|
|
15
|
+
secondary,
|
|
16
|
+
children,
|
|
17
|
+
...rest
|
|
18
|
+
}: SvelteCardProps = $props()
|
|
15
19
|
|
|
16
20
|
const classes = classNames([
|
|
17
21
|
styles.card,
|
|
@@ -26,13 +30,13 @@
|
|
|
26
30
|
])
|
|
27
31
|
</script>
|
|
28
32
|
|
|
29
|
-
<svelte:element this={element} class={classes} {
|
|
33
|
+
<svelte:element this={element} class={classes} {...rest}>
|
|
30
34
|
{#if title}
|
|
31
35
|
<svelte:element this={titleTag} class={styles.title}>
|
|
32
36
|
{title}
|
|
33
37
|
</svelte:element>
|
|
34
38
|
{/if}
|
|
35
39
|
<div class={bodyClasses}>
|
|
36
|
-
|
|
40
|
+
{@render children?.()}
|
|
37
41
|
</div>
|
|
38
42
|
</svelte:element>
|
package/components/Card/card.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte'
|
|
2
|
+
|
|
1
3
|
export type CardProps = {
|
|
2
4
|
element?: string
|
|
3
5
|
title?: string
|
|
@@ -9,6 +11,10 @@ export type CardProps = {
|
|
|
9
11
|
[key: string]: any
|
|
10
12
|
}
|
|
11
13
|
|
|
14
|
+
export type SvelteCardProps = {
|
|
15
|
+
children: Snippet
|
|
16
|
+
} & CardProps
|
|
17
|
+
|
|
12
18
|
export type ReactCardProps = {
|
|
13
19
|
Element?: keyof JSX.IntrinsicElements
|
|
14
20
|
TitleTag?: keyof JSX.IntrinsicElements
|
|
@@ -102,53 +102,55 @@ const style = itemsPerSlide > 1
|
|
|
102
102
|
import { debounce } from '../../utils/debounce'
|
|
103
103
|
import { listen } from '../../utils/event'
|
|
104
104
|
|
|
105
|
-
const
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
const
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
105
|
+
const addEventListeners = () => {
|
|
106
|
+
const carousels = Array.from(document.querySelectorAll('[data-id="w-carousel"]'))
|
|
107
|
+
|
|
108
|
+
const scroll = (event: Event) => {
|
|
109
|
+
const target = event.target as HTMLDivElement
|
|
110
|
+
|
|
111
|
+
if (!target.dataset.paginated) {
|
|
112
|
+
const scrollLeft = target.scrollLeft
|
|
113
|
+
const itemWidth = target.children[0].clientWidth
|
|
114
|
+
const page = Math.round(scrollLeft / itemWidth) + 1
|
|
115
|
+
const carouselElement = target.children[0]
|
|
116
|
+
const paginationElement = target.parentElement
|
|
117
|
+
?.querySelector('[data-id="w-pagination"]') as HTMLUListElement
|
|
118
|
+
const currentPage = Number(paginationElement.dataset.currentPage)
|
|
119
|
+
const diff = Math.abs(currentPage - page)
|
|
120
|
+
|
|
121
|
+
let triggerButton = currentPage > page
|
|
122
|
+
? paginationElement.querySelector('[data-page="prev"]') as HTMLButtonElement
|
|
123
|
+
: paginationElement.querySelector('[data-page="next"]') as HTMLButtonElement
|
|
124
|
+
|
|
125
|
+
if (!triggerButton) {
|
|
126
|
+
triggerButton = paginationElement.querySelector(`[data-page="${page}"]`) as HTMLButtonElement
|
|
127
|
+
}
|
|
127
128
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
129
|
+
for (let i = 0; i < diff; i++) {
|
|
130
|
+
triggerButton.click()
|
|
131
|
+
}
|
|
131
132
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
133
|
+
Array.from(carouselElement.children).forEach(li => {
|
|
134
|
+
(li as HTMLLIElement).removeAttribute('data-active')
|
|
135
|
+
})
|
|
135
136
|
|
|
136
|
-
|
|
137
|
+
const activeElement = carouselElement.children[page - 1] as HTMLLIElement
|
|
137
138
|
|
|
138
|
-
|
|
139
|
+
activeElement.dataset.active = 'true'
|
|
140
|
+
}
|
|
139
141
|
}
|
|
140
|
-
}
|
|
141
142
|
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
143
|
+
carousels.forEach(carousel => {
|
|
144
|
+
const carouselElement = carousel as HTMLDivElement
|
|
145
|
+
const debounceAmount = carouselElement.dataset.debounce
|
|
146
|
+
? Number(carouselElement.dataset.debounce)
|
|
147
|
+
: 20
|
|
147
148
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
149
|
+
carousel.addEventListener('scroll', debounce((event: Event) => {
|
|
150
|
+
scroll(event)
|
|
151
|
+
}, debounceAmount))
|
|
152
|
+
})
|
|
153
|
+
}
|
|
152
154
|
|
|
153
155
|
listen('paginate', event => {
|
|
154
156
|
const target = event.target
|
|
@@ -172,7 +174,7 @@ const style = itemsPerSlide > 1
|
|
|
172
174
|
: indexes[event.page - 1][indexes[event.page - 1].length - 1]
|
|
173
175
|
|
|
174
176
|
const liElement = carousel.children[pageIndex]
|
|
175
|
-
const subText = event.target.
|
|
177
|
+
const subText = event.target.parentElement.querySelector('span')
|
|
176
178
|
|
|
177
179
|
Array.from(carousel.children).forEach(li => {
|
|
178
180
|
(li as HTMLLIElement).removeAttribute('data-active')
|
|
@@ -204,4 +206,7 @@ const style = itemsPerSlide > 1
|
|
|
204
206
|
}, 300)
|
|
205
207
|
}
|
|
206
208
|
})
|
|
209
|
+
|
|
210
|
+
document.addEventListener('astro:after-swap', addEventListeners)
|
|
211
|
+
addEventListeners()
|
|
207
212
|
</script>
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte'
|
|
2
|
+
|
|
1
3
|
import type { PaginationProps } from '../Pagination/pagination'
|
|
2
4
|
|
|
3
5
|
export type CarouselProps = {
|
|
@@ -18,6 +20,7 @@ export type CarouselProps = {
|
|
|
18
20
|
|
|
19
21
|
export type SvelteCarouselProps = {
|
|
20
22
|
onScroll?: (event: number) => void
|
|
23
|
+
children: Snippet
|
|
21
24
|
} & CarouselProps
|
|
22
25
|
|
|
23
26
|
export type ReactCarouselProps = {
|
|
@@ -15,7 +15,8 @@ const {
|
|
|
15
15
|
subText,
|
|
16
16
|
disabled,
|
|
17
17
|
color,
|
|
18
|
-
className
|
|
18
|
+
className,
|
|
19
|
+
...rest
|
|
19
20
|
} = Astro.props
|
|
20
21
|
|
|
21
22
|
const classes = [
|
|
@@ -34,7 +35,12 @@ const style = color
|
|
|
34
35
|
<div class={styles.wrapper} slot="wrapper">
|
|
35
36
|
children
|
|
36
37
|
</div>
|
|
37
|
-
<input
|
|
38
|
+
<input
|
|
39
|
+
type="checkbox"
|
|
40
|
+
checked={checked}
|
|
41
|
+
disabled={disabled}
|
|
42
|
+
{...rest}
|
|
43
|
+
/>
|
|
38
44
|
<span class={styles.check}>
|
|
39
45
|
<Fragment set:html={check} />
|
|
40
46
|
</span>
|