webcoreui 0.4.1 → 0.6.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 +237 -227
- package/astro.d.ts +115 -62
- package/astro.js +14 -0
- package/components/Avatar/Avatar.astro +9 -2
- package/components/Avatar/Avatar.svelte +3 -1
- package/components/Avatar/Avatar.tsx +4 -2
- package/components/Avatar/avatar.ts +1 -0
- package/components/Badge/Badge.astro +4 -0
- package/components/Badge/Badge.svelte +5 -1
- package/components/Badge/Badge.tsx +4 -0
- package/components/Badge/badge.module.scss +8 -0
- package/components/Badge/badge.ts +7 -3
- package/components/Breadcrumb/Breadcrumb.astro +51 -0
- package/components/Breadcrumb/Breadcrumb.svelte +45 -0
- package/components/Breadcrumb/Breadcrumb.tsx +51 -0
- package/components/Breadcrumb/breadcrumb.module.scss +26 -0
- package/components/Breadcrumb/breadcrumb.ts +12 -0
- package/components/Button/button.module.scss +6 -1
- package/components/Button/button.ts +13 -3
- package/components/Carousel/Carousel.astro +198 -0
- package/components/Carousel/Carousel.svelte +161 -0
- package/components/Carousel/Carousel.tsx +172 -0
- package/components/Carousel/carousel.module.scss +58 -0
- package/components/Carousel/carousel.ts +26 -0
- package/components/Checkbox/checkbox.ts +4 -2
- package/components/DataTable/DataTable.astro +332 -0
- package/components/DataTable/DataTable.svelte +272 -0
- package/components/DataTable/DataTable.tsx +287 -0
- package/components/DataTable/datatable.module.scss +102 -0
- package/components/DataTable/datatable.ts +41 -0
- package/components/Footer/Footer.astro +91 -0
- package/components/Footer/Footer.svelte +94 -0
- package/components/Footer/Footer.tsx +107 -0
- package/components/Footer/footer.module.scss +61 -0
- package/components/Footer/footer.ts +29 -0
- package/components/Icon/Icon.svelte +1 -1
- package/components/Icon/icon.ts +18 -1
- package/components/Icon/map.ts +14 -0
- package/components/Input/input.module.scss +6 -0
- package/components/List/List.astro +1 -1
- package/components/List/List.svelte +1 -1
- package/components/List/List.tsx +1 -2
- package/components/List/list.ts +3 -1
- package/components/Masonry/Masonry.astro +54 -0
- package/components/Masonry/Masonry.svelte +54 -0
- package/components/Masonry/Masonry.tsx +62 -0
- package/components/Masonry/masonry.module.scss +18 -0
- package/components/Masonry/masonry.ts +36 -0
- package/components/Menu/Menu.astro +1 -1
- package/components/Menu/Menu.svelte +1 -1
- package/components/Menu/Menu.tsx +1 -1
- package/components/Menu/menu.ts +4 -2
- package/components/Modal/Modal.astro +2 -0
- package/components/Modal/Modal.svelte +2 -0
- package/components/Modal/Modal.tsx +2 -0
- package/components/Modal/modal.module.scss +29 -22
- package/components/Modal/modal.ts +1 -0
- package/components/Pagination/Pagination.astro +189 -0
- package/components/Pagination/Pagination.svelte +144 -0
- package/components/Pagination/Pagination.tsx +162 -0
- package/components/Pagination/pagination.module.scss +49 -0
- package/components/Pagination/pagination.ts +35 -0
- package/components/Rating/rating.ts +3 -1
- package/components/Select/Select.astro +8 -4
- package/components/Select/Select.svelte +15 -6
- package/components/Select/Select.tsx +15 -8
- package/components/Select/select.ts +7 -2
- package/components/Sidebar/Sidebar.astro +61 -0
- package/components/Sidebar/Sidebar.svelte +50 -0
- package/components/Sidebar/Sidebar.tsx +58 -0
- package/components/Sidebar/sidebar.module.scss +43 -0
- package/components/Sidebar/sidebar.ts +21 -0
- package/components/Switch/switch.ts +4 -2
- package/components/Table/Table.svelte +1 -1
- package/components/Table/table.ts +1 -1
- package/icons/arrow-left.svg +3 -0
- package/icons/arrow-right.svg +3 -0
- package/icons/circle-close.svg +3 -0
- package/icons/components.svg +3 -0
- package/icons/file.svg +3 -0
- package/icons/home.svg +4 -0
- package/icons/order.svg +3 -0
- package/icons/sun.svg +1 -1
- package/icons.d.ts +7 -0
- package/icons.js +7 -0
- package/index.d.ts +6 -6
- package/package.json +8 -10
- package/react.d.ts +115 -62
- package/react.js +14 -0
- package/scss/resets.scss +27 -1
- package/svelte.d.ts +116 -62
- package/svelte.js +14 -0
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import type { ReactFooterProps } from './footer'
|
|
3
|
+
|
|
4
|
+
import ConditionalWrapper from '../ConditionalWrapper/ConditionalWrapper.tsx'
|
|
5
|
+
|
|
6
|
+
import { classNames } from '../../utils/classNames'
|
|
7
|
+
|
|
8
|
+
import styles from './footer.module.scss'
|
|
9
|
+
|
|
10
|
+
const Footer = ({
|
|
11
|
+
logo,
|
|
12
|
+
columns,
|
|
13
|
+
subText,
|
|
14
|
+
className,
|
|
15
|
+
wrapperClassName,
|
|
16
|
+
subTextClassName,
|
|
17
|
+
children
|
|
18
|
+
}: ReactFooterProps) => {
|
|
19
|
+
const classes = classNames([
|
|
20
|
+
styles.footer,
|
|
21
|
+
className
|
|
22
|
+
])
|
|
23
|
+
|
|
24
|
+
const containerClasses = classNames([
|
|
25
|
+
styles.container,
|
|
26
|
+
wrapperClassName
|
|
27
|
+
])
|
|
28
|
+
|
|
29
|
+
const subTextClasses = classNames([
|
|
30
|
+
styles.subtext,
|
|
31
|
+
subTextClassName
|
|
32
|
+
])
|
|
33
|
+
|
|
34
|
+
return (
|
|
35
|
+
<footer className={classes}>
|
|
36
|
+
<div className={containerClasses}>
|
|
37
|
+
<ConditionalWrapper
|
|
38
|
+
condition={!!(logo?.url || logo?.html)}
|
|
39
|
+
wrapper={children => <div className={styles.wrapper}>{children}</div>}
|
|
40
|
+
>
|
|
41
|
+
{logo?.url && (
|
|
42
|
+
<a href="/">
|
|
43
|
+
<img
|
|
44
|
+
src={logo.url}
|
|
45
|
+
alt={logo.alt || 'Logo'}
|
|
46
|
+
width={logo.width}
|
|
47
|
+
height={logo.height}
|
|
48
|
+
loading={logo.eager ? undefined : 'lazy'}
|
|
49
|
+
/>
|
|
50
|
+
</a>
|
|
51
|
+
)}
|
|
52
|
+
|
|
53
|
+
{logo?.html && (
|
|
54
|
+
<a
|
|
55
|
+
href="/"
|
|
56
|
+
aria-label={logo.alt || 'Logo'}
|
|
57
|
+
dangerouslySetInnerHTML={{ __html: logo.html }}
|
|
58
|
+
/>
|
|
59
|
+
)}
|
|
60
|
+
|
|
61
|
+
{!!columns?.length && (
|
|
62
|
+
<ConditionalWrapper
|
|
63
|
+
condition={columns.length > 1}
|
|
64
|
+
wrapper={children => <div className={styles.columns}>{children}</div>}
|
|
65
|
+
>
|
|
66
|
+
{columns.map((column, columnIndex) => (
|
|
67
|
+
<ConditionalWrapper
|
|
68
|
+
condition={!!column.title}
|
|
69
|
+
wrapper={children => <div>{children}</div>}
|
|
70
|
+
key={columnIndex}
|
|
71
|
+
>
|
|
72
|
+
{column.title && (
|
|
73
|
+
<strong className={styles['column-title']}>
|
|
74
|
+
{column.title}
|
|
75
|
+
</strong>
|
|
76
|
+
)}
|
|
77
|
+
<ul className={styles.column}>
|
|
78
|
+
{column.items.map((item, itemKey) => (
|
|
79
|
+
<li key={itemKey}>
|
|
80
|
+
<a
|
|
81
|
+
href={item.href}
|
|
82
|
+
target={item.target}
|
|
83
|
+
className={item.active ? styles.active : undefined}
|
|
84
|
+
>
|
|
85
|
+
{item.name}
|
|
86
|
+
</a>
|
|
87
|
+
</li>
|
|
88
|
+
))}
|
|
89
|
+
</ul>
|
|
90
|
+
</ConditionalWrapper>
|
|
91
|
+
))}
|
|
92
|
+
</ConditionalWrapper>
|
|
93
|
+
)}
|
|
94
|
+
</ConditionalWrapper>
|
|
95
|
+
{(subText || children) && (
|
|
96
|
+
<div className={subTextClasses}>
|
|
97
|
+
{subText && <span dangerouslySetInnerHTML={{ __html: subText }} />}
|
|
98
|
+
{children}
|
|
99
|
+
</div>
|
|
100
|
+
)}
|
|
101
|
+
</div>
|
|
102
|
+
</footer>
|
|
103
|
+
)
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export default Footer
|
|
107
|
+
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
@import '../../scss/config.scss';
|
|
2
|
+
|
|
3
|
+
.footer {
|
|
4
|
+
@include border(top, primary-50);
|
|
5
|
+
|
|
6
|
+
.column-title {
|
|
7
|
+
@include spacing(mb-default);
|
|
8
|
+
|
|
9
|
+
display: block;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.column {
|
|
13
|
+
@include spacing(0);
|
|
14
|
+
|
|
15
|
+
list-style-type: none;
|
|
16
|
+
|
|
17
|
+
a {
|
|
18
|
+
@include typography(primary-10, none);
|
|
19
|
+
|
|
20
|
+
&:hover,
|
|
21
|
+
&.active {
|
|
22
|
+
@include typography(primary, underline);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.container {
|
|
29
|
+
@include spacing(auto-default, px-default);
|
|
30
|
+
|
|
31
|
+
max-width: 1200px;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.wrapper {
|
|
35
|
+
@include layout(flex, column, default, h-between);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.columns {
|
|
39
|
+
@include layout(flex, column, default);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.subtext {
|
|
43
|
+
@include border(top, primary-60);
|
|
44
|
+
@include spacing(mt-default, py-default);
|
|
45
|
+
@include layout(flex, column, default, h-between);
|
|
46
|
+
|
|
47
|
+
span {
|
|
48
|
+
@include typography(md, primary-20);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
@include media('sm') {
|
|
53
|
+
.wrapper,
|
|
54
|
+
.subtext {
|
|
55
|
+
@include layout(row, none);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.columns {
|
|
59
|
+
@include layout(row, '5xl');
|
|
60
|
+
}
|
|
61
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { ButtonProps } from '../Button/button'
|
|
2
|
+
|
|
3
|
+
export type FooterProps = {
|
|
4
|
+
logo?: {
|
|
5
|
+
url?: string
|
|
6
|
+
alt?: string
|
|
7
|
+
width?: number
|
|
8
|
+
height?: number
|
|
9
|
+
eager?: boolean
|
|
10
|
+
html?: string
|
|
11
|
+
} | null
|
|
12
|
+
columns?: {
|
|
13
|
+
title?: string
|
|
14
|
+
items: {
|
|
15
|
+
href: string
|
|
16
|
+
name: string
|
|
17
|
+
target?: ButtonProps['target']
|
|
18
|
+
active?: boolean
|
|
19
|
+
}[]
|
|
20
|
+
}[]
|
|
21
|
+
subText?: string
|
|
22
|
+
className?: string
|
|
23
|
+
wrapperClassName?: string
|
|
24
|
+
subTextClassName?: string
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export type ReactFooterProps = {
|
|
28
|
+
children?: React.ReactNode
|
|
29
|
+
} & FooterProps
|
package/components/Icon/icon.ts
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
export type IconProps = {
|
|
2
|
-
type:
|
|
2
|
+
type: 'alert'
|
|
3
|
+
| 'arrow-down'
|
|
4
|
+
| 'arrow-left'
|
|
5
|
+
| 'arrow-right'
|
|
6
|
+
| 'check'
|
|
7
|
+
| 'circle-check'
|
|
8
|
+
| 'circle-close'
|
|
9
|
+
| 'close'
|
|
10
|
+
| 'components'
|
|
11
|
+
| 'file'
|
|
12
|
+
| 'github'
|
|
13
|
+
| 'home'
|
|
14
|
+
| 'info'
|
|
15
|
+
| 'moon'
|
|
16
|
+
| 'order'
|
|
17
|
+
| 'search'
|
|
18
|
+
| 'sun'
|
|
19
|
+
| 'warning'
|
|
3
20
|
size?: number
|
|
4
21
|
color?: string
|
|
5
22
|
}
|
package/components/Icon/map.ts
CHANGED
|
@@ -1,11 +1,18 @@
|
|
|
1
1
|
import Alert from '../../icons/alert.svg?raw'
|
|
2
2
|
import ArrowDown from '../../icons/arrow-down.svg?raw'
|
|
3
|
+
import ArrowLeft from '../../icons/arrow-left.svg?raw'
|
|
4
|
+
import ArrowRight from '../../icons/arrow-right.svg?raw'
|
|
3
5
|
import Check from '../../icons/check.svg?raw'
|
|
4
6
|
import CircleCheck from '../../icons/circle-check.svg?raw'
|
|
7
|
+
import CircleClose from '../../icons/circle-close.svg?raw'
|
|
5
8
|
import Close from '../../icons/close.svg?raw'
|
|
9
|
+
import Components from '../../icons/components.svg?raw'
|
|
10
|
+
import File from '../../icons/file.svg?raw'
|
|
6
11
|
import Github from '../../icons/github.svg?raw'
|
|
12
|
+
import Home from '../../icons/home.svg?raw'
|
|
7
13
|
import Info from '../../icons/info.svg?raw'
|
|
8
14
|
import Moon from '../../icons/moon.svg?raw'
|
|
15
|
+
import Order from '../../icons/order.svg?raw'
|
|
9
16
|
import Search from '../../icons/search.svg?raw'
|
|
10
17
|
import Sun from '../../icons/sun.svg?raw'
|
|
11
18
|
import Warning from '../../icons/warning.svg?raw'
|
|
@@ -13,12 +20,19 @@ import Warning from '../../icons/warning.svg?raw'
|
|
|
13
20
|
const iconMap = {
|
|
14
21
|
'alert': Alert,
|
|
15
22
|
'arrow-down': ArrowDown,
|
|
23
|
+
'arrow-left': ArrowLeft,
|
|
24
|
+
'arrow-right': ArrowRight,
|
|
16
25
|
'check': Check,
|
|
17
26
|
'circle-check': CircleCheck,
|
|
27
|
+
'circle-close': CircleClose,
|
|
18
28
|
'close': Close,
|
|
29
|
+
'components': Components,
|
|
30
|
+
'file': File,
|
|
19
31
|
'github': Github,
|
|
32
|
+
'home': Home,
|
|
20
33
|
'info': Info,
|
|
21
34
|
'moon': Moon,
|
|
35
|
+
'order': Order,
|
|
22
36
|
'search': Search,
|
|
23
37
|
'sun': Sun,
|
|
24
38
|
'warning': Warning
|
|
@@ -52,6 +52,7 @@
|
|
|
52
52
|
|
|
53
53
|
.input-label {
|
|
54
54
|
@include layout(flex, column);
|
|
55
|
+
@include size('w100%');
|
|
55
56
|
|
|
56
57
|
.label {
|
|
57
58
|
@include typography(primary-20);
|
|
@@ -66,6 +67,11 @@
|
|
|
66
67
|
padding-left: 40px;
|
|
67
68
|
}
|
|
68
69
|
|
|
70
|
+
span {
|
|
71
|
+
@include position(absolute);
|
|
72
|
+
@include size(18px);
|
|
73
|
+
}
|
|
74
|
+
|
|
69
75
|
svg {
|
|
70
76
|
@include position(absolute, l10px);
|
|
71
77
|
@include size(18px);
|
|
@@ -76,7 +76,7 @@ const wrapperClasses = [
|
|
|
76
76
|
<ConditionalWrapper condition={!!(item.icon && item.subText)}>
|
|
77
77
|
<div slot="wrapper">children</div>
|
|
78
78
|
{item.icon && <Fragment set:html={item.icon} />}
|
|
79
|
-
{item.name}
|
|
79
|
+
<div>{item.name}</div>
|
|
80
80
|
</ConditionalWrapper>
|
|
81
81
|
{item.subText && <span>{item.subText}</span>}
|
|
82
82
|
</ConditionalWrapper>
|
package/components/List/List.tsx
CHANGED
|
@@ -97,7 +97,6 @@ const List = ({
|
|
|
97
97
|
{showSearchBarIcon && (
|
|
98
98
|
<span
|
|
99
99
|
dangerouslySetInnerHTML={{ __html: searchIcon }}
|
|
100
|
-
style={{ height: '18px', position: 'absolute' }}
|
|
101
100
|
/>
|
|
102
101
|
)}
|
|
103
102
|
</Input>
|
|
@@ -148,7 +147,7 @@ const List = ({
|
|
|
148
147
|
style={{ height: '18px' }}
|
|
149
148
|
/>
|
|
150
149
|
)}
|
|
151
|
-
{item.name}
|
|
150
|
+
<div>{item.name}</div>
|
|
152
151
|
</ConditionalWrapper>
|
|
153
152
|
{item.subText && <span>{item.subText}</span>}
|
|
154
153
|
</ConditionalWrapper>
|
package/components/List/list.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { ButtonProps } from '../Button/button'
|
|
2
|
+
|
|
1
3
|
export type ListEventType = {
|
|
2
4
|
value: string
|
|
3
5
|
name: string
|
|
@@ -19,7 +21,7 @@ export type ListProps = {
|
|
|
19
21
|
name: string
|
|
20
22
|
value?: string
|
|
21
23
|
href?: string
|
|
22
|
-
target?: '
|
|
24
|
+
target?: ButtonProps['target']
|
|
23
25
|
selected?: boolean
|
|
24
26
|
disabled?: boolean
|
|
25
27
|
icon?: string
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
---
|
|
2
|
+
import type { MasonryProps } from './masonry'
|
|
3
|
+
|
|
4
|
+
import styles from './masonry.module.scss'
|
|
5
|
+
|
|
6
|
+
interface Props extends MasonryProps {}
|
|
7
|
+
|
|
8
|
+
const {
|
|
9
|
+
items,
|
|
10
|
+
element = 'section',
|
|
11
|
+
gap,
|
|
12
|
+
columns = 3,
|
|
13
|
+
sequential,
|
|
14
|
+
className
|
|
15
|
+
} = Astro.props
|
|
16
|
+
|
|
17
|
+
const classes = [
|
|
18
|
+
styles.masonry,
|
|
19
|
+
className
|
|
20
|
+
]
|
|
21
|
+
|
|
22
|
+
const Component = element
|
|
23
|
+
|
|
24
|
+
const componentProps = {
|
|
25
|
+
'class:list': classes,
|
|
26
|
+
'style': gap ? `--w-masonry-gap: ${gap};` : null
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const chunkSize = Math.ceil(items.length / columns)
|
|
30
|
+
const columnGroups = Array.from({ length: columns }, (_, i) => {
|
|
31
|
+
return sequential
|
|
32
|
+
? items.slice(i * chunkSize, (i + 1) * chunkSize)
|
|
33
|
+
: items.filter((_, index) => index % columns === i)
|
|
34
|
+
})
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
<Component {...componentProps}>
|
|
38
|
+
{columnGroups.map(column => (
|
|
39
|
+
<div class={styles.column}>
|
|
40
|
+
{column.map(item => (
|
|
41
|
+
item.component
|
|
42
|
+
? <item.component {...item.props}>
|
|
43
|
+
{typeof item.children === 'object'
|
|
44
|
+
? <item.children.component {...item.children.props}>
|
|
45
|
+
<Fragment set:html={item.children.children} />
|
|
46
|
+
</item.children.component>
|
|
47
|
+
: <Fragment set:html={item.children} />
|
|
48
|
+
}
|
|
49
|
+
</item.component>
|
|
50
|
+
: <Fragment set:html={item.html} />
|
|
51
|
+
))}
|
|
52
|
+
</div>
|
|
53
|
+
))}
|
|
54
|
+
</Component>
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { SvelteMasonryProps } from './masonry'
|
|
3
|
+
|
|
4
|
+
import { classNames } from '../../utils/classNames'
|
|
5
|
+
|
|
6
|
+
import styles from './masonry.module.scss'
|
|
7
|
+
|
|
8
|
+
export let items: SvelteMasonryProps['items'] = []
|
|
9
|
+
export let element: SvelteMasonryProps['element'] = 'section'
|
|
10
|
+
export let gap: SvelteMasonryProps['gap'] = ''
|
|
11
|
+
export let columns: SvelteMasonryProps['columns'] = 3
|
|
12
|
+
export let sequential: SvelteMasonryProps['sequential'] = false
|
|
13
|
+
export let className: SvelteMasonryProps['className'] = ''
|
|
14
|
+
|
|
15
|
+
const classes = classNames([
|
|
16
|
+
styles.masonry,
|
|
17
|
+
className
|
|
18
|
+
])
|
|
19
|
+
|
|
20
|
+
const componentProps = {
|
|
21
|
+
class: classes,
|
|
22
|
+
style: gap ? `--w-masonry-gap: ${gap};` : null
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const chunkSize = Math.ceil(items.length / columns!)
|
|
26
|
+
const columnGroups = Array.from({ length: columns! }, (_, i) => {
|
|
27
|
+
return sequential
|
|
28
|
+
? items.slice(i * chunkSize, (i + 1) * chunkSize)
|
|
29
|
+
: items.filter((_, index) => index % columns! === i)
|
|
30
|
+
})
|
|
31
|
+
</script>
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
<svelte:element this={element} {...componentProps}>
|
|
35
|
+
{#each columnGroups as group}
|
|
36
|
+
<div class={styles.column}>
|
|
37
|
+
{#each group as item}
|
|
38
|
+
{#if item.component}
|
|
39
|
+
<svelte:component this={item.component} {...item.props}>
|
|
40
|
+
{#if typeof item.children === 'object' && item.children.component}
|
|
41
|
+
<svelte:component this={item.children.component} {...item.children.props}>
|
|
42
|
+
{@html item.children.children}
|
|
43
|
+
</svelte:component>
|
|
44
|
+
{:else}
|
|
45
|
+
{@html item.children}
|
|
46
|
+
{/if}
|
|
47
|
+
</svelte:component>
|
|
48
|
+
{:else}
|
|
49
|
+
{@html item.html}
|
|
50
|
+
{/if}
|
|
51
|
+
{/each}
|
|
52
|
+
</div>
|
|
53
|
+
{/each}
|
|
54
|
+
</svelte:element>
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import type { ReactMasonryProps } from './masonry'
|
|
3
|
+
|
|
4
|
+
import { classNames } from '../../utils/classNames'
|
|
5
|
+
|
|
6
|
+
import styles from './masonry.module.scss'
|
|
7
|
+
|
|
8
|
+
const Masonry = ({
|
|
9
|
+
items,
|
|
10
|
+
element = 'section',
|
|
11
|
+
gap,
|
|
12
|
+
columns = 3,
|
|
13
|
+
sequential,
|
|
14
|
+
className
|
|
15
|
+
}: ReactMasonryProps) => {
|
|
16
|
+
const classes = classNames([
|
|
17
|
+
styles.masonry,
|
|
18
|
+
className
|
|
19
|
+
])
|
|
20
|
+
|
|
21
|
+
const componentProps = {
|
|
22
|
+
className: classes,
|
|
23
|
+
style: gap
|
|
24
|
+
? { '--w-masonry-gap': gap } as React.CSSProperties
|
|
25
|
+
: undefined
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const chunkSize = Math.ceil(items.length / columns!)
|
|
29
|
+
const columnGroups = Array.from({ length: columns! }, (_, i) => {
|
|
30
|
+
return sequential
|
|
31
|
+
? items.slice(i * chunkSize, (i + 1) * chunkSize)
|
|
32
|
+
: items.filter((_, index) => index % columns! === i)
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
const Element = element as keyof JSX.IntrinsicElements
|
|
36
|
+
|
|
37
|
+
return (
|
|
38
|
+
<Element {...componentProps}>
|
|
39
|
+
{columnGroups.map((column, columnKey) => (
|
|
40
|
+
<div className={styles.column} key={columnKey}>
|
|
41
|
+
{column.map((item, itemKey) => (
|
|
42
|
+
item.component
|
|
43
|
+
? <item.component {...item.props} key={itemKey}>
|
|
44
|
+
{typeof item.children === 'object'
|
|
45
|
+
? <item.children.component {...item.children.props}>
|
|
46
|
+
<span dangerouslySetInnerHTML={{ __html: String(item.children.children) }} />
|
|
47
|
+
</item.children.component>
|
|
48
|
+
: <span dangerouslySetInnerHTML={{ __html: String(item.children) }} />
|
|
49
|
+
}
|
|
50
|
+
</item.component>
|
|
51
|
+
: <span
|
|
52
|
+
key={itemKey}
|
|
53
|
+
dangerouslySetInnerHTML={{ __html: String(item.html) }}
|
|
54
|
+
/>
|
|
55
|
+
))}
|
|
56
|
+
</div>
|
|
57
|
+
))}
|
|
58
|
+
</Element>
|
|
59
|
+
)
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export default Masonry
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
@import '../../scss/config.scss';
|
|
2
|
+
|
|
3
|
+
body {
|
|
4
|
+
--w-masonry-gap: 5px;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
.masonry {
|
|
8
|
+
@include layout(flex);
|
|
9
|
+
|
|
10
|
+
gap: var(--w-masonry-gap);
|
|
11
|
+
overflow-x: auto;
|
|
12
|
+
|
|
13
|
+
.column {
|
|
14
|
+
@include layout(flex, column);
|
|
15
|
+
|
|
16
|
+
gap: var(--w-masonry-gap);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { FC } from 'react'
|
|
2
|
+
import type { SvelteComponent } from 'svelte'
|
|
3
|
+
|
|
4
|
+
type ChildrenProps<ComponentType> = {
|
|
5
|
+
component: ComponentType
|
|
6
|
+
children?: string | number
|
|
7
|
+
props?: {
|
|
8
|
+
[key: string]: any
|
|
9
|
+
}
|
|
10
|
+
} | string | number
|
|
11
|
+
|
|
12
|
+
type Items<ComponentType> = {
|
|
13
|
+
component?: ComponentType;
|
|
14
|
+
children?: ChildrenProps<ComponentType>
|
|
15
|
+
html?: string
|
|
16
|
+
props?: {
|
|
17
|
+
[key: string]: any
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export type MasonryProps = {
|
|
22
|
+
items: Items<(_props: any) => any>[]
|
|
23
|
+
element?: string
|
|
24
|
+
gap?: string
|
|
25
|
+
columns?: number
|
|
26
|
+
sequential?: boolean
|
|
27
|
+
className?: string
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export type SvelteMasonryProps = {
|
|
31
|
+
items: Items<typeof SvelteComponent<any>>[]
|
|
32
|
+
} & Omit<MasonryProps, 'items'>
|
|
33
|
+
|
|
34
|
+
export type ReactMasonryProps = {
|
|
35
|
+
items: Items<FC<any>>[]
|
|
36
|
+
} & Omit<MasonryProps, 'items'>
|
package/components/Menu/Menu.tsx
CHANGED
package/components/Menu/menu.ts
CHANGED
|
@@ -26,6 +26,7 @@ const {
|
|
|
26
26
|
showCloseIcon = true,
|
|
27
27
|
closeOnEsc = true,
|
|
28
28
|
closeOnOverlay = true,
|
|
29
|
+
transparent,
|
|
29
30
|
theme,
|
|
30
31
|
id,
|
|
31
32
|
className,
|
|
@@ -40,6 +41,7 @@ const close = [
|
|
|
40
41
|
|
|
41
42
|
const classes = [
|
|
42
43
|
styles.modal,
|
|
44
|
+
transparent && styles.transparent,
|
|
43
45
|
theme && styles[theme],
|
|
44
46
|
className
|
|
45
47
|
]
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
export let showCloseIcon: ModalProps['showCloseIcon'] = true
|
|
19
19
|
export let closeOnEsc: ModalProps['closeOnEsc'] = true
|
|
20
20
|
export let closeOnOverlay: ModalProps['closeOnOverlay'] = true
|
|
21
|
+
export let transparent: ModalProps['transparent'] = false
|
|
21
22
|
export let theme: ModalProps['theme'] = null
|
|
22
23
|
export let id : ModalProps['className'] = ''
|
|
23
24
|
export let className: ModalProps['className'] = ''
|
|
@@ -31,6 +32,7 @@
|
|
|
31
32
|
|
|
32
33
|
const classes = classNames([
|
|
33
34
|
styles.modal,
|
|
35
|
+
transparent && styles.transparent,
|
|
34
36
|
theme && styles[theme],
|
|
35
37
|
className
|
|
36
38
|
])
|
|
@@ -26,6 +26,7 @@ const Modal = ({
|
|
|
26
26
|
showCloseIcon = true,
|
|
27
27
|
closeOnEsc = true,
|
|
28
28
|
closeOnOverlay = true,
|
|
29
|
+
transparent,
|
|
29
30
|
theme,
|
|
30
31
|
id,
|
|
31
32
|
className,
|
|
@@ -35,6 +36,7 @@ const Modal = ({
|
|
|
35
36
|
const classes = classNames([
|
|
36
37
|
styles.modal,
|
|
37
38
|
theme && styles[theme],
|
|
39
|
+
transparent && styles.transparent,
|
|
38
40
|
className
|
|
39
41
|
])
|
|
40
42
|
|