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
|
@@ -1,54 +1,56 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import type { TableProps } from './table'
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export let
|
|
8
|
-
export let
|
|
9
|
-
export let
|
|
10
|
-
export let
|
|
11
|
-
export let
|
|
12
|
-
export let
|
|
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
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
{
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
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>
|
|
@@ -1,63 +1,64 @@
|
|
|
1
|
-
import React from 'react'
|
|
2
|
-
import type { TableProps } from './table'
|
|
3
|
-
|
|
4
|
-
import './table.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
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
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
|
|
@@ -1,65 +1,60 @@
|
|
|
1
|
-
@
|
|
2
|
-
|
|
3
|
-
.
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
table {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
thead,
|
|
14
|
-
tfoot {
|
|
15
|
-
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
th,
|
|
19
|
-
td {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
&.hover tr:hover
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
&.striped-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
&.striped-
|
|
49
|
-
&.striped-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
&.
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
th, td {
|
|
62
|
-
padding: 3px 10px;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
}
|
|
1
|
+
@use '../../scss/config.scss' as *;
|
|
2
|
+
|
|
3
|
+
.table {
|
|
4
|
+
@include visibility(auto);
|
|
5
|
+
|
|
6
|
+
table {
|
|
7
|
+
@include size('w100%');
|
|
8
|
+
@include typography(md, left);
|
|
9
|
+
|
|
10
|
+
border-collapse: collapse;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
thead,
|
|
14
|
+
tfoot {
|
|
15
|
+
@include typography(bold);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
th,
|
|
19
|
+
td {
|
|
20
|
+
@include spacing(py-xs, px-sm);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
thead,
|
|
24
|
+
tr {
|
|
25
|
+
@include border(bottom, primary-50);
|
|
26
|
+
|
|
27
|
+
&:last-child {
|
|
28
|
+
@include border(bottom, 0);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
tfoot,
|
|
33
|
+
&.hover tr:hover,
|
|
34
|
+
&.striped-rows tbody tr:nth-child(odd),
|
|
35
|
+
&.striped-rows.offset tbody tr:nth-child(even),
|
|
36
|
+
&.striped-columns td:nth-child(odd),
|
|
37
|
+
&.striped-columns.offset td:nth-child(even),
|
|
38
|
+
&.hover.striped-rows.offset tbody tr:nth-child(odd):hover {
|
|
39
|
+
@include background(primary-60);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
&.striped-rows tr,
|
|
43
|
+
&.striped-columns tr,
|
|
44
|
+
&.striped-columns thead {
|
|
45
|
+
@include border(bottom, 0);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
&.striped-rows.offset tbody tr:nth-child(odd),
|
|
49
|
+
&.striped-rows.offset tfoot,
|
|
50
|
+
&.striped-columns.offset td:nth-child(odd),
|
|
51
|
+
&.striped-columns tfoot {
|
|
52
|
+
@include background(transparent);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
&.compact {
|
|
56
|
+
th, td {
|
|
57
|
+
@include spacing(py-xxs, px-sm);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
@@ -1,76 +1,76 @@
|
|
|
1
|
-
---
|
|
2
|
-
import type { TabsProps } from './tabs'
|
|
3
|
-
import './tabs.scss'
|
|
4
|
-
|
|
5
|
-
interface Props extends TabsProps {}
|
|
6
|
-
|
|
7
|
-
const {
|
|
8
|
-
items,
|
|
9
|
-
theme,
|
|
10
|
-
vertical,
|
|
11
|
-
even,
|
|
12
|
-
className
|
|
13
|
-
} = Astro.props
|
|
14
|
-
|
|
15
|
-
const classes = [
|
|
16
|
-
|
|
17
|
-
theme && theme,
|
|
18
|
-
vertical &&
|
|
19
|
-
even &&
|
|
20
|
-
className
|
|
21
|
-
]
|
|
22
|
-
---
|
|
23
|
-
|
|
24
|
-
<section class:list={classes} data-id="w-tabs">
|
|
25
|
-
<div class=
|
|
26
|
-
<div class=
|
|
27
|
-
{items.map(item => (
|
|
28
|
-
<button
|
|
29
|
-
data-value={item.value}
|
|
30
|
-
|
|
31
|
-
disabled={item.disabled}
|
|
32
|
-
>
|
|
33
|
-
<Fragment set:html={item.label} />
|
|
34
|
-
</button>
|
|
35
|
-
))}
|
|
36
|
-
</div>
|
|
37
|
-
</div>
|
|
38
|
-
<div class=
|
|
39
|
-
<slot />
|
|
40
|
-
</div>
|
|
41
|
-
</section>
|
|
42
|
-
|
|
43
|
-
<script>
|
|
44
|
-
const tabs = document.querySelectorAll('[data-id="w-tabs"]')
|
|
45
|
-
|
|
46
|
-
Array.from(tabs).forEach(element => {
|
|
47
|
-
element.addEventListener('click', event => {
|
|
48
|
-
const target = event.target as HTMLDivElement
|
|
49
|
-
|
|
50
|
-
if (target.dataset.value) {
|
|
51
|
-
const tabContent = target.parentElement
|
|
52
|
-
?.parentElement
|
|
53
|
-
?.nextElementSibling as HTMLDivElement
|
|
54
|
-
|
|
55
|
-
Array.from(tabContent.children)
|
|
56
|
-
.forEach((element: any) => {
|
|
57
|
-
if (element.dataset.tab === target.dataset.value) {
|
|
58
|
-
element.dataset.active = true
|
|
59
|
-
} else {
|
|
60
|
-
element.dataset.active = false
|
|
61
|
-
}
|
|
62
|
-
})
|
|
63
|
-
|
|
64
|
-
const tabs = target.parentElement?.querySelectorAll('button') as NodeListOf<HTMLButtonElement>
|
|
65
|
-
|
|
66
|
-
Array.from(tabs).forEach((tab: any) => {
|
|
67
|
-
tab.
|
|
68
|
-
|
|
69
|
-
if (tab.dataset.value === target.dataset.value) {
|
|
70
|
-
tab.
|
|
71
|
-
}
|
|
72
|
-
})
|
|
73
|
-
}
|
|
74
|
-
})
|
|
75
|
-
})
|
|
76
|
-
</script>
|
|
1
|
+
---
|
|
2
|
+
import type { TabsProps } from './tabs'
|
|
3
|
+
import styles from './tabs.module.scss'
|
|
4
|
+
|
|
5
|
+
interface Props extends TabsProps {}
|
|
6
|
+
|
|
7
|
+
const {
|
|
8
|
+
items,
|
|
9
|
+
theme,
|
|
10
|
+
vertical,
|
|
11
|
+
even,
|
|
12
|
+
className
|
|
13
|
+
} = Astro.props
|
|
14
|
+
|
|
15
|
+
const classes = [
|
|
16
|
+
styles.tabs,
|
|
17
|
+
theme && styles[theme],
|
|
18
|
+
vertical && styles.vertical,
|
|
19
|
+
even && styles.even,
|
|
20
|
+
className
|
|
21
|
+
]
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
<section class:list={classes} data-id="w-tabs">
|
|
25
|
+
<div class={styles.wrapper}>
|
|
26
|
+
<div class={styles.items}>
|
|
27
|
+
{items.map(item => (
|
|
28
|
+
<button
|
|
29
|
+
data-value={item.value}
|
|
30
|
+
data-active={item.active ? 'true' : null}
|
|
31
|
+
disabled={item.disabled}
|
|
32
|
+
>
|
|
33
|
+
<Fragment set:html={item.label} />
|
|
34
|
+
</button>
|
|
35
|
+
))}
|
|
36
|
+
</div>
|
|
37
|
+
</div>
|
|
38
|
+
<div class={styles.content}>
|
|
39
|
+
<slot />
|
|
40
|
+
</div>
|
|
41
|
+
</section>
|
|
42
|
+
|
|
43
|
+
<script>
|
|
44
|
+
const tabs = document.querySelectorAll('[data-id="w-tabs"]')
|
|
45
|
+
|
|
46
|
+
Array.from(tabs).forEach(element => {
|
|
47
|
+
element.addEventListener('click', event => {
|
|
48
|
+
const target = event.target as HTMLDivElement
|
|
49
|
+
|
|
50
|
+
if (target.dataset.value) {
|
|
51
|
+
const tabContent = target.parentElement
|
|
52
|
+
?.parentElement
|
|
53
|
+
?.nextElementSibling as HTMLDivElement
|
|
54
|
+
|
|
55
|
+
Array.from(tabContent.children)
|
|
56
|
+
.forEach((element: any) => {
|
|
57
|
+
if (element.dataset.tab === target.dataset.value) {
|
|
58
|
+
element.dataset.active = true
|
|
59
|
+
} else {
|
|
60
|
+
element.dataset.active = false
|
|
61
|
+
}
|
|
62
|
+
})
|
|
63
|
+
|
|
64
|
+
const tabs = target.parentElement?.querySelectorAll('button') as NodeListOf<HTMLButtonElement>
|
|
65
|
+
|
|
66
|
+
Array.from(tabs).forEach((tab: any) => {
|
|
67
|
+
tab.dataset.active = 'false'
|
|
68
|
+
|
|
69
|
+
if (tab.dataset.value === target.dataset.value) {
|
|
70
|
+
tab.dataset.active = 'true'
|
|
71
|
+
}
|
|
72
|
+
})
|
|
73
|
+
}
|
|
74
|
+
})
|
|
75
|
+
})
|
|
76
|
+
</script>
|
|
@@ -1,54 +1,56 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import type { TabsProps } from './tabs'
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export let
|
|
8
|
-
export let
|
|
9
|
-
export let
|
|
10
|
-
|
|
11
|
-
let
|
|
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
|
-
|
|
45
|
-
|
|
46
|
-
{
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { TabsProps } from './tabs'
|
|
3
|
+
|
|
4
|
+
import styles from './tabs.module.scss'
|
|
5
|
+
import { classNames } from '../../utils/classNames'
|
|
6
|
+
|
|
7
|
+
export let items: TabsProps['items'] = []
|
|
8
|
+
export let theme: TabsProps['theme'] = null
|
|
9
|
+
export let vertical: TabsProps['vertical'] = false
|
|
10
|
+
export let even: TabsProps['even'] = false
|
|
11
|
+
export let className: TabsProps['className'] = ''
|
|
12
|
+
|
|
13
|
+
let active = ''
|
|
14
|
+
let tabContainer: HTMLDivElement
|
|
15
|
+
|
|
16
|
+
const classes = classNames([
|
|
17
|
+
styles.tabs,
|
|
18
|
+
theme && styles[theme],
|
|
19
|
+
vertical && styles.vertical,
|
|
20
|
+
even && styles.even,
|
|
21
|
+
className
|
|
22
|
+
])
|
|
23
|
+
|
|
24
|
+
const setTab = (tab: string) => {
|
|
25
|
+
const tabs = tabContainer.querySelectorAll('[data-tab]')
|
|
26
|
+
|
|
27
|
+
active = tab
|
|
28
|
+
|
|
29
|
+
Array.from(tabs).forEach((item: any) => {
|
|
30
|
+
item.dataset.active = false
|
|
31
|
+
|
|
32
|
+
if (item.dataset.tab === active) {
|
|
33
|
+
item.dataset.active = true
|
|
34
|
+
}
|
|
35
|
+
})
|
|
36
|
+
}
|
|
37
|
+
</script>
|
|
38
|
+
|
|
39
|
+
<section class={classes}>
|
|
40
|
+
<div class={styles.wrapper}>
|
|
41
|
+
<div class={styles.items}>
|
|
42
|
+
{#each items as item}
|
|
43
|
+
<button
|
|
44
|
+
data-active={active ? active === item.value : item.active}
|
|
45
|
+
disabled={item.disabled}
|
|
46
|
+
on:click={() => setTab(item.value)}
|
|
47
|
+
>
|
|
48
|
+
{@html item.label}
|
|
49
|
+
</button>
|
|
50
|
+
{/each}
|
|
51
|
+
</div>
|
|
52
|
+
</div>
|
|
53
|
+
<div class={styles.content} bind:this={tabContainer}>
|
|
54
|
+
<slot />
|
|
55
|
+
</div>
|
|
56
|
+
</section>
|