webcoreui 0.1.0 → 0.2.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 +29 -1
- package/astro.d.ts +4 -0
- package/astro.js +4 -0
- package/components/Accordion/accordion.module.scss +1 -2
- package/components/Alert/alert.module.scss +3 -3
- package/components/Badge/badge.module.scss +1 -1
- package/components/Button/button.module.scss +2 -2
- package/components/Button/button.ts +1 -1
- package/components/Card/card.module.scss +0 -1
- package/components/Checkbox/checkbox.module.scss +4 -4
- package/components/Icon/map.ts +2 -0
- package/components/Input/input.module.scss +2 -2
- package/components/Menu/Menu.astro +7 -3
- package/components/Menu/Menu.svelte +11 -3
- package/components/Menu/Menu.tsx +7 -1
- package/components/Menu/menu.module.scss +4 -1
- package/components/Menu/menu.ts +1 -0
- package/components/Modal/Modal.astro +70 -0
- package/components/Modal/Modal.svelte +71 -0
- package/components/Modal/Modal.tsx +76 -0
- package/components/Modal/modal.module.scss +103 -0
- package/components/Modal/modal.ts +18 -0
- package/components/Progress/progress.module.scss +3 -3
- package/components/Radio/radio.module.scss +1 -2
- package/components/Rating/Rating.astro +2 -2
- package/components/Rating/Rating.svelte +2 -2
- package/components/Rating/Rating.tsx +2 -2
- package/components/Rating/rating.module.scss +1 -1
- package/components/Slider/Slider.astro +44 -0
- package/components/Slider/Slider.svelte +42 -0
- package/components/Slider/Slider.tsx +48 -0
- package/components/Slider/slider.module.scss +68 -0
- package/components/Slider/slider.ts +20 -0
- package/components/Switch/switch.module.scss +1 -1
- package/components/Table/Table.astro +6 -1
- package/components/Table/Table.svelte +3 -1
- package/components/Table/Table.tsx +7 -1
- package/components/Table/table.module.scss +11 -1
- package/components/Table/table.ts +1 -0
- package/components/Tabs/tabs.module.scss +6 -1
- package/components/ThemeSwitcher/ThemeSwitcher.astro +1 -0
- package/components/ThemeSwitcher/ThemeSwitcher.svelte +2 -1
- package/components/ThemeSwitcher/ThemeSwitcher.tsx +2 -1
- package/components/Timeline/timeline.module.scss +4 -4
- package/components/TimelineItem/TimelineItem.tsx +1 -6
- package/components/TimelineItem/timelineitem.module.scss +2 -3
- package/components/TimelineItem/timelineitem.ts +5 -0
- package/icons/close.svg +3 -0
- package/icons.d.ts +1 -0
- package/icons.js +1 -0
- package/index.js +2 -0
- package/package.json +1 -1
- package/react.d.ts +6 -2
- package/react.js +4 -0
- package/scss/config/color-palette.scss +1 -0
- package/scss/config/mixins.scss +152 -155
- package/scss/config/typography.scss +8 -9
- package/scss/global/theme.scss +71 -38
- package/scss/global/tooltip.scss +5 -3
- package/scss/global/utility.scss +76 -58
- package/scss/resets.scss +10 -5
- package/scss/setup.scss +2 -2
- package/svelte.d.ts +4 -0
- package/svelte.js +4 -0
- package/utils/interpolate.ts +23 -0
- package/utils/modal.ts +59 -0
package/README.md
CHANGED
|
@@ -99,7 +99,7 @@ The `Setup` mixin can also accept the following options:
|
|
|
99
99
|
| Property | Default value | Purpose |
|
|
100
100
|
|-----------|---------------|---------|
|
|
101
101
|
| `includeResets` | `true` | Include reset styles. Set to `false` if you want to use your own CSS resets. |
|
|
102
|
-
| `
|
|
102
|
+
| `includeUtilities` | `true` | Adds utility classes for CSS. Read more about the available utility classes [here](https://webcoreui.dev/docs/layout). |
|
|
103
103
|
| `includeTooltip` | `true` | Adds styles for using tooltips.
|
|
104
104
|
| `includeScrollbarStyles` | `true` | Adds styles for scrollbars.
|
|
105
105
|
|
|
@@ -107,30 +107,56 @@ Default component styles can be changed by overriding the following CSS variable
|
|
|
107
107
|
|
|
108
108
|
```scss
|
|
109
109
|
html body {
|
|
110
|
+
// Avatar component
|
|
110
111
|
--w-avatar-border: var(--w-color-primary-70);
|
|
112
|
+
|
|
113
|
+
// Checkbox component
|
|
111
114
|
--w-checkbox-color: var(--w-color-primary);
|
|
115
|
+
|
|
116
|
+
// Progress component
|
|
112
117
|
--w-progress-color: var(--w-color-primary);
|
|
113
118
|
--w-progress-background: var(--w-color-primary-50);
|
|
114
119
|
--w-progress-stripe-light: var(--w-color-primary);
|
|
115
120
|
--w-progress-stripe-dark: var(--w-color-primary-10);
|
|
121
|
+
|
|
122
|
+
// Radio component
|
|
116
123
|
--w-radio-color: var(--w-color-primary);
|
|
124
|
+
|
|
125
|
+
// Rating component
|
|
117
126
|
--w-rating-color: var(--w-color-primary);
|
|
118
127
|
--w-rating-empty-color: var(--w-color-primary);
|
|
119
128
|
--w-rating-empty-background: var(--w-color-primary-70);
|
|
120
129
|
--w-rating-size: 18px;
|
|
130
|
+
|
|
131
|
+
// Scrollbars
|
|
121
132
|
--w-scrollbar-bg: var(--w-color-primary-60);
|
|
122
133
|
--w-scrollbar-fg: var(--w-color-primary-50);
|
|
134
|
+
|
|
135
|
+
// Slider component
|
|
136
|
+
--w-slider-background: var(--w-color-primary-50);
|
|
137
|
+
--w-slider-color: var(--w-color-primary);
|
|
138
|
+
--w-slider-thumb: var(--w-color-primary-50);
|
|
139
|
+
|
|
140
|
+
// Spinner component
|
|
123
141
|
--w-spinner-color: var(--w-color-primary);
|
|
124
142
|
--w-spinner-width: 2px;
|
|
125
143
|
--w-spinner-speed: 2s;
|
|
126
144
|
--w-spinner-size: 30px;
|
|
127
145
|
--w-spinner-dash: 8;
|
|
146
|
+
|
|
147
|
+
// Switch component
|
|
128
148
|
--w-switch-off-color: var(--w-color-primary-50);
|
|
129
149
|
--w-switch-on-color: var(--w-color-primary);
|
|
150
|
+
|
|
151
|
+
// ThemeSwitcher component
|
|
130
152
|
--w-theme-switcher-size: 20px;
|
|
153
|
+
|
|
154
|
+
// Timeline component
|
|
131
155
|
--w-timeline-color: var(--w-color-primary-50);
|
|
132
156
|
--w-timeline-text-color: var(--w-color-primary);
|
|
133
157
|
--w-timeline-counter: decimal;
|
|
158
|
+
|
|
159
|
+
// Tooltips
|
|
134
160
|
--w-tooltip-background: var(--w-color-primary);
|
|
135
161
|
--w-tooltip-color: var(--w-color-primary-70);
|
|
136
162
|
|
|
@@ -175,9 +201,11 @@ import { Accordion } from 'webcoreui/react'
|
|
|
175
201
|
- [Icon](https://github.com/Frontendland/webcoreui/tree/main/src/components/Icon)
|
|
176
202
|
- [Input](https://github.com/Frontendland/webcoreui/tree/main/src/components/Input)
|
|
177
203
|
- [Menu](https://github.com/Frontendland/webcoreui/tree/main/src/components/Menu)
|
|
204
|
+
- [Modal](https://github.com/Frontendland/webcoreui/tree/main/src/components/Modal)
|
|
178
205
|
- [Progress](https://github.com/Frontendland/webcoreui/tree/main/src/components/Progress)
|
|
179
206
|
- [Radio](https://github.com/Frontendland/webcoreui/tree/main/src/components/Radio)
|
|
180
207
|
- [Rating](https://github.com/Frontendland/webcoreui/tree/main/src/components/Rating)
|
|
208
|
+
- [Slider](https://github.com/Frontendland/webcoreui/tree/main/src/components/Slider)
|
|
181
209
|
- [Spinner](https://github.com/Frontendland/webcoreui/tree/main/src/components/Spinner)
|
|
182
210
|
- [Switch](https://github.com/Frontendland/webcoreui/tree/main/src/components/Switch)
|
|
183
211
|
- [Table](https://github.com/Frontendland/webcoreui/tree/main/src/components/Table)
|
package/astro.d.ts
CHANGED
|
@@ -9,9 +9,11 @@ import type { ConditionalWrapperProps } from './components/ConditionalWrapper/co
|
|
|
9
9
|
import type { IconProps } from './components/Icon/icon'
|
|
10
10
|
import type { InputProps } from './components/Input/input'
|
|
11
11
|
import type { MenuProps } from './components/Menu/menu'
|
|
12
|
+
import type { ModalProps } from './components/Modal/modal'
|
|
12
13
|
import type { ProgressProps } from './components/Progress/progress'
|
|
13
14
|
import type { RadioProps } from './components/Radio/radio'
|
|
14
15
|
import type { RatingProps } from './components/Rating/rating'
|
|
16
|
+
import type { SliderProps } from './components/Slider/slider'
|
|
15
17
|
import type { SpinnerProps } from './components/Spinner/spinner'
|
|
16
18
|
import type { SwitchProps } from './components/Switch/switch'
|
|
17
19
|
import type { TableProps } from './components/Table/table'
|
|
@@ -33,9 +35,11 @@ declare module 'webcoreui/astro' {
|
|
|
33
35
|
export function Icon(_props: IconProps): any
|
|
34
36
|
export function Input(_props: InputProps): any
|
|
35
37
|
export function Menu(_props: MenuProps): any
|
|
38
|
+
export function Modal(_props: ModalProps): any
|
|
36
39
|
export function Progress(_props: ProgressProps): any
|
|
37
40
|
export function Radio(_props: RadioProps): any
|
|
38
41
|
export function Rating(_props: RatingProps): any
|
|
42
|
+
export function Slider(_props: SliderProps): any
|
|
39
43
|
export function Spinner(_props: SpinnerProps): any
|
|
40
44
|
export function Switch(_props: SwitchProps): any
|
|
41
45
|
export function Table(_props: TableProps): any
|
package/astro.js
CHANGED
|
@@ -9,9 +9,11 @@ import ConditionalWrapperComponent from './components/ConditionalWrapper/Conditi
|
|
|
9
9
|
import IconComponent from './components/Icon/Icon.astro'
|
|
10
10
|
import InputComponent from './components/Input/Input.astro'
|
|
11
11
|
import MenuComponent from './components/Menu/Menu.astro'
|
|
12
|
+
import ModalComponent from './components/Modal/Modal.astro'
|
|
12
13
|
import ProgressComponent from './components/Progress/Progress.astro'
|
|
13
14
|
import RadioComponent from './components/Radio/Radio.astro'
|
|
14
15
|
import RatingComponent from './components/Rating/Rating.astro'
|
|
16
|
+
import SliderComponent from './components/Slider/Slider.astro'
|
|
15
17
|
import SpinnerComponent from './components/Spinner/Spinner.astro'
|
|
16
18
|
import SwitchComponent from './components/Switch/Switch.astro'
|
|
17
19
|
import TableComponent from './components/Table/Table.astro'
|
|
@@ -32,9 +34,11 @@ export const ConditionalWrapper = ConditionalWrapperComponent
|
|
|
32
34
|
export const Icon = IconComponent
|
|
33
35
|
export const Input = InputComponent
|
|
34
36
|
export const Menu = MenuComponent
|
|
37
|
+
export const Modal = ModalComponent
|
|
35
38
|
export const Progress = ProgressComponent
|
|
36
39
|
export const Radio = RadioComponent
|
|
37
40
|
export const Rating = RatingComponent
|
|
41
|
+
export const Slider = SliderComponent
|
|
38
42
|
export const Spinner = SpinnerComponent
|
|
39
43
|
export const Switch = SwitchComponent
|
|
40
44
|
export const Table = TableComponent
|
|
@@ -7,7 +7,6 @@
|
|
|
7
7
|
li {
|
|
8
8
|
@include border(primary-50, bottom);
|
|
9
9
|
@include spacing(py-sm, px-none, m0);
|
|
10
|
-
@include typography(md);
|
|
11
10
|
|
|
12
11
|
&:first-child {
|
|
13
12
|
padding-top: 0;
|
|
@@ -20,7 +19,7 @@
|
|
|
20
19
|
|
|
21
20
|
.title {
|
|
22
21
|
@include layout(flex, h-between, v-center, sm);
|
|
23
|
-
@include typography(
|
|
22
|
+
@include typography(default, primary, left);
|
|
24
23
|
@include size('w100%');
|
|
25
24
|
@include spacing(p0);
|
|
26
25
|
@include border(0);
|
|
@@ -37,15 +37,15 @@
|
|
|
37
37
|
svg {
|
|
38
38
|
@include size(20px);
|
|
39
39
|
min-width: 20px;
|
|
40
|
-
margin-top:
|
|
40
|
+
margin-top: 2.5px;
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
.title {
|
|
44
|
-
@include
|
|
44
|
+
@include typography(lg, hmd);
|
|
45
45
|
display: block;
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
.body {
|
|
49
|
-
@include typography(primary-20,
|
|
49
|
+
@include typography(primary-20, hmd);
|
|
50
50
|
}
|
|
51
51
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
@use '../../scss/config.scss' as *;
|
|
2
2
|
|
|
3
3
|
.button {
|
|
4
|
-
@include layout(inline-flex,
|
|
5
|
-
@include typography(
|
|
4
|
+
@include layout(inline-flex, center, xs);
|
|
5
|
+
@include typography(default, primary-50, none);
|
|
6
6
|
@include spacing(py-sm, px-md);
|
|
7
7
|
@include border-radius(xs);
|
|
8
8
|
@include border(0);
|
|
@@ -6,7 +6,7 @@ body {
|
|
|
6
6
|
|
|
7
7
|
.checkbox {
|
|
8
8
|
@include layout(inline-flex, sm);
|
|
9
|
-
@include typography(
|
|
9
|
+
@include typography(hmd);
|
|
10
10
|
|
|
11
11
|
cursor: pointer;
|
|
12
12
|
|
|
@@ -34,8 +34,8 @@ body {
|
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
&:disabled + span {
|
|
37
|
-
@include background(primary-
|
|
38
|
-
@include border(primary-
|
|
37
|
+
@include background(primary-30);
|
|
38
|
+
@include border(primary-30);
|
|
39
39
|
cursor: no-drop;
|
|
40
40
|
}
|
|
41
41
|
}
|
|
@@ -57,7 +57,7 @@ body {
|
|
|
57
57
|
|
|
58
58
|
.text {
|
|
59
59
|
@include spacing(ml-lg);
|
|
60
|
-
@include typography(
|
|
60
|
+
@include typography(md, primary-20);
|
|
61
61
|
|
|
62
62
|
a {
|
|
63
63
|
@include typography(primary-20);
|
package/components/Icon/map.ts
CHANGED
|
@@ -2,6 +2,7 @@ import Alert from '../../icons/alert.svg?raw'
|
|
|
2
2
|
import ArrowDown from '../../icons/arrow-down.svg?raw'
|
|
3
3
|
import Check from '../../icons/check.svg?raw'
|
|
4
4
|
import CircleCheck from '../../icons/circle-check.svg?raw'
|
|
5
|
+
import Close from '../../icons/close.svg?raw'
|
|
5
6
|
import Github from '../../icons/github.svg?raw'
|
|
6
7
|
import Info from '../../icons/info.svg?raw'
|
|
7
8
|
import Moon from '../../icons/moon.svg?raw'
|
|
@@ -13,6 +14,7 @@ const iconMap = {
|
|
|
13
14
|
'arrow-down': ArrowDown,
|
|
14
15
|
'check': Check,
|
|
15
16
|
'circle-check': CircleCheck,
|
|
17
|
+
'close': Close,
|
|
16
18
|
'github': Github,
|
|
17
19
|
'info': Info,
|
|
18
20
|
'moon': Moon,
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
@include layout(flex, column);
|
|
55
55
|
|
|
56
56
|
.label {
|
|
57
|
-
@include typography(
|
|
57
|
+
@include typography(primary-20);
|
|
58
58
|
@include spacing(mb-xs);
|
|
59
59
|
}
|
|
60
60
|
|
|
@@ -73,7 +73,7 @@
|
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
.subtext {
|
|
76
|
-
@include typography(
|
|
76
|
+
@include typography(md, primary-30);
|
|
77
77
|
@include spacing(mt-xs);
|
|
78
78
|
}
|
|
79
79
|
}
|
|
@@ -45,7 +45,7 @@ const wrapMenu = (logo?.url || logo?.html) && items?.length && Astro.slots.has('
|
|
|
45
45
|
)}
|
|
46
46
|
|
|
47
47
|
{!centerLogo && logo?.html && (
|
|
48
|
-
<a href="/">
|
|
48
|
+
<a href="/" aria-label={logo.alt || 'Logo'}>
|
|
49
49
|
<Fragment set:html={logo.html} />
|
|
50
50
|
</a>
|
|
51
51
|
)}
|
|
@@ -54,7 +54,11 @@ const wrapMenu = (logo?.url || logo?.html) && items?.length && Astro.slots.has('
|
|
|
54
54
|
<ul>
|
|
55
55
|
{items.map(item => (
|
|
56
56
|
<li>
|
|
57
|
-
<a
|
|
57
|
+
<a
|
|
58
|
+
href={item.url}
|
|
59
|
+
target={item.target}
|
|
60
|
+
class:list={[item.active && styles.active]}
|
|
61
|
+
>
|
|
58
62
|
{item.name}
|
|
59
63
|
</a>
|
|
60
64
|
</li>
|
|
@@ -73,7 +77,7 @@ const wrapMenu = (logo?.url || logo?.html) && items?.length && Astro.slots.has('
|
|
|
73
77
|
)}
|
|
74
78
|
|
|
75
79
|
{centerLogo && logo?.html && (
|
|
76
|
-
<a href="/">
|
|
80
|
+
<a href="/" aria-label={logo.alt || 'Logo'}>
|
|
77
81
|
<Fragment set:html={logo.html} />
|
|
78
82
|
</a>
|
|
79
83
|
)}
|
|
@@ -43,14 +43,20 @@
|
|
|
43
43
|
{/if}
|
|
44
44
|
|
|
45
45
|
{#if !centerLogo && logo?.html}
|
|
46
|
-
<a href="/"
|
|
46
|
+
<a href="/" aria-label={logo.alt || 'Logo'}>
|
|
47
|
+
{@html logo.html}
|
|
48
|
+
</a>
|
|
47
49
|
{/if}
|
|
48
50
|
|
|
49
51
|
{#if items?.length}
|
|
50
52
|
<ul>
|
|
51
53
|
{#each items as item}
|
|
52
54
|
<li>
|
|
53
|
-
<a
|
|
55
|
+
<a
|
|
56
|
+
href={item.url}
|
|
57
|
+
target={item.target}
|
|
58
|
+
class={item.active ? styles.active : null}
|
|
59
|
+
>
|
|
54
60
|
{item.name}
|
|
55
61
|
</a>
|
|
56
62
|
</li>
|
|
@@ -69,7 +75,9 @@
|
|
|
69
75
|
{/if}
|
|
70
76
|
|
|
71
77
|
{#if centerLogo && logo?.html}
|
|
72
|
-
<a href="/"
|
|
78
|
+
<a href="/" aria-label={logo.alt || 'Logo'}>
|
|
79
|
+
{@html logo.html}
|
|
80
|
+
</a>
|
|
73
81
|
{/if}
|
|
74
82
|
|
|
75
83
|
{#if logo?.url && centerLogo}
|
package/components/Menu/Menu.tsx
CHANGED
|
@@ -55,6 +55,7 @@ const Menu = ({
|
|
|
55
55
|
<a
|
|
56
56
|
href="/"
|
|
57
57
|
dangerouslySetInnerHTML={{ __html: logo.html }}
|
|
58
|
+
aria-label={logo.alt || 'Logo'}
|
|
58
59
|
/>
|
|
59
60
|
)}
|
|
60
61
|
|
|
@@ -62,7 +63,11 @@ const Menu = ({
|
|
|
62
63
|
<ul>
|
|
63
64
|
{items.map((item, index) => (
|
|
64
65
|
<li key={index}>
|
|
65
|
-
<a
|
|
66
|
+
<a
|
|
67
|
+
href={item.url}
|
|
68
|
+
target={item.target}
|
|
69
|
+
className={item.active ? styles.active : undefined}
|
|
70
|
+
>
|
|
66
71
|
{item.name}
|
|
67
72
|
</a>
|
|
68
73
|
</li>
|
|
@@ -84,6 +89,7 @@ const Menu = ({
|
|
|
84
89
|
<a
|
|
85
90
|
href="/"
|
|
86
91
|
dangerouslySetInnerHTML={{ __html: logo.html }}
|
|
92
|
+
aria-label={logo.alt || 'Logo'}
|
|
87
93
|
/>
|
|
88
94
|
)}
|
|
89
95
|
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
.menu {
|
|
4
4
|
@include background(primary-70);
|
|
5
5
|
@include spacing(p-md);
|
|
6
|
-
@include typography(md);
|
|
7
6
|
@include border(bottom, primary-50);
|
|
8
7
|
@include position(sticky, t0);
|
|
9
8
|
@include layer(header);
|
|
@@ -75,6 +74,10 @@
|
|
|
75
74
|
&:hover {
|
|
76
75
|
@include typography(primary);
|
|
77
76
|
}
|
|
77
|
+
|
|
78
|
+
&.active {
|
|
79
|
+
@include typography(primary);
|
|
80
|
+
}
|
|
78
81
|
}
|
|
79
82
|
}
|
|
80
83
|
|
package/components/Menu/menu.ts
CHANGED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
---
|
|
2
|
+
import type { ModalProps } from './modal'
|
|
3
|
+
|
|
4
|
+
import Button from '../Button/Button.astro'
|
|
5
|
+
|
|
6
|
+
import info from '../../icons/info.svg?raw'
|
|
7
|
+
import success from '../../icons/circle-check.svg?raw'
|
|
8
|
+
import warning from '../../icons/warning.svg?raw'
|
|
9
|
+
import alert from '../../icons/alert.svg?raw'
|
|
10
|
+
import closeIcon from '../../icons/close.svg?raw'
|
|
11
|
+
|
|
12
|
+
import styles from './modal.module.scss'
|
|
13
|
+
|
|
14
|
+
interface Props extends ModalProps {}
|
|
15
|
+
|
|
16
|
+
const iconMap = {
|
|
17
|
+
info,
|
|
18
|
+
success,
|
|
19
|
+
warning,
|
|
20
|
+
alert
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const {
|
|
24
|
+
title,
|
|
25
|
+
subTitle,
|
|
26
|
+
showCloseIcon = true,
|
|
27
|
+
closeOnEsc = true,
|
|
28
|
+
closeOnOverlay = true,
|
|
29
|
+
theme,
|
|
30
|
+
id,
|
|
31
|
+
className
|
|
32
|
+
} = Astro.props
|
|
33
|
+
|
|
34
|
+
const close = [
|
|
35
|
+
showCloseIcon && 'icon',
|
|
36
|
+
closeOnEsc && 'esc',
|
|
37
|
+
closeOnOverlay && 'overlay'
|
|
38
|
+
].filter(Boolean).join(',')
|
|
39
|
+
|
|
40
|
+
const classes = [
|
|
41
|
+
styles.modal,
|
|
42
|
+
theme && styles[theme],
|
|
43
|
+
className
|
|
44
|
+
]
|
|
45
|
+
---
|
|
46
|
+
|
|
47
|
+
<dialog
|
|
48
|
+
class:list={classes}
|
|
49
|
+
id={id}
|
|
50
|
+
data-close={close.length ? close : undefined}
|
|
51
|
+
>
|
|
52
|
+
{showCloseIcon && (
|
|
53
|
+
<Button
|
|
54
|
+
theme="flat"
|
|
55
|
+
className={styles.close}
|
|
56
|
+
data-id="close"
|
|
57
|
+
>
|
|
58
|
+
<Fragment set:html={closeIcon} />
|
|
59
|
+
</Button>
|
|
60
|
+
)}
|
|
61
|
+
{title && (
|
|
62
|
+
<strong class={styles.title}>
|
|
63
|
+
{theme && <Fragment set:html={iconMap[theme]} />}
|
|
64
|
+
{title}
|
|
65
|
+
</strong>
|
|
66
|
+
)}
|
|
67
|
+
{subTitle && <div class={styles.subTitle}>{subTitle}</div>}
|
|
68
|
+
<slot />
|
|
69
|
+
</dialog>
|
|
70
|
+
<div class={styles.overlay} />
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { ModalProps } from './modal'
|
|
3
|
+
|
|
4
|
+
import styles from './modal.module.scss'
|
|
5
|
+
import { classNames } from '../../utils/classNames'
|
|
6
|
+
|
|
7
|
+
import Button from '../Button/Button.svelte'
|
|
8
|
+
|
|
9
|
+
import info from '../../icons/info.svg?raw'
|
|
10
|
+
import success from '../../icons/circle-check.svg?raw'
|
|
11
|
+
import warning from '../../icons/warning.svg?raw'
|
|
12
|
+
import alert from '../../icons/alert.svg?raw'
|
|
13
|
+
import closeIcon from '../../icons/close.svg?raw'
|
|
14
|
+
|
|
15
|
+
export let title: ModalProps['title'] = ''
|
|
16
|
+
export let subTitle: ModalProps['subTitle'] = ''
|
|
17
|
+
export let showCloseIcon: ModalProps['showCloseIcon'] = true
|
|
18
|
+
export let closeOnEsc: ModalProps['closeOnEsc'] = true
|
|
19
|
+
export let closeOnOverlay: ModalProps['closeOnOverlay'] = true
|
|
20
|
+
export let theme: ModalProps['theme'] = null
|
|
21
|
+
export let id : ModalProps['className'] = ''
|
|
22
|
+
export let className: ModalProps['className'] = ''
|
|
23
|
+
|
|
24
|
+
const iconMap = {
|
|
25
|
+
info,
|
|
26
|
+
success,
|
|
27
|
+
warning,
|
|
28
|
+
alert
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const classes = classNames([
|
|
32
|
+
styles.modal,
|
|
33
|
+
theme && styles[theme],
|
|
34
|
+
className
|
|
35
|
+
])
|
|
36
|
+
|
|
37
|
+
const close = [
|
|
38
|
+
showCloseIcon && 'icon',
|
|
39
|
+
closeOnEsc && 'esc',
|
|
40
|
+
closeOnOverlay && 'overlay'
|
|
41
|
+
].filter(Boolean).join(',')
|
|
42
|
+
</script>
|
|
43
|
+
|
|
44
|
+
<dialog
|
|
45
|
+
class={classes}
|
|
46
|
+
id={id}
|
|
47
|
+
data-close={close.length ? close : undefined}
|
|
48
|
+
>
|
|
49
|
+
{#if showCloseIcon}
|
|
50
|
+
<Button
|
|
51
|
+
theme="flat"
|
|
52
|
+
className={styles.close}
|
|
53
|
+
data-id="close"
|
|
54
|
+
>
|
|
55
|
+
{@html closeIcon}
|
|
56
|
+
</Button>
|
|
57
|
+
{/if}
|
|
58
|
+
{#if title}
|
|
59
|
+
<strong class={styles.title}>
|
|
60
|
+
{#if theme}
|
|
61
|
+
{@html iconMap[theme]}
|
|
62
|
+
{/if}
|
|
63
|
+
{title}
|
|
64
|
+
</strong>
|
|
65
|
+
{/if}
|
|
66
|
+
{#if subTitle}
|
|
67
|
+
<div class={styles.subTitle}>{subTitle}</div>
|
|
68
|
+
{/if}
|
|
69
|
+
<slot />
|
|
70
|
+
</dialog>
|
|
71
|
+
<div class={styles.overlay} />
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import type { ReactModalProps } from './modal'
|
|
3
|
+
|
|
4
|
+
import styles from './modal.module.scss'
|
|
5
|
+
import { classNames } from '../../utils/classNames'
|
|
6
|
+
|
|
7
|
+
import Button from '../Button/Button.tsx'
|
|
8
|
+
|
|
9
|
+
import info from '../../icons/info.svg?raw'
|
|
10
|
+
import success from '../../icons/circle-check.svg?raw'
|
|
11
|
+
import warning from '../../icons/warning.svg?raw'
|
|
12
|
+
import alert from '../../icons/alert.svg?raw'
|
|
13
|
+
import closeIcon from '../../icons/close.svg?raw'
|
|
14
|
+
|
|
15
|
+
const iconMap = {
|
|
16
|
+
info,
|
|
17
|
+
success,
|
|
18
|
+
warning,
|
|
19
|
+
alert
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const Modal = ({
|
|
23
|
+
title,
|
|
24
|
+
subTitle,
|
|
25
|
+
showCloseIcon = true,
|
|
26
|
+
closeOnEsc = true,
|
|
27
|
+
closeOnOverlay = true,
|
|
28
|
+
theme,
|
|
29
|
+
id,
|
|
30
|
+
className,
|
|
31
|
+
children
|
|
32
|
+
}: ReactModalProps) => {
|
|
33
|
+
const classes = classNames([
|
|
34
|
+
styles.modal,
|
|
35
|
+
theme && styles[theme],
|
|
36
|
+
className
|
|
37
|
+
])
|
|
38
|
+
|
|
39
|
+
const close = [
|
|
40
|
+
showCloseIcon && 'icon',
|
|
41
|
+
closeOnEsc && 'esc',
|
|
42
|
+
closeOnOverlay && 'overlay'
|
|
43
|
+
].filter(Boolean).join(',')
|
|
44
|
+
|
|
45
|
+
return (
|
|
46
|
+
<React.Fragment>
|
|
47
|
+
<dialog
|
|
48
|
+
className={classes}
|
|
49
|
+
id={id}
|
|
50
|
+
data-close={close.length ? close : undefined}
|
|
51
|
+
>
|
|
52
|
+
{showCloseIcon && (
|
|
53
|
+
<Button
|
|
54
|
+
theme="flat"
|
|
55
|
+
className={styles.close}
|
|
56
|
+
data-id="close"
|
|
57
|
+
dangerouslySetInnerHTML={{ __html: closeIcon }}
|
|
58
|
+
/>
|
|
59
|
+
)}
|
|
60
|
+
{title && (
|
|
61
|
+
<strong
|
|
62
|
+
className={styles.title}
|
|
63
|
+
dangerouslySetInnerHTML={{
|
|
64
|
+
__html: theme ? iconMap[theme] + title : title
|
|
65
|
+
}}
|
|
66
|
+
/>
|
|
67
|
+
)}
|
|
68
|
+
{subTitle && <div className={styles.subTitle}>{subTitle}</div>}
|
|
69
|
+
{children}
|
|
70
|
+
</dialog>
|
|
71
|
+
<div className={styles.overlay} />
|
|
72
|
+
</React.Fragment>
|
|
73
|
+
)
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export default Modal
|