|
4 | 4 | * @property {string?} icon |
5 | 5 | * @property {number?} timeout |
6 | 6 | * @property {boolean?} closeable |
7 | | - * @property {'info'|'success'|'error'} type |
| 7 | + * @property {'info'|'success'|'warn'|'error'} type |
8 | 8 | */ |
9 | 9 | import van from '../van.min.js'; |
10 | 10 | import { getValue, loadStylesheet, getRandomId } from '../utils.js'; |
@@ -35,11 +35,7 @@ const Alert = (/** @type Properties */ props, /** @type Array<HTMLElement> */ .. |
35 | 35 | { |
36 | 36 | ...props, |
37 | 37 | id: elementId, |
38 | | - class: () => (getValue(props.class) ?? '') + ` tg-alert flex-row`, |
39 | | - style: () => { |
40 | | - const colors = alertTypeColors[getValue(props.type)]; |
41 | | - return `color: ${colors.color}; background-color: ${colors.backgroundColor};`; |
42 | | - }, |
| 38 | + class: () => `tg-alert flex-row ${getValue(props.class) ?? ''} tg-alert-${getValue(props.type)}`, |
43 | 39 | role: 'alert', |
44 | 40 | }, |
45 | 41 | () => { |
@@ -74,6 +70,34 @@ stylesheet.replace(` |
74 | 70 | font-size: 16px; |
75 | 71 | line-height: 24px; |
76 | 72 | } |
| 73 | +
|
| 74 | +.tg-alert-info { |
| 75 | + background-color: rgba(28, 131, 225, 0.1); |
| 76 | + color: rgb(0, 66, 128); |
| 77 | +} |
| 78 | +
|
| 79 | +.tg-alert-success { |
| 80 | + background-color: rgba(33, 195, 84, 0.1); |
| 81 | + color: rgb(23, 114, 51); |
| 82 | +} |
| 83 | +
|
| 84 | +.tg-alert-error { |
| 85 | + background-color: rgba(255, 43, 43, 0.09); |
| 86 | + color: rgb(125, 53, 59); |
| 87 | +} |
| 88 | +
|
| 89 | +.tg-alert-warn { |
| 90 | + background-color: rgba(255, 227, 18, 0.1); |
| 91 | + color: rgb(146, 108, 5); |
| 92 | +} |
| 93 | +
|
| 94 | +@media (prefers-color-scheme: dark) { |
| 95 | + .tg-alert-warn { |
| 96 | + background-color: rgba(255, 227, 18, 0.2); |
| 97 | + color: rgb(255, 255, 194); |
| 98 | + } |
| 99 | +} |
| 100 | +
|
77 | 101 | .tg-alert > .tg-icon { |
78 | 102 | color: inherit !important; |
79 | 103 | } |
|
0 commit comments