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/scss/global/theme.scss
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
--w-color-primary: #FFF;
|
|
8
8
|
--w-color-primary-10: #DDD;
|
|
9
9
|
--w-color-primary-20: #BBB;
|
|
10
|
-
--w-color-primary-30: #
|
|
10
|
+
--w-color-primary-30: #757575;
|
|
11
11
|
--w-color-primary-40: #333;
|
|
12
12
|
--w-color-primary-50: #252525;
|
|
13
13
|
--w-color-primary-60: #111;
|
|
@@ -22,9 +22,10 @@
|
|
|
22
22
|
--w-color-warning: #FF9F43;
|
|
23
23
|
--w-color-warning-accent: #f7AA61;
|
|
24
24
|
--w-color-warning-fg: #000;
|
|
25
|
-
--w-color-alert: #
|
|
25
|
+
--w-color-alert: #de3233;
|
|
26
26
|
--w-color-alert-accent: #EE5253;
|
|
27
27
|
--w-color-alert-fg: #FFF;
|
|
28
|
+
--w-color-overlay: #0000009e;
|
|
28
29
|
}
|
|
29
30
|
}
|
|
30
31
|
|
|
@@ -49,9 +50,10 @@
|
|
|
49
50
|
--w-color-warning: #FF9F43;
|
|
50
51
|
--w-color-warning-accent: #f7AA61;
|
|
51
52
|
--w-color-warning-fg: #000;
|
|
52
|
-
--w-color-alert: #
|
|
53
|
+
--w-color-alert: #de3233;
|
|
53
54
|
--w-color-alert-accent: #EE5253;
|
|
54
55
|
--w-color-alert-fg: #FFF;
|
|
56
|
+
--w-color-overlay: #0000009e;
|
|
55
57
|
}
|
|
56
58
|
}
|
|
57
59
|
|
|
@@ -61,78 +63,109 @@
|
|
|
61
63
|
--w-color-primary: #FFF;
|
|
62
64
|
--w-color-primary-10: #EEE;
|
|
63
65
|
--w-color-primary-20: #a5b7cf;
|
|
64
|
-
--w-color-primary-30: #
|
|
66
|
+
--w-color-primary-30: #667f9e;
|
|
65
67
|
--w-color-primary-40: #2d4463;
|
|
66
68
|
--w-color-primary-50: #20344e;
|
|
67
69
|
--w-color-primary-60: #101a2d;
|
|
68
70
|
--w-color-primary-70: #061321;
|
|
69
71
|
|
|
70
|
-
--w-color-info: #
|
|
71
|
-
--w-color-info-accent: #
|
|
72
|
-
--w-color-info-fg: #
|
|
73
|
-
--w-color-success: #
|
|
72
|
+
--w-color-info: #57a0ff;
|
|
73
|
+
--w-color-info-accent: #71afff;
|
|
74
|
+
--w-color-info-fg: #000;
|
|
75
|
+
--w-color-success: #10b59c;
|
|
74
76
|
--w-color-success-accent: #1DD1A1;
|
|
75
77
|
--w-color-success-fg: #000;
|
|
76
78
|
--w-color-warning: #FF9F43;
|
|
77
|
-
--w-color-warning-accent: #
|
|
79
|
+
--w-color-warning-accent: #feb570;
|
|
78
80
|
--w-color-warning-fg: #000;
|
|
79
|
-
--w-color-alert: #
|
|
80
|
-
--w-color-alert-accent: #
|
|
81
|
+
--w-color-alert: #ed3b3c;
|
|
82
|
+
--w-color-alert-accent: #fb6161;
|
|
81
83
|
--w-color-alert-fg: #FFF;
|
|
84
|
+
--w-color-overlay: #0017239e;
|
|
82
85
|
}
|
|
83
86
|
}
|
|
84
87
|
|
|
85
|
-
@if $theme ==
|
|
88
|
+
@if $theme == 'vintage' {
|
|
86
89
|
#{$selector} {
|
|
87
90
|
--w-color-scheme: dark;
|
|
88
|
-
--w-color-primary: #
|
|
89
|
-
--w-color-primary-10: #
|
|
90
|
-
--w-color-primary-20: #
|
|
91
|
-
--w-color-primary-30: #
|
|
92
|
-
--w-color-primary-40: #
|
|
93
|
-
--w-color-primary-50: #
|
|
94
|
-
--w-color-primary-60: #
|
|
95
|
-
--w-color-primary-70: #
|
|
91
|
+
--w-color-primary: #000;
|
|
92
|
+
--w-color-primary-10: #111;
|
|
93
|
+
--w-color-primary-20: #6b4430;
|
|
94
|
+
--w-color-primary-30: #d6ccc2;
|
|
95
|
+
--w-color-primary-40: #cbb39a;
|
|
96
|
+
--w-color-primary-50: #e8d0b7;
|
|
97
|
+
--w-color-primary-60: #f5e6d5;
|
|
98
|
+
--w-color-primary-70: #f5ebe0;
|
|
96
99
|
|
|
97
|
-
--w-color-info: #
|
|
100
|
+
--w-color-info: #6d95d1;
|
|
98
101
|
--w-color-info-accent: #48DBFB;
|
|
99
102
|
--w-color-info-fg: #000;
|
|
100
|
-
--w-color-success: #
|
|
103
|
+
--w-color-success: #85c8ba;
|
|
101
104
|
--w-color-success-accent: #1DD1A1;
|
|
102
105
|
--w-color-success-fg: #000;
|
|
103
|
-
--w-color-warning: #
|
|
106
|
+
--w-color-warning: #e79d6b;
|
|
104
107
|
--w-color-warning-accent: #f7AA61;
|
|
105
108
|
--w-color-warning-fg: #000;
|
|
106
|
-
--w-color-alert: #
|
|
109
|
+
--w-color-alert: #bf6170;
|
|
107
110
|
--w-color-alert-accent: #EE5253;
|
|
108
111
|
--w-color-alert-fg: #FFF;
|
|
112
|
+
--w-color-overlay: #0000009e;
|
|
109
113
|
}
|
|
110
114
|
}
|
|
111
115
|
|
|
112
|
-
@if $theme ==
|
|
116
|
+
@if $theme == 'amber' {
|
|
113
117
|
#{$selector} {
|
|
114
118
|
--w-color-scheme: dark;
|
|
115
|
-
--w-color-primary: #
|
|
116
|
-
--w-color-primary-10: #
|
|
117
|
-
--w-color-primary-20: #
|
|
118
|
-
--w-color-primary-30: #
|
|
119
|
-
--w-color-primary-40: #
|
|
120
|
-
--w-color-primary-50: #
|
|
121
|
-
--w-color-primary-60: #
|
|
122
|
-
--w-color-primary-70: #
|
|
119
|
+
--w-color-primary: #FFF;
|
|
120
|
+
--w-color-primary-10: #DDD;
|
|
121
|
+
--w-color-primary-20: #FFF3DB;
|
|
122
|
+
--w-color-primary-30: #757575;
|
|
123
|
+
--w-color-primary-40: #232323;
|
|
124
|
+
--w-color-primary-50: #312e31;
|
|
125
|
+
--w-color-primary-60: #1b1b1b;
|
|
126
|
+
--w-color-primary-70: #111;
|
|
123
127
|
|
|
124
|
-
--w-color-info: #
|
|
128
|
+
--w-color-info: #78dcdc;
|
|
125
129
|
--w-color-info-accent: #48DBFB;
|
|
126
130
|
--w-color-info-fg: #000;
|
|
127
|
-
--w-color-success: #
|
|
128
|
-
--w-color-success-accent: #
|
|
131
|
+
--w-color-success: #a9dc62;
|
|
132
|
+
--w-color-success-accent: #97da3b;
|
|
129
133
|
--w-color-success-fg: #000;
|
|
130
|
-
--w-color-warning: #
|
|
134
|
+
--w-color-warning: #FCBA28;
|
|
131
135
|
--w-color-warning-accent: #f7AA61;
|
|
132
136
|
--w-color-warning-fg: #000;
|
|
133
|
-
--w-color-alert: #
|
|
137
|
+
--w-color-alert: #ff6188;
|
|
138
|
+
--w-color-alert-accent: #EE5253;
|
|
139
|
+
--w-color-alert-fg: #000;
|
|
140
|
+
--w-color-overlay: #0000009e;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
@if $theme == 'synthwave' {
|
|
145
|
+
#{$selector} {
|
|
146
|
+
--w-color-scheme: dark;
|
|
147
|
+
--w-color-primary: #FFF;
|
|
148
|
+
--w-color-primary-10: #EEE;
|
|
149
|
+
--w-color-primary-20: #fad5c0;
|
|
150
|
+
--w-color-primary-30: #eabfff;
|
|
151
|
+
--w-color-primary-40: #8212ba;
|
|
152
|
+
--w-color-primary-50: #9D2BD6;
|
|
153
|
+
--w-color-primary-60: #0f1b33;
|
|
154
|
+
--w-color-primary-70: #030d1e;
|
|
155
|
+
|
|
156
|
+
--w-color-info: #1c98ff;
|
|
157
|
+
--w-color-info-accent: #6be4ff;
|
|
158
|
+
--w-color-info-fg: #000;
|
|
159
|
+
--w-color-success: #83e300;
|
|
160
|
+
--w-color-success-accent: #b7ff51;
|
|
161
|
+
--w-color-success-fg: #000;
|
|
162
|
+
--w-color-warning: #FF9F43;
|
|
163
|
+
--w-color-warning-accent: #ffb672;
|
|
164
|
+
--w-color-warning-fg: #000;
|
|
165
|
+
--w-color-alert: #ff3333;
|
|
134
166
|
--w-color-alert-accent: #EE5253;
|
|
135
167
|
--w-color-alert-fg: #FFF;
|
|
168
|
+
--w-color-overlay: #13002cc2;
|
|
136
169
|
}
|
|
137
170
|
}
|
|
138
171
|
}
|
package/scss/global/tooltip.scss
CHANGED
|
@@ -8,6 +8,8 @@
|
|
|
8
8
|
|
|
9
9
|
[data-tooltip] {
|
|
10
10
|
@include position(relative);
|
|
11
|
+
@include typography(normal);
|
|
12
|
+
|
|
11
13
|
display: inline-block;
|
|
12
14
|
|
|
13
15
|
&::before,
|
|
@@ -24,7 +26,7 @@
|
|
|
24
26
|
&::before {
|
|
25
27
|
@include border-radius(md);
|
|
26
28
|
@include position(absolute);
|
|
27
|
-
@include typography(
|
|
29
|
+
@include typography(md, hlg);
|
|
28
30
|
@include background(var(--w-tooltip-background));
|
|
29
31
|
@include size(wmax-content);
|
|
30
32
|
@include spacing(px-xs);
|
|
@@ -94,7 +96,7 @@
|
|
|
94
96
|
@include border(5px, top, transparent);
|
|
95
97
|
@include border(5px, bottom, transparent);
|
|
96
98
|
|
|
97
|
-
top: calc(50%
|
|
99
|
+
top: calc(50%);
|
|
98
100
|
border-left: 5px solid var(--w-tooltip-background);
|
|
99
101
|
transform: translate(10px, -50%);
|
|
100
102
|
}
|
|
@@ -123,7 +125,7 @@
|
|
|
123
125
|
@include border(5px, top, transparent);
|
|
124
126
|
@include border(5px, bottom, transparent);
|
|
125
127
|
|
|
126
|
-
top: calc(50%
|
|
128
|
+
top: calc(50%);
|
|
127
129
|
border-right: 5px solid var(--w-tooltip-background);
|
|
128
130
|
transform: translate(-10px, -50%);
|
|
129
131
|
}
|
package/scss/global/utility.scss
CHANGED
|
@@ -1,88 +1,106 @@
|
|
|
1
|
+
@use 'sass:string';
|
|
2
|
+
@use 'sass:meta';
|
|
3
|
+
@use 'sass:list';
|
|
4
|
+
@use 'sass:map';
|
|
1
5
|
@use '../config' as *;
|
|
2
6
|
|
|
7
|
+
$breakpointMap: (
|
|
8
|
+
'xs': 3,
|
|
9
|
+
'sm': 4,
|
|
10
|
+
'md': 6,
|
|
11
|
+
'lg': 8
|
|
12
|
+
);
|
|
13
|
+
|
|
14
|
+
$alignments: (
|
|
15
|
+
'items-center': center,
|
|
16
|
+
'items-start': flex-start,
|
|
17
|
+
'items-end': flex-end,
|
|
18
|
+
'items-baseline': baseline,
|
|
19
|
+
'items-stretch': stretch,
|
|
20
|
+
|
|
21
|
+
'justify-center': center,
|
|
22
|
+
'justify-start': flex-start,
|
|
23
|
+
'justify-end': flex-end,
|
|
24
|
+
'justify-between': space-between,
|
|
25
|
+
'justify-around': space-around,
|
|
26
|
+
'justify-evenly': space-evenly,
|
|
27
|
+
'justify-stretch': stretch
|
|
28
|
+
);
|
|
29
|
+
|
|
3
30
|
@mixin utility() {
|
|
4
31
|
.container {
|
|
5
|
-
|
|
32
|
+
@include spacing(auto-none, px-default);
|
|
6
33
|
max-width: 1200px;
|
|
7
|
-
padding: 0 20px;
|
|
8
34
|
}
|
|
9
35
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
36
|
+
// Gaps
|
|
37
|
+
.flex, .grid {
|
|
38
|
+
@each $key, $value in $spacing {
|
|
39
|
+
$numberList: ('2', '3', '4', '5');
|
|
40
|
+
$firstLetter: string.slice($key, 1, 1);
|
|
41
|
+
$class: $key;
|
|
42
|
+
|
|
43
|
+
@if (list.index($numberList, $firstLetter)) {
|
|
44
|
+
$class: string.slice($key, 2, -1) + $firstLetter;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
&.#{$class} { gap: $value; }
|
|
16
48
|
}
|
|
17
49
|
}
|
|
18
50
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
&.xs {
|
|
28
|
-
gap: 5px;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
&.sm {
|
|
32
|
-
gap: 10px;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
&.wrap {
|
|
36
|
-
flex-wrap: wrap;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
&.center {
|
|
40
|
-
justify-content: center;
|
|
41
|
-
align-items: center;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
&.justify-center {
|
|
45
|
-
justify-content: center;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
&.items-center {
|
|
49
|
-
align-items: center;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
&.items-start {
|
|
53
|
-
align-items: flex-start;
|
|
51
|
+
// Alignments
|
|
52
|
+
@each $key, $value in $alignments {
|
|
53
|
+
.#{$key} {
|
|
54
|
+
@if (string.index($key, 'items')) {
|
|
55
|
+
align-items: $value;
|
|
56
|
+
} @else {
|
|
57
|
+
justify-content: $value;
|
|
58
|
+
}
|
|
54
59
|
}
|
|
55
60
|
}
|
|
56
61
|
|
|
57
|
-
.
|
|
58
|
-
|
|
62
|
+
.flex.center,
|
|
63
|
+
.grid.center {
|
|
64
|
+
justify-content: center;
|
|
65
|
+
align-items: center;
|
|
59
66
|
}
|
|
60
67
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
grid-template-columns: repeat(2, minmax(0, 1fr));
|
|
64
|
-
}
|
|
68
|
+
.flex {
|
|
69
|
+
@include layout(flex, default);
|
|
65
70
|
|
|
66
|
-
|
|
67
|
-
|
|
71
|
+
@each $direction in $flexDirectionValues {
|
|
72
|
+
&.#{$direction} {
|
|
73
|
+
flex-direction: $direction;
|
|
74
|
+
}
|
|
68
75
|
}
|
|
69
76
|
|
|
70
|
-
|
|
71
|
-
|
|
77
|
+
@each $wrap in $flexWrapValues {
|
|
78
|
+
&.#{$wrap} {
|
|
79
|
+
flex-wrap: $wrap;
|
|
80
|
+
}
|
|
72
81
|
}
|
|
73
82
|
}
|
|
74
83
|
|
|
75
|
-
|
|
76
|
-
|
|
84
|
+
.grid {
|
|
85
|
+
@include layout(grid, default);
|
|
86
|
+
|
|
87
|
+
&.col-2 {
|
|
77
88
|
grid-template-columns: repeat(2, minmax(0, 1fr));
|
|
78
89
|
}
|
|
79
90
|
|
|
80
|
-
|
|
91
|
+
&.col-3 {
|
|
81
92
|
grid-template-columns: repeat(3, minmax(0, 1fr));
|
|
82
93
|
}
|
|
94
|
+
}
|
|
83
95
|
|
|
84
|
-
|
|
85
|
-
|
|
96
|
+
// Grid columns
|
|
97
|
+
@each $key, $value in $breakpoints {
|
|
98
|
+
@include media($key) {
|
|
99
|
+
@for $i from 2 to map.get($breakpointMap, $key) + 1 {
|
|
100
|
+
.grid.#{$key}-#{$i} {
|
|
101
|
+
grid-template-columns: repeat($i, minmax(0, 1fr));
|
|
102
|
+
}
|
|
103
|
+
}
|
|
86
104
|
}
|
|
87
105
|
}
|
|
88
106
|
}
|
package/scss/resets.scss
CHANGED
|
@@ -53,11 +53,11 @@
|
|
|
53
53
|
pre {
|
|
54
54
|
@include border(primary-50);
|
|
55
55
|
@include border-radius(md);
|
|
56
|
-
@include typography(
|
|
56
|
+
@include typography(md);
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
code {
|
|
60
|
-
@include spacing(
|
|
60
|
+
@include spacing(px-sm);
|
|
61
61
|
display: inline-block;
|
|
62
62
|
}
|
|
63
63
|
|
|
@@ -73,7 +73,7 @@
|
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
figcaption {
|
|
76
|
-
@include typography(
|
|
76
|
+
@include typography(md, primary-20);
|
|
77
77
|
|
|
78
78
|
a {
|
|
79
79
|
@include typography(primary-20);
|
|
@@ -85,7 +85,7 @@
|
|
|
85
85
|
}
|
|
86
86
|
|
|
87
87
|
p, ul, ol {
|
|
88
|
-
@include typography(
|
|
88
|
+
@include typography(hlg);
|
|
89
89
|
@include spacing(my-default);
|
|
90
90
|
}
|
|
91
91
|
|
|
@@ -94,8 +94,13 @@
|
|
|
94
94
|
}
|
|
95
95
|
|
|
96
96
|
blockquote {
|
|
97
|
-
@include typography(md);
|
|
98
97
|
@include spacing(my-default, mx-none, pl-default);
|
|
99
98
|
@include border(2px, left, primary-30);
|
|
100
99
|
}
|
|
100
|
+
|
|
101
|
+
hr {
|
|
102
|
+
@include size('w100%', h1px);
|
|
103
|
+
@include border(0);
|
|
104
|
+
@include background(primary-50);
|
|
105
|
+
}
|
|
101
106
|
}
|
package/scss/setup.scss
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
$config: (
|
|
4
4
|
includeResets: true,
|
|
5
|
-
|
|
5
|
+
includeUtilities: true,
|
|
6
6
|
includeTooltip: true,
|
|
7
7
|
includeScrollbarStyles: true
|
|
8
8
|
);
|
|
@@ -25,7 +25,7 @@ body {
|
|
|
25
25
|
@include resets();
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
@if (config('
|
|
28
|
+
@if (config('includeUtilities')) {
|
|
29
29
|
@include utility();
|
|
30
30
|
}
|
|
31
31
|
|
package/svelte.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 { SvelteInputProps } 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 { SvelteRadioProps } from './components/Radio/radio'
|
|
14
15
|
import type { RatingProps } from './components/Rating/rating'
|
|
16
|
+
import type { SvelteSliderProps } from './components/Slider/slider'
|
|
15
17
|
import type { SpinnerProps } from './components/Spinner/spinner'
|
|
16
18
|
import type { SvelteSwitchProps } from './components/Switch/switch'
|
|
17
19
|
import type { TableProps } from './components/Table/table'
|
|
@@ -33,9 +35,11 @@ declare module 'webcoreui/svelte' {
|
|
|
33
35
|
export function Icon(_props: IconProps): any
|
|
34
36
|
export function Input(_props: SvelteInputProps): 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: SvelteRadioProps): any
|
|
38
41
|
export function Rating(_props: RatingProps): any
|
|
42
|
+
export function Slider(_props: SvelteSliderProps): any
|
|
39
43
|
export function Spinner(_props: SpinnerProps): any
|
|
40
44
|
export function Switch(_props: SvelteSwitchProps): any
|
|
41
45
|
export function Table(_props: TableProps): any
|
package/svelte.js
CHANGED
|
@@ -9,9 +9,11 @@ import ConditionalWrapperComponent from './components/ConditionalWrapper/Conditi
|
|
|
9
9
|
import IconComponent from './components/Icon/Icon.svelte'
|
|
10
10
|
import InputComponent from './components/Input/Input.svelte'
|
|
11
11
|
import MenuComponent from './components/Menu/Menu.svelte'
|
|
12
|
+
import ModalComponent from './components/Modal/Modal.svelte'
|
|
12
13
|
import ProgressComponent from './components/Progress/Progress.svelte'
|
|
13
14
|
import RadioComponent from './components/Radio/Radio.svelte'
|
|
14
15
|
import RatingComponent from './components/Rating/Rating.svelte'
|
|
16
|
+
import SliderComponent from './components/Slider/Slider.svelte'
|
|
15
17
|
import SpinnerComponent from './components/Spinner/Spinner.svelte'
|
|
16
18
|
import SwitchComponent from './components/Switch/Switch.svelte'
|
|
17
19
|
import TableComponent from './components/Table/Table.svelte'
|
|
@@ -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
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export const clamp = (
|
|
2
|
+
num: number,
|
|
3
|
+
min: number,
|
|
4
|
+
max: number
|
|
5
|
+
) => Math.min(Math.max(num, min), max)
|
|
6
|
+
|
|
7
|
+
export const lerp = (
|
|
8
|
+
x: number,
|
|
9
|
+
y: number,
|
|
10
|
+
z: number
|
|
11
|
+
) => x * (1 - z) + y * z
|
|
12
|
+
|
|
13
|
+
export const invlerp = (
|
|
14
|
+
x: number,
|
|
15
|
+
y: number,
|
|
16
|
+
z: number
|
|
17
|
+
) => clamp((z - x) / (y - x), 0, 1)
|
|
18
|
+
|
|
19
|
+
export const interpolate = (
|
|
20
|
+
value: number,
|
|
21
|
+
input: [x: number, y: number],
|
|
22
|
+
output: [x: number, y: number],
|
|
23
|
+
) => lerp(output[0], output[1], invlerp(input[0], input[1], value))
|
package/utils/modal.ts
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
export const modal = (element: string) => {
|
|
2
|
+
const htmlElement = document.querySelector(element) as HTMLElement
|
|
3
|
+
|
|
4
|
+
if (htmlElement) {
|
|
5
|
+
const handleClose = {
|
|
6
|
+
icon: () => {
|
|
7
|
+
const close = htmlElement.querySelector('[data-id="close"]')
|
|
8
|
+
|
|
9
|
+
const listener = () => {
|
|
10
|
+
htmlElement.dataset.show = ''
|
|
11
|
+
|
|
12
|
+
close?.removeEventListener('click', listener)
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
close?.addEventListener('click', listener)
|
|
16
|
+
},
|
|
17
|
+
|
|
18
|
+
esc: () => {
|
|
19
|
+
const listener = (event: KeyboardEvent) => {
|
|
20
|
+
if (event.key === 'Escape') {
|
|
21
|
+
htmlElement.dataset.show = ''
|
|
22
|
+
|
|
23
|
+
document.removeEventListener('keydown', listener)
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
document.addEventListener('keydown', listener)
|
|
28
|
+
},
|
|
29
|
+
|
|
30
|
+
overlay: () => {
|
|
31
|
+
const close = htmlElement.nextElementSibling
|
|
32
|
+
|
|
33
|
+
const listener = () => {
|
|
34
|
+
htmlElement.dataset.show = ''
|
|
35
|
+
|
|
36
|
+
close?.removeEventListener('click', listener)
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
close?.addEventListener('click', listener)
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const closeOptions = htmlElement.dataset.close?.split(',')
|
|
44
|
+
|
|
45
|
+
htmlElement.dataset.show = 'true'
|
|
46
|
+
|
|
47
|
+
closeOptions?.forEach(option => {
|
|
48
|
+
handleClose[option as keyof typeof handleClose]()
|
|
49
|
+
})
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export const closeModal = (element: string) => {
|
|
54
|
+
const htmlElement = document.querySelector(element) as HTMLElement
|
|
55
|
+
|
|
56
|
+
if (htmlElement) {
|
|
57
|
+
htmlElement.dataset.show = ''
|
|
58
|
+
}
|
|
59
|
+
}
|