webcoreui 0.0.10 → 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.
- package/README.md +35 -7
- package/astro.d.ts +8 -0
- package/astro.js +8 -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.scss → accordion.module.scss} +18 -10
- 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 +54 -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} +2 -2
- 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 +89 -0
- package/components/Badge/badge.ts +8 -1
- package/components/Button/Button.astro +10 -6
- package/components/Button/Button.svelte +15 -11
- package/components/Button/Button.tsx +11 -7
- package/components/Button/button.module.scss +94 -0
- package/components/Button/button.ts +6 -1
- 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 +33 -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.scss → checkbox.module.scss} +16 -17
- package/components/Checkbox/checkbox.ts +5 -1
- package/components/ConditionalWrapper/ConditionalWrapper.svelte +1 -1
- 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 -0
- package/components/Input/Input.svelte +52 -0
- package/components/Input/Input.tsx +59 -0
- package/components/Input/input.module.scss +87 -0
- package/components/Input/input.ts +50 -0
- 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 +144 -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.scss → progress.module.scss} +66 -66
- 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.scss → radio.module.scss} +92 -92
- 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.scss → rating.module.scss} +10 -9
- 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} +41 -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.scss → switch.module.scss} +4 -4
- package/components/Switch/switch.ts +8 -4
- package/components/Table/Table.astro +60 -0
- package/components/Table/Table.svelte +56 -0
- package/components/Table/Table.tsx +64 -0
- package/components/Table/table.module.scss +64 -0
- package/components/Table/table.ts +10 -0
- package/components/Tabs/Tabs.astro +77 -76
- package/components/Tabs/Tabs.svelte +56 -54
- package/components/Tabs/Tabs.tsx +70 -69
- package/components/Tabs/{tabs.scss → tabs.module.scss} +30 -31
- 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 +74 -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} +71 -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.scss → timelineitem.module.scss} +31 -31
- 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.scss → toast.module.scss} +44 -43
- package/components/Toast/toast.ts +3 -6
- package/icons/moon.svg +3 -0
- package/icons/sun.svg +3 -0
- package/index.js +3 -0
- package/package.json +3 -1
- package/react.d.ts +8 -0
- package/react.js +8 -0
- package/scss/global/elements.scss +1 -1
- package/scss/global/scrollbar.scss +21 -0
- package/scss/global/theme.scss +140 -0
- package/scss/global/tooltip.scss +8 -5
- package/scss/global/utility.scss +29 -0
- package/scss/global.scss +2 -0
- package/scss/resets.scss +5 -5
- package/scss/setup.scss +39 -18
- package/svelte.d.ts +18 -10
- package/svelte.js +8 -0
- package/utils/classNames.ts +4 -0
- package/utils/cookies.ts +28 -0
- package/utils/event.ts +17 -0
- package/utils/toast.ts +12 -9
- 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
|
@@ -1,44 +1,45 @@
|
|
|
1
|
-
import React from 'react'
|
|
2
|
-
import type { SpinnerProps } from './spinner'
|
|
3
|
-
|
|
4
|
-
import './spinner.scss'
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
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
|
-
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import type { SpinnerProps } from './spinner'
|
|
3
|
+
|
|
4
|
+
import styles from './spinner.module.scss'
|
|
5
|
+
import { classNames } from '../../utils/classNames'
|
|
6
|
+
|
|
7
|
+
const Spinner = ({
|
|
8
|
+
color,
|
|
9
|
+
width,
|
|
10
|
+
speed,
|
|
11
|
+
size,
|
|
12
|
+
dashArray
|
|
13
|
+
}: SpinnerProps) => {
|
|
14
|
+
const classes = classNames([
|
|
15
|
+
styles.spinner,
|
|
16
|
+
dashArray && styles.dashed
|
|
17
|
+
])
|
|
18
|
+
|
|
19
|
+
const stylesVariable = {
|
|
20
|
+
...(color && { '--w-spinner-color': color }),
|
|
21
|
+
...(width && { '--w-spinner-width': `${width}px;` }),
|
|
22
|
+
...(speed && { '--w-spinner-speed': `${speed}s;` }),
|
|
23
|
+
...(size && { '--w-spinner-size': `${size}px;` }),
|
|
24
|
+
...(dashArray && { '--w-spinner-dash': dashArray }),
|
|
25
|
+
} as React.CSSProperties
|
|
26
|
+
|
|
27
|
+
return (
|
|
28
|
+
<svg
|
|
29
|
+
className={classes}
|
|
30
|
+
viewBox="25 25 50 50"
|
|
31
|
+
role="status"
|
|
32
|
+
style={stylesVariable}
|
|
33
|
+
>
|
|
34
|
+
<circle
|
|
35
|
+
className={styles.path}
|
|
36
|
+
cx="50"
|
|
37
|
+
cy="50"
|
|
38
|
+
r="20"
|
|
39
|
+
fill="none"
|
|
40
|
+
/>
|
|
41
|
+
</svg>
|
|
42
|
+
)
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export default Spinner
|
|
@@ -1,41 +1,41 @@
|
|
|
1
|
-
@import '../../scss/config.scss';
|
|
2
|
-
|
|
3
|
-
.
|
|
4
|
-
margin: 0px auto;
|
|
5
|
-
width: var(--w-spinner-size);
|
|
6
|
-
height: var(--w-spinner-size);
|
|
7
|
-
animation: rotate var(--w-spinner-speed) linear infinite;
|
|
8
|
-
|
|
9
|
-
&.dashed .
|
|
10
|
-
stroke-dasharray: var(--w-spinner-dash);
|
|
11
|
-
animation: none;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
.
|
|
15
|
-
stroke: var(--w-spinner-color);
|
|
16
|
-
stroke-width: var(--w-spinner-width);
|
|
17
|
-
animation: dash 1.5s ease-in-out infinite;
|
|
18
|
-
stroke-linecap: round;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
@keyframes rotate {
|
|
23
|
-
100% {
|
|
24
|
-
transform: rotate(360deg);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
@keyframes dash {
|
|
29
|
-
0% {
|
|
30
|
-
stroke-dasharray: 1, 200;
|
|
31
|
-
stroke-dashoffset: 0;
|
|
32
|
-
}
|
|
33
|
-
50% {
|
|
34
|
-
stroke-dasharray: 89, 200;
|
|
35
|
-
stroke-dashoffset: -35;
|
|
36
|
-
}
|
|
37
|
-
100% {
|
|
38
|
-
stroke-dasharray: 89, 200;
|
|
39
|
-
stroke-dashoffset: -124;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
1
|
+
@import '../../scss/config.scss';
|
|
2
|
+
|
|
3
|
+
.spinner {
|
|
4
|
+
margin: 0px auto;
|
|
5
|
+
width: var(--w-spinner-size);
|
|
6
|
+
height: var(--w-spinner-size);
|
|
7
|
+
animation: rotate var(--w-spinner-speed) linear infinite;
|
|
8
|
+
|
|
9
|
+
&.dashed .path {
|
|
10
|
+
stroke-dasharray: var(--w-spinner-dash);
|
|
11
|
+
animation: none;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.path {
|
|
15
|
+
stroke: var(--w-spinner-color);
|
|
16
|
+
stroke-width: var(--w-spinner-width);
|
|
17
|
+
animation: dash 1.5s ease-in-out infinite;
|
|
18
|
+
stroke-linecap: round;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
@keyframes rotate {
|
|
23
|
+
100% {
|
|
24
|
+
transform: rotate(360deg);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
@keyframes dash {
|
|
29
|
+
0% {
|
|
30
|
+
stroke-dasharray: 1, 200;
|
|
31
|
+
stroke-dashoffset: 0;
|
|
32
|
+
}
|
|
33
|
+
50% {
|
|
34
|
+
stroke-dasharray: 89, 200;
|
|
35
|
+
stroke-dashoffset: -35;
|
|
36
|
+
}
|
|
37
|
+
100% {
|
|
38
|
+
stroke-dasharray: 89, 200;
|
|
39
|
+
stroke-dashoffset: -124;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
---
|
|
2
2
|
import type { SwitchProps } from './switch'
|
|
3
|
-
|
|
3
|
+
|
|
4
|
+
import styles from './switch.module.scss'
|
|
5
|
+
import { classNames } from '../../utils/classNames'
|
|
4
6
|
|
|
5
7
|
interface Props extends SwitchProps {}
|
|
6
8
|
|
|
@@ -17,22 +19,22 @@ const {
|
|
|
17
19
|
} = Astro.props
|
|
18
20
|
|
|
19
21
|
const classes = [
|
|
20
|
-
|
|
21
|
-
reverse &&
|
|
22
|
-
small &&
|
|
23
|
-
square &&
|
|
24
|
-
disabled &&
|
|
22
|
+
styles.switch,
|
|
23
|
+
reverse && styles.reverse,
|
|
24
|
+
small && styles.small,
|
|
25
|
+
square && styles.square,
|
|
26
|
+
disabled && styles.disabled,
|
|
25
27
|
className
|
|
26
28
|
]
|
|
27
29
|
|
|
28
|
-
const
|
|
30
|
+
const styleVariables = classNames([
|
|
29
31
|
offColor && `--w-switch-off-color: ${offColor};`,
|
|
30
32
|
onColor && `--w-switch-on-color: ${onColor};`
|
|
31
|
-
]
|
|
33
|
+
])
|
|
32
34
|
---
|
|
33
35
|
|
|
34
|
-
<label class:list={classes} style={
|
|
36
|
+
<label class:list={classes} style={styleVariables}>
|
|
35
37
|
<input type="checkbox" checked={toggled} disabled={disabled} />
|
|
36
|
-
<span class=
|
|
37
|
-
{label && <span class=
|
|
38
|
+
<span class={styles.toggle}></span>
|
|
39
|
+
{label && <span class={styles.label}>{label}</span>}
|
|
38
40
|
</label>
|
|
@@ -1,42 +1,44 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import type {
|
|
3
|
-
|
|
2
|
+
import type { SvelteSwitchProps } from './switch'
|
|
3
|
+
|
|
4
|
+
import styles from './switch.module.scss'
|
|
5
|
+
import { classNames } from '../../utils/classNames'
|
|
4
6
|
|
|
5
|
-
export let label:
|
|
6
|
-
export let toggled:
|
|
7
|
-
export let offColor:
|
|
8
|
-
export let onColor:
|
|
9
|
-
export let reverse:
|
|
10
|
-
export let small:
|
|
11
|
-
export let square:
|
|
12
|
-
export let disabled:
|
|
13
|
-
export let className:
|
|
14
|
-
export let onClick:
|
|
7
|
+
export let label: SvelteSwitchProps['label'] = ''
|
|
8
|
+
export let toggled: SvelteSwitchProps['toggled'] = false
|
|
9
|
+
export let offColor: SvelteSwitchProps['offColor'] = ''
|
|
10
|
+
export let onColor: SvelteSwitchProps['onColor'] = ''
|
|
11
|
+
export let reverse: SvelteSwitchProps['reverse'] = false
|
|
12
|
+
export let small: SvelteSwitchProps['small'] = false
|
|
13
|
+
export let square: SvelteSwitchProps['square'] = false
|
|
14
|
+
export let disabled: SvelteSwitchProps['disabled'] = false
|
|
15
|
+
export let className: SvelteSwitchProps['className'] = ''
|
|
16
|
+
export let onClick: SvelteSwitchProps['onClick'] = () => {}
|
|
15
17
|
|
|
16
|
-
const classes = [
|
|
17
|
-
|
|
18
|
-
reverse &&
|
|
19
|
-
small &&
|
|
20
|
-
square &&
|
|
21
|
-
disabled &&
|
|
18
|
+
const classes = classNames([
|
|
19
|
+
styles.switch,
|
|
20
|
+
reverse && styles.reverse,
|
|
21
|
+
small && styles.small,
|
|
22
|
+
square && styles.square,
|
|
23
|
+
disabled && styles.disabled,
|
|
22
24
|
className
|
|
23
|
-
]
|
|
25
|
+
])
|
|
24
26
|
|
|
25
|
-
const
|
|
27
|
+
const styleVariables = classNames([
|
|
26
28
|
offColor && `--w-switch-off-color: ${offColor};`,
|
|
27
29
|
onColor && `--w-switch-on-color: ${onColor};`
|
|
28
|
-
]
|
|
30
|
+
])
|
|
29
31
|
</script>
|
|
30
32
|
|
|
31
|
-
<label class={classes} style={
|
|
33
|
+
<label class={classes} style={styleVariables || null}>
|
|
32
34
|
<input
|
|
33
35
|
type="checkbox"
|
|
34
36
|
checked={toggled}
|
|
35
37
|
disabled={disabled}
|
|
36
38
|
on:click={onClick}
|
|
37
39
|
/>
|
|
38
|
-
<span class=
|
|
40
|
+
<span class={styles.toggle}></span>
|
|
39
41
|
{#if label}
|
|
40
|
-
<span class=
|
|
42
|
+
<span class={styles.label}>{label}</span>
|
|
41
43
|
{/if}
|
|
42
44
|
</label>
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
2
|
import type { ReactSwitchProps } from './switch'
|
|
3
|
-
|
|
3
|
+
|
|
4
|
+
import styles from './switch.module.scss'
|
|
5
|
+
import { classNames } from '../../utils/classNames'
|
|
4
6
|
|
|
5
7
|
const Switch = ({
|
|
6
8
|
label,
|
|
@@ -14,30 +16,30 @@ const Switch = ({
|
|
|
14
16
|
className,
|
|
15
17
|
onClick
|
|
16
18
|
}: ReactSwitchProps) => {
|
|
17
|
-
const classes = [
|
|
18
|
-
|
|
19
|
-
reverse &&
|
|
20
|
-
small &&
|
|
21
|
-
square &&
|
|
22
|
-
disabled &&
|
|
19
|
+
const classes = classNames([
|
|
20
|
+
styles.switch,
|
|
21
|
+
reverse && styles.reverse,
|
|
22
|
+
small && styles.small,
|
|
23
|
+
square && styles.square,
|
|
24
|
+
disabled && styles.disabled,
|
|
23
25
|
className
|
|
24
|
-
]
|
|
26
|
+
])
|
|
25
27
|
|
|
26
|
-
const
|
|
28
|
+
const styleVariables = {
|
|
27
29
|
...(offColor && { '--w-switch-off-color': offColor }),
|
|
28
30
|
...(onColor && { '--w-switch-on-color': onColor })
|
|
29
31
|
} as React.CSSProperties
|
|
30
32
|
|
|
31
33
|
return (
|
|
32
|
-
<label className={classes} style={
|
|
34
|
+
<label className={classes} style={styleVariables || null}>
|
|
33
35
|
<input
|
|
34
36
|
type="checkbox"
|
|
35
37
|
defaultChecked={toggled}
|
|
36
38
|
disabled={disabled}
|
|
37
39
|
onClick={onClick}
|
|
38
40
|
/>
|
|
39
|
-
<span className=
|
|
40
|
-
{label && <span className=
|
|
41
|
+
<span className={styles.toggle}></span>
|
|
42
|
+
{label && <span className={styles.label}>{label}</span>}
|
|
41
43
|
</label>
|
|
42
44
|
)
|
|
43
45
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
@import '../../scss/config.scss';
|
|
2
2
|
|
|
3
|
-
.
|
|
3
|
+
.switch {
|
|
4
4
|
display: inline-flex;
|
|
5
5
|
align-items: center;
|
|
6
6
|
gap: 10px;
|
|
@@ -12,10 +12,10 @@
|
|
|
12
12
|
|
|
13
13
|
&.disabled .toggle {
|
|
14
14
|
cursor: no-drop;
|
|
15
|
-
background:
|
|
15
|
+
background: var(--w-color-primary-40);
|
|
16
16
|
|
|
17
17
|
&::before {
|
|
18
|
-
background:
|
|
18
|
+
background: var(--w-color-primary-50);
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
21
|
|
|
@@ -74,7 +74,7 @@
|
|
|
74
74
|
width: 24px;
|
|
75
75
|
left: 3px;
|
|
76
76
|
bottom: 3px;
|
|
77
|
-
background:
|
|
77
|
+
background: var(--w-color-primary-70);
|
|
78
78
|
border-radius: 50%;
|
|
79
79
|
transition: 0.3s;
|
|
80
80
|
}
|
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
export type SwitchProps = {
|
|
2
2
|
label?: string
|
|
3
|
-
toggled?: boolean
|
|
4
|
-
offColor?: string
|
|
5
|
-
onColor?: string
|
|
6
3
|
reverse?: boolean
|
|
4
|
+
toggled?: boolean
|
|
5
|
+
disabled?: boolean
|
|
7
6
|
small?: boolean
|
|
8
7
|
square?: boolean
|
|
9
|
-
|
|
8
|
+
onColor?: string
|
|
9
|
+
offColor?: string
|
|
10
10
|
className?: string
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
+
export type SvelteSwitchProps = {
|
|
14
|
+
onClick?: (key: any) => any
|
|
15
|
+
} & SwitchProps
|
|
16
|
+
|
|
13
17
|
export type ReactSwitchProps = {
|
|
14
18
|
onClick?: (key: any) => any
|
|
15
19
|
} & SwitchProps
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
---
|
|
2
|
+
import type { TableProps } from './table'
|
|
3
|
+
import styles from './table.module.scss'
|
|
4
|
+
|
|
5
|
+
interface Props extends TableProps {}
|
|
6
|
+
|
|
7
|
+
const {
|
|
8
|
+
headings,
|
|
9
|
+
footer,
|
|
10
|
+
data,
|
|
11
|
+
hover,
|
|
12
|
+
striped,
|
|
13
|
+
offsetStripe,
|
|
14
|
+
compact,
|
|
15
|
+
className
|
|
16
|
+
} = Astro.props
|
|
17
|
+
|
|
18
|
+
const classes = [
|
|
19
|
+
styles.table,
|
|
20
|
+
hover && styles.hover,
|
|
21
|
+
striped && styles[`striped-${striped}s`],
|
|
22
|
+
offsetStripe && styles.offset,
|
|
23
|
+
compact && styles.compact,
|
|
24
|
+
className
|
|
25
|
+
]
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
<div class:list={classes}>
|
|
29
|
+
<table>
|
|
30
|
+
{headings?.length && (
|
|
31
|
+
<thead>
|
|
32
|
+
<tr>
|
|
33
|
+
{headings.map(heading => (
|
|
34
|
+
<th>{heading}</th>
|
|
35
|
+
))}
|
|
36
|
+
</tr>
|
|
37
|
+
</thead>
|
|
38
|
+
)}
|
|
39
|
+
<tbody>
|
|
40
|
+
{data.map(row => (
|
|
41
|
+
<tr>
|
|
42
|
+
{row.map(column => (
|
|
43
|
+
<td>
|
|
44
|
+
<Fragment set:html={column} />
|
|
45
|
+
</td>
|
|
46
|
+
))}
|
|
47
|
+
</tr>
|
|
48
|
+
))}
|
|
49
|
+
</tbody>
|
|
50
|
+
{footer?.length && (
|
|
51
|
+
<tfoot>
|
|
52
|
+
<tr>
|
|
53
|
+
{footer.map(data => (
|
|
54
|
+
<td>{data}</td>
|
|
55
|
+
))}
|
|
56
|
+
</tr>
|
|
57
|
+
</tfoot>
|
|
58
|
+
)}
|
|
59
|
+
</table>
|
|
60
|
+
</div>
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { TableProps } from './table'
|
|
3
|
+
|
|
4
|
+
import styles from './table.module.scss'
|
|
5
|
+
import { classNames } from '../../utils/classNames'
|
|
6
|
+
|
|
7
|
+
export let headings: TableProps['headings'] = []
|
|
8
|
+
export let footer: TableProps['footer'] = []
|
|
9
|
+
export let data: TableProps['data'] = []
|
|
10
|
+
export let hover: TableProps['hover'] = false
|
|
11
|
+
export let striped: TableProps['striped'] = null
|
|
12
|
+
export let offsetStripe: TableProps['offsetStripe'] = false
|
|
13
|
+
export let compact: TableProps['compact'] = false
|
|
14
|
+
export let className: TableProps['className'] = ''
|
|
15
|
+
|
|
16
|
+
const classes = classNames([
|
|
17
|
+
styles.table,
|
|
18
|
+
hover && styles.hover,
|
|
19
|
+
striped && styles[`striped-${striped}s`],
|
|
20
|
+
offsetStripe && styles.offset,
|
|
21
|
+
compact && styles.compact,
|
|
22
|
+
className
|
|
23
|
+
])
|
|
24
|
+
</script>
|
|
25
|
+
|
|
26
|
+
<div class={classes}>
|
|
27
|
+
<table>
|
|
28
|
+
{#if headings?.length}
|
|
29
|
+
<thead>
|
|
30
|
+
<tr>
|
|
31
|
+
{#each headings as heading}
|
|
32
|
+
<th>{heading}</th>
|
|
33
|
+
{/each}
|
|
34
|
+
</tr>
|
|
35
|
+
</thead>
|
|
36
|
+
{/if}
|
|
37
|
+
<tbody>
|
|
38
|
+
{#each data as row}
|
|
39
|
+
<tr>
|
|
40
|
+
{#each row as column}
|
|
41
|
+
<td>{@html column}</td>
|
|
42
|
+
{/each}
|
|
43
|
+
</tr>
|
|
44
|
+
{/each}
|
|
45
|
+
</tbody>
|
|
46
|
+
{#if footer?.length}
|
|
47
|
+
<tfoot>
|
|
48
|
+
<tr>
|
|
49
|
+
{#each footer as data}
|
|
50
|
+
<td>{data}</td>
|
|
51
|
+
{/each}
|
|
52
|
+
</tr>
|
|
53
|
+
</tfoot>
|
|
54
|
+
{/if}
|
|
55
|
+
</table>
|
|
56
|
+
</div>
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import type { TableProps } from './table'
|
|
3
|
+
|
|
4
|
+
import styles from './table.module.scss'
|
|
5
|
+
import { classNames } from '../../utils/classNames'
|
|
6
|
+
|
|
7
|
+
const Table = ({
|
|
8
|
+
headings,
|
|
9
|
+
footer,
|
|
10
|
+
data,
|
|
11
|
+
hover,
|
|
12
|
+
striped,
|
|
13
|
+
offsetStripe,
|
|
14
|
+
compact,
|
|
15
|
+
className
|
|
16
|
+
}: TableProps) => {
|
|
17
|
+
const classes = classNames([
|
|
18
|
+
styles.table,
|
|
19
|
+
hover && styles.hover,
|
|
20
|
+
striped && styles[`striped-${striped}s`],
|
|
21
|
+
offsetStripe && styles.offset,
|
|
22
|
+
compact && styles.compact,
|
|
23
|
+
className
|
|
24
|
+
])
|
|
25
|
+
|
|
26
|
+
return (
|
|
27
|
+
<div className={classes}>
|
|
28
|
+
<table>
|
|
29
|
+
{headings?.length && (
|
|
30
|
+
<thead>
|
|
31
|
+
<tr>
|
|
32
|
+
{headings.map((heading, index) => (
|
|
33
|
+
<th key={index}>{heading}</th>
|
|
34
|
+
))}
|
|
35
|
+
</tr>
|
|
36
|
+
</thead>
|
|
37
|
+
)}
|
|
38
|
+
<tbody>
|
|
39
|
+
{data.map((row, rowIndex) => (
|
|
40
|
+
<tr key={rowIndex}>
|
|
41
|
+
{row.map((column, columnIndex) => (
|
|
42
|
+
<td
|
|
43
|
+
key={columnIndex}
|
|
44
|
+
dangerouslySetInnerHTML={{ __html: column }}
|
|
45
|
+
/>
|
|
46
|
+
))}
|
|
47
|
+
</tr>
|
|
48
|
+
))}
|
|
49
|
+
</tbody>
|
|
50
|
+
{footer?.length && (
|
|
51
|
+
<tfoot>
|
|
52
|
+
<tr>
|
|
53
|
+
{footer.map((data, index) => (
|
|
54
|
+
<td key={index}>{data}</td>
|
|
55
|
+
))}
|
|
56
|
+
</tr>
|
|
57
|
+
</tfoot>
|
|
58
|
+
)}
|
|
59
|
+
</table>
|
|
60
|
+
</div>
|
|
61
|
+
)
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export default Table
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
@import '../../scss/config.scss';
|
|
2
|
+
|
|
3
|
+
.table {
|
|
4
|
+
overflow-x: auto;
|
|
5
|
+
|
|
6
|
+
table {
|
|
7
|
+
width: 100%;
|
|
8
|
+
border-collapse: collapse;
|
|
9
|
+
text-align: left;
|
|
10
|
+
font-size: 16px;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
thead,
|
|
14
|
+
tfoot {
|
|
15
|
+
font-family: Bold;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
th,
|
|
19
|
+
td {
|
|
20
|
+
padding: 5px 10px;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
thead,
|
|
24
|
+
tr {
|
|
25
|
+
border-bottom: 1px solid var(--w-color-primary-50);
|
|
26
|
+
|
|
27
|
+
&:last-child {
|
|
28
|
+
border-bottom: 0;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
a {
|
|
33
|
+
text-decoration: underline;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
tfoot,
|
|
37
|
+
&.hover tr:hover,
|
|
38
|
+
&.striped-rows tbody tr:nth-child(odd),
|
|
39
|
+
&.striped-rows.offset tbody tr:nth-child(even),
|
|
40
|
+
&.striped-columns td:nth-child(odd),
|
|
41
|
+
&.striped-columns.offset td:nth-child(even),
|
|
42
|
+
&.hover.striped-rows.offset tbody tr:nth-child(odd):hover {
|
|
43
|
+
background: var(--w-color-primary-60);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
&.striped-rows tr,
|
|
47
|
+
&.striped-columns tr,
|
|
48
|
+
&.striped-columns thead {
|
|
49
|
+
border-bottom: 0;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
&.striped-rows.offset tbody tr:nth-child(odd),
|
|
53
|
+
&.striped-rows.offset tfoot,
|
|
54
|
+
&.striped-columns.offset td:nth-child(odd),
|
|
55
|
+
&.striped-columns tfoot {
|
|
56
|
+
background: transparent;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
&.compact {
|
|
60
|
+
th, td {
|
|
61
|
+
padding: 3px 10px;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|