lapikit 0.5.5 → 0.5.6
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.
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { useClassName, useStyles } from '../../utils';
|
|
3
3
|
import { makeComponentProps } from '../../html-mapped';
|
|
4
|
-
import type {
|
|
4
|
+
import type { AlertProps, AlertTone, AlertVariant, AlertDensity } from './alert.types.js';
|
|
5
5
|
|
|
6
6
|
function resolveVariant(value: AlertVariant | undefined): AlertVariant {
|
|
7
7
|
return value === 'filled' || value === 'outline' || value === 'text' ? value : 'filled';
|
|
@@ -13,25 +13,8 @@
|
|
|
13
13
|
: 'default';
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
function resolveTone({
|
|
17
|
-
|
|
18
|
-
info,
|
|
19
|
-
success,
|
|
20
|
-
warning,
|
|
21
|
-
error
|
|
22
|
-
}: {
|
|
23
|
-
tone?: AlertTone;
|
|
24
|
-
info?: boolean;
|
|
25
|
-
success?: boolean;
|
|
26
|
-
warning?: boolean;
|
|
27
|
-
error?: boolean;
|
|
28
|
-
}): AlertTone {
|
|
29
|
-
if (tone && ['default', 'info', 'success', 'warning', 'error'].includes(tone)) return tone;
|
|
30
|
-
if (error) return 'error';
|
|
31
|
-
if (warning) return 'warning';
|
|
32
|
-
if (success) return 'success';
|
|
33
|
-
if (info) return 'info';
|
|
34
|
-
return 'default';
|
|
16
|
+
function resolveTone(value: AlertTone | undefined): AlertTone {
|
|
17
|
+
return value && ['info', 'success', 'warning', 'error'].includes(value) ? value : 'default';
|
|
35
18
|
}
|
|
36
19
|
|
|
37
20
|
let {
|
|
@@ -48,10 +31,6 @@
|
|
|
48
31
|
density = 'default',
|
|
49
32
|
rounded = 'md',
|
|
50
33
|
tone = 'default',
|
|
51
|
-
info = false,
|
|
52
|
-
success = false,
|
|
53
|
-
warning = false,
|
|
54
|
-
error = false,
|
|
55
34
|
color = undefined,
|
|
56
35
|
background = undefined,
|
|
57
36
|
prepend = undefined,
|
|
@@ -83,7 +62,7 @@
|
|
|
83
62
|
|
|
84
63
|
let safeVariant = $derived(resolveVariant(variant));
|
|
85
64
|
let safeDensity = $derived(resolveDensity(density));
|
|
86
|
-
let safeTone = $derived(resolveTone(
|
|
65
|
+
let safeTone = $derived(resolveTone(tone));
|
|
87
66
|
let mergedStyle = $derived(
|
|
88
67
|
[
|
|
89
68
|
baseStyle,
|
|
@@ -171,7 +150,7 @@
|
|
|
171
150
|
.kit-alert[data-variant='outline'] {
|
|
172
151
|
background: transparent;
|
|
173
152
|
color: var(--kit-alert-fg);
|
|
174
|
-
border-color:
|
|
153
|
+
border-color: var(--kit-alert-bd);
|
|
175
154
|
}
|
|
176
155
|
|
|
177
156
|
.kit-alert[data-variant='text'] {
|
|
@@ -185,29 +164,48 @@
|
|
|
185
164
|
}
|
|
186
165
|
|
|
187
166
|
.kit-alert[data-tone='info'] {
|
|
167
|
+
--kit-alert-tone-accent: hsl(var(--kit-h-info, 205) 60% 42%);
|
|
188
168
|
--kit-alert-bg: hsl(var(--kit-h-info, 205) 90% 95%);
|
|
189
169
|
--kit-alert-fg: hsl(var(--kit-h-info, 205) 36% 24%);
|
|
190
170
|
--kit-alert-bd: hsl(var(--kit-h-info, 205) 45% 78%);
|
|
191
171
|
}
|
|
192
172
|
|
|
193
173
|
.kit-alert[data-tone='success'] {
|
|
174
|
+
--kit-alert-tone-accent: hsl(var(--kit-h-success, 145) 50% 38%);
|
|
194
175
|
--kit-alert-bg: hsl(var(--kit-h-success, 145) 58% 93%);
|
|
195
176
|
--kit-alert-fg: hsl(var(--kit-h-success, 145) 38% 23%);
|
|
196
177
|
--kit-alert-bd: hsl(var(--kit-h-success, 145) 30% 75%);
|
|
197
178
|
}
|
|
198
179
|
|
|
199
180
|
.kit-alert[data-tone='warning'] {
|
|
181
|
+
--kit-alert-tone-accent: hsl(var(--kit-h-warning, 35) 80% 38%);
|
|
200
182
|
--kit-alert-bg: hsl(var(--kit-h-warning, 35) 95% 92%);
|
|
201
183
|
--kit-alert-fg: hsl(var(--kit-h-warning, 35) 55% 24%);
|
|
202
184
|
--kit-alert-bd: hsl(var(--kit-h-warning, 35) 55% 72%);
|
|
203
185
|
}
|
|
204
186
|
|
|
205
187
|
.kit-alert[data-tone='error'] {
|
|
188
|
+
--kit-alert-tone-accent: hsl(var(--kit-h-danger, 5) 65% 45%);
|
|
206
189
|
--kit-alert-bg: hsl(var(--kit-h-danger, 5) 90% 94%);
|
|
207
190
|
--kit-alert-fg: hsl(var(--kit-h-danger, 5) 48% 28%);
|
|
208
191
|
--kit-alert-bd: hsl(var(--kit-h-danger, 5) 55% 78%);
|
|
209
192
|
}
|
|
210
193
|
|
|
194
|
+
.kit-alert[data-variant='outline'][data-tone='info'],
|
|
195
|
+
.kit-alert[data-variant='outline'][data-tone='success'],
|
|
196
|
+
.kit-alert[data-variant='outline'][data-tone='warning'],
|
|
197
|
+
.kit-alert[data-variant='outline'][data-tone='error'] {
|
|
198
|
+
--kit-alert-fg: var(--kit-alert-tone-accent);
|
|
199
|
+
--kit-alert-bd: var(--kit-alert-tone-accent);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
.kit-alert[data-variant='text'][data-tone='info'],
|
|
203
|
+
.kit-alert[data-variant='text'][data-tone='success'],
|
|
204
|
+
.kit-alert[data-variant='text'][data-tone='warning'],
|
|
205
|
+
.kit-alert[data-variant='text'][data-tone='error'] {
|
|
206
|
+
--kit-alert-fg: var(--kit-alert-tone-accent);
|
|
207
|
+
}
|
|
208
|
+
|
|
211
209
|
.kit-alert[data-density='compact'] {
|
|
212
210
|
--kit-alert-py: 0.5rem;
|
|
213
211
|
--kit-alert-px: 0.75rem;
|
|
@@ -12,10 +12,6 @@ export interface AlertProps extends Component {
|
|
|
12
12
|
density?: AlertDensity;
|
|
13
13
|
rounded?: RoundedType;
|
|
14
14
|
tone?: AlertTone;
|
|
15
|
-
info?: boolean;
|
|
16
|
-
success?: boolean;
|
|
17
|
-
warning?: boolean;
|
|
18
|
-
error?: boolean;
|
|
19
15
|
color?: string;
|
|
20
16
|
background?: string;
|
|
21
17
|
prepend?: Snippet;
|