@justin_evo/evo-ui 1.2.0 → 1.2.1
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/LICENSE +21 -21
- package/README.md +70 -70
- package/dist/declarations.d.ts +6 -6
- package/package.json +52 -52
- package/src/Alert/Alert.tsx +49 -49
- package/src/AutoComplete/AutoComplete.tsx +810 -810
- package/src/Badge/Badge.tsx +53 -53
- package/src/Breadcrumb/Breadcrumb.tsx +53 -53
- package/src/Button/Button.tsx +125 -125
- package/src/Card/Card.tsx +257 -257
- package/src/Checkbox/Checkbox.tsx +59 -59
- package/src/CommandPalette/CommandPalette.tsx +185 -185
- package/src/Container/Container.tsx +31 -31
- package/src/Divider/Divider.tsx +31 -31
- package/src/Form/Form.tsx +185 -185
- package/src/Grid/Grid.tsx +66 -66
- package/src/ImageCropper/ImageCropper.tsx +911 -911
- package/src/Input/Input.tsx +74 -74
- package/src/Modal/Modal.tsx +77 -77
- package/src/Nav/Nav.tsx +708 -708
- package/src/Notification/Notification.tsx +1503 -1503
- package/src/Pagination/Pagination.tsx +76 -76
- package/src/Radio/Radio.tsx +69 -69
- package/src/RichTextArea/RichTextArea.tsx +886 -886
- package/src/Select/Select.tsx +515 -515
- package/src/Skeleton/Skeleton.tsx +70 -70
- package/src/Stack/Stack.tsx +52 -52
- package/src/Table/Table.tsx +335 -335
- package/src/Tabs/Tabs.tsx +90 -90
- package/src/Theme/ThemeProvider.tsx +253 -253
- package/src/Theme/ThemeToggle.tsx +79 -79
- package/src/Toggle/Toggle.tsx +48 -48
- package/src/Tooltip/Tooltip.tsx +38 -38
- package/src/TopNav/TopNav.tsx +1163 -1163
- package/src/TreeSelect/TreeSelect.tsx +825 -825
- package/src/css/alert.module.scss +93 -93
- package/src/css/autocomplete.module.scss +416 -416
- package/src/css/badge.module.scss +82 -82
- package/src/css/base/_color.scss +159 -159
- package/src/css/base/_theme.scss +237 -237
- package/src/css/base/_variables.scss +161 -161
- package/src/css/breadcrumb.module.scss +50 -50
- package/src/css/button.module.scss +385 -385
- package/src/css/card.module.scss +217 -217
- package/src/css/checkbox.module.scss +123 -123
- package/src/css/commandpalette.module.scss +211 -211
- package/src/css/container.module.scss +18 -18
- package/src/css/divider.module.scss +41 -41
- package/src/css/form.module.scss +245 -245
- package/src/css/imagecropper.module.scss +397 -397
- package/src/css/input.module.scss +89 -89
- package/src/css/modal.module.scss +105 -105
- package/src/css/nav.module.scss +494 -494
- package/src/css/notification.module.scss +691 -691
- package/src/css/pagination.module.scss +63 -63
- package/src/css/radio.module.scss +89 -89
- package/src/css/richtextarea.module.scss +307 -307
- package/src/css/select.module.scss +525 -525
- package/src/css/skeleton.module.scss +30 -30
- package/src/css/table.module.scss +386 -386
- package/src/css/tabs.module.scss +63 -63
- package/src/css/theme-toggle.module.scss +83 -83
- package/src/css/toggle.module.scss +54 -54
- package/src/css/tooltip.module.scss +97 -97
- package/src/css/topnav.module.scss +568 -568
- package/src/css/treeselect.module.scss +558 -558
- package/src/css/utilities/_borders.scss +111 -111
- package/src/css/utilities/_colors.scss +66 -66
- package/src/css/utilities/_effects.scss +216 -216
- package/src/css/utilities/_layout.scss +181 -181
- package/src/css/utilities/_position.scss +75 -75
- package/src/css/utilities/_sizing.scss +138 -138
- package/src/css/utilities/_spacing.scss +99 -99
- package/src/css/utilities/_typography.scss +121 -121
- package/src/css/utilities/index.scss +24 -24
- package/src/declarations.d.ts +6 -6
- package/src/index.ts +60 -60
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2026 Justin Khor
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Justin Khor
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,70 +1,70 @@
|
|
|
1
|
-
# Evo UI
|
|
2
|
-
|
|
3
|
-
**A high-performance, enterprise-grade React UI component library.**
|
|
4
|
-
|
|
5
|
-
Evo UI ships 30+ accessible, themeable React components — with built-in light &
|
|
6
|
-
dark mode, full TypeScript types, `forwardRef` + native attribute pass-through,
|
|
7
|
-
and **zero runtime dependencies**.
|
|
8
|
-
|
|
9
|
-
- 📚 **Documentation:** https://elevora
|
|
10
|
-
- 💻 **GitHub:** https://github.com/jinchuen/evo
|
|
11
|
-
- 📦 **npm:** https://www.npmjs.com/package/@justin_evo/evo-ui
|
|
12
|
-
|
|
13
|
-
## Installation
|
|
14
|
-
|
|
15
|
-
```bash
|
|
16
|
-
npm install @justin_evo/evo-ui
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
`react` and `react-dom` (>= 17) are peer dependencies. Evo UI itself has no
|
|
20
|
-
runtime dependencies.
|
|
21
|
-
|
|
22
|
-
## Quick start
|
|
23
|
-
|
|
24
|
-
```jsx
|
|
25
|
-
// Import the stylesheet once in your app entry (includes the light/dark theme tokens)
|
|
26
|
-
import '@justin_evo/evo-ui/dist/evo-ui.css'
|
|
27
|
-
|
|
28
|
-
import { EvoThemeProvider, EvoButton } from '@justin_evo/evo-ui'
|
|
29
|
-
|
|
30
|
-
export default function App() {
|
|
31
|
-
return (
|
|
32
|
-
<EvoThemeProvider defaultTheme="system">
|
|
33
|
-
<EvoButton variant="solid" severity="primary">Hello Evo</EvoButton>
|
|
34
|
-
</EvoThemeProvider>
|
|
35
|
-
)
|
|
36
|
-
}
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
## Why Evo UI
|
|
40
|
-
|
|
41
|
-
- 🌗 **Light & dark mode** out of the box — CSS-variable theming, no runtime cost.
|
|
42
|
-
- 📱 **Mobile-ready** — ≥ 44px touch targets, responsive down to 375px.
|
|
43
|
-
- 🔡 **Fully typed** — ships `.d.ts`; every component forwards `ref` and native attributes.
|
|
44
|
-
- 🧩 **Composable, orthogonal APIs** — e.g. `<Form.Field><Form.Label /></Form.Field>`.
|
|
45
|
-
- 🪶 **Zero runtime dependencies.**
|
|
46
|
-
|
|
47
|
-
## Components
|
|
48
|
-
|
|
49
|
-
Full props, variants, and live examples for every component live in the
|
|
50
|
-
[documentation](https://elevora
|
|
51
|
-
|
|
52
|
-
| Category | Components |
|
|
53
|
-
| ---------------------- | ---------------------------------------------------------------------------------------------------------- |
|
|
54
|
-
| **Theming** | `EvoThemeProvider`, `EvoThemeToggle` |
|
|
55
|
-
| **Layout & structure** | `EvoStack`, `EvoGrid`, `EvoDivider`, `EvoContainer`, `EvoCard` |
|
|
56
|
-
| **Navigation** | `EvoTabs`, `EvoBreadcrumb`, `EvoNav`, `EvoTopNav`, `EvoPagination`, `EvoCommandPalette` |
|
|
57
|
-
| **Forms & inputs** | `EvoInput`, `EvoRichTextArea`, `EvoSelect`, `EvoTreeSelect`, `EvoAutoComplete`, `EvoCheckbox`, `EvoRadio`, `EvoToggle`, `EvoForm` |
|
|
58
|
-
| **Feedback & overlays**| `EvoModal`, `EvoNotification`, `EvoTooltip`, `EvoAlert` |
|
|
59
|
-
| **Data display** | `EvoBadge`, `EvoSkeleton`, `EvoTable` |
|
|
60
|
-
| **General** | `EvoButton` |
|
|
61
|
-
| **Media** | `EvoImageCropper` |
|
|
62
|
-
|
|
63
|
-
## Documentation
|
|
64
|
-
|
|
65
|
-
Browse the full component catalogue, prop tables, and copy-paste examples at
|
|
66
|
-
**https://elevora
|
|
67
|
-
|
|
68
|
-
## License
|
|
69
|
-
|
|
70
|
-
MIT © Justin Khor
|
|
1
|
+
# Evo UI
|
|
2
|
+
|
|
3
|
+
**A high-performance, enterprise-grade React UI component library.**
|
|
4
|
+
|
|
5
|
+
Evo UI ships 30+ accessible, themeable React components — with built-in light &
|
|
6
|
+
dark mode, full TypeScript types, `forwardRef` + native attribute pass-through,
|
|
7
|
+
and **zero runtime dependencies**.
|
|
8
|
+
|
|
9
|
+
- 📚 **Documentation:** https://docs.elevora.com.my
|
|
10
|
+
- 💻 **GitHub:** https://github.com/jinchuen/evo
|
|
11
|
+
- 📦 **npm:** https://www.npmjs.com/package/@justin_evo/evo-ui
|
|
12
|
+
|
|
13
|
+
## Installation
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npm install @justin_evo/evo-ui
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
`react` and `react-dom` (>= 17) are peer dependencies. Evo UI itself has no
|
|
20
|
+
runtime dependencies.
|
|
21
|
+
|
|
22
|
+
## Quick start
|
|
23
|
+
|
|
24
|
+
```jsx
|
|
25
|
+
// Import the stylesheet once in your app entry (includes the light/dark theme tokens)
|
|
26
|
+
import '@justin_evo/evo-ui/dist/evo-ui.css'
|
|
27
|
+
|
|
28
|
+
import { EvoThemeProvider, EvoButton } from '@justin_evo/evo-ui'
|
|
29
|
+
|
|
30
|
+
export default function App() {
|
|
31
|
+
return (
|
|
32
|
+
<EvoThemeProvider defaultTheme="system">
|
|
33
|
+
<EvoButton variant="solid" severity="primary">Hello Evo</EvoButton>
|
|
34
|
+
</EvoThemeProvider>
|
|
35
|
+
)
|
|
36
|
+
}
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Why Evo UI
|
|
40
|
+
|
|
41
|
+
- 🌗 **Light & dark mode** out of the box — CSS-variable theming, no runtime cost.
|
|
42
|
+
- 📱 **Mobile-ready** — ≥ 44px touch targets, responsive down to 375px.
|
|
43
|
+
- 🔡 **Fully typed** — ships `.d.ts`; every component forwards `ref` and native attributes.
|
|
44
|
+
- 🧩 **Composable, orthogonal APIs** — e.g. `<Form.Field><Form.Label /></Form.Field>`.
|
|
45
|
+
- 🪶 **Zero runtime dependencies.**
|
|
46
|
+
|
|
47
|
+
## Components
|
|
48
|
+
|
|
49
|
+
Full props, variants, and live examples for every component live in the
|
|
50
|
+
[documentation](https://docs.elevora.com.my).
|
|
51
|
+
|
|
52
|
+
| Category | Components |
|
|
53
|
+
| ---------------------- | ---------------------------------------------------------------------------------------------------------- |
|
|
54
|
+
| **Theming** | `EvoThemeProvider`, `EvoThemeToggle` |
|
|
55
|
+
| **Layout & structure** | `EvoStack`, `EvoGrid`, `EvoDivider`, `EvoContainer`, `EvoCard` |
|
|
56
|
+
| **Navigation** | `EvoTabs`, `EvoBreadcrumb`, `EvoNav`, `EvoTopNav`, `EvoPagination`, `EvoCommandPalette` |
|
|
57
|
+
| **Forms & inputs** | `EvoInput`, `EvoRichTextArea`, `EvoSelect`, `EvoTreeSelect`, `EvoAutoComplete`, `EvoCheckbox`, `EvoRadio`, `EvoToggle`, `EvoForm` |
|
|
58
|
+
| **Feedback & overlays**| `EvoModal`, `EvoNotification`, `EvoTooltip`, `EvoAlert` |
|
|
59
|
+
| **Data display** | `EvoBadge`, `EvoSkeleton`, `EvoTable` |
|
|
60
|
+
| **General** | `EvoButton` |
|
|
61
|
+
| **Media** | `EvoImageCropper` |
|
|
62
|
+
|
|
63
|
+
## Documentation
|
|
64
|
+
|
|
65
|
+
Browse the full component catalogue, prop tables, and copy-paste examples at
|
|
66
|
+
**https://docs.elevora.com.my**.
|
|
67
|
+
|
|
68
|
+
## License
|
|
69
|
+
|
|
70
|
+
MIT © Justin Khor
|
package/dist/declarations.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
declare module '*.module.scss' {
|
|
2
|
-
const classes: Record<string, string>;
|
|
3
|
-
export default classes;
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
declare module '*.scss' {}
|
|
1
|
+
declare module '*.module.scss' {
|
|
2
|
+
const classes: Record<string, string>;
|
|
3
|
+
export default classes;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
declare module '*.scss' {}
|
package/package.json
CHANGED
|
@@ -1,52 +1,52 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@justin_evo/evo-ui",
|
|
3
|
-
"version": "1.2.
|
|
4
|
-
"main": "dist/index.cjs.js",
|
|
5
|
-
"module": "dist/index.es.js",
|
|
6
|
-
"types": "dist/index.d.ts",
|
|
7
|
-
"style": "dist/evo-ui.css",
|
|
8
|
-
"exports": {
|
|
9
|
-
".": {
|
|
10
|
-
"types": "./dist/index.d.ts",
|
|
11
|
-
"import": "./dist/index.es.js",
|
|
12
|
-
"require": "./dist/index.cjs.js"
|
|
13
|
-
},
|
|
14
|
-
"./dist/evo-ui.css": "./dist/evo-ui.css"
|
|
15
|
-
},
|
|
16
|
-
"scripts": {
|
|
17
|
-
"dev": "tsup src/index.ts --format cjs,esm --watch --dts",
|
|
18
|
-
"build": "vite build",
|
|
19
|
-
"showcase": "vite"
|
|
20
|
-
},
|
|
21
|
-
"keywords": [
|
|
22
|
-
"react",
|
|
23
|
-
"ui",
|
|
24
|
-
"button",
|
|
25
|
-
"component",
|
|
26
|
-
"evo-ui"
|
|
27
|
-
],
|
|
28
|
-
"author": "Justin Khor",
|
|
29
|
-
"license": "MIT",
|
|
30
|
-
"description": "A high-performance, enterprise-grade React UI component library.",
|
|
31
|
-
"peerDependencies": {
|
|
32
|
-
"react": ">=17.0.0",
|
|
33
|
-
"react-dom": ">=17.0.0"
|
|
34
|
-
},
|
|
35
|
-
"devDependencies": {
|
|
36
|
-
"@types/node": "^25.6.0",
|
|
37
|
-
"@types/react": "^19.2.14",
|
|
38
|
-
"@types/react-dom": "^19.2.3",
|
|
39
|
-
"@vitejs/plugin-react": "^4.3.4",
|
|
40
|
-
"sass": "^1.99.0",
|
|
41
|
-
"sass-embedded": "^1.99.0",
|
|
42
|
-
"tsup": "^8.5.1",
|
|
43
|
-
"typescript": "^6.0.3",
|
|
44
|
-
"vite": "^6.3.2",
|
|
45
|
-
"vite-plugin-dts": "^4.5.4"
|
|
46
|
-
},
|
|
47
|
-
"files": [
|
|
48
|
-
"dist",
|
|
49
|
-
"src",
|
|
50
|
-
"src/css"
|
|
51
|
-
]
|
|
52
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@justin_evo/evo-ui",
|
|
3
|
+
"version": "1.2.1",
|
|
4
|
+
"main": "dist/index.cjs.js",
|
|
5
|
+
"module": "dist/index.es.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"style": "dist/evo-ui.css",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.es.js",
|
|
12
|
+
"require": "./dist/index.cjs.js"
|
|
13
|
+
},
|
|
14
|
+
"./dist/evo-ui.css": "./dist/evo-ui.css"
|
|
15
|
+
},
|
|
16
|
+
"scripts": {
|
|
17
|
+
"dev": "tsup src/index.ts --format cjs,esm --watch --dts",
|
|
18
|
+
"build": "vite build",
|
|
19
|
+
"showcase": "vite"
|
|
20
|
+
},
|
|
21
|
+
"keywords": [
|
|
22
|
+
"react",
|
|
23
|
+
"ui",
|
|
24
|
+
"button",
|
|
25
|
+
"component",
|
|
26
|
+
"evo-ui"
|
|
27
|
+
],
|
|
28
|
+
"author": "Justin Khor",
|
|
29
|
+
"license": "MIT",
|
|
30
|
+
"description": "A high-performance, enterprise-grade React UI component library.",
|
|
31
|
+
"peerDependencies": {
|
|
32
|
+
"react": ">=17.0.0",
|
|
33
|
+
"react-dom": ">=17.0.0"
|
|
34
|
+
},
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"@types/node": "^25.6.0",
|
|
37
|
+
"@types/react": "^19.2.14",
|
|
38
|
+
"@types/react-dom": "^19.2.3",
|
|
39
|
+
"@vitejs/plugin-react": "^4.3.4",
|
|
40
|
+
"sass": "^1.99.0",
|
|
41
|
+
"sass-embedded": "^1.99.0",
|
|
42
|
+
"tsup": "^8.5.1",
|
|
43
|
+
"typescript": "^6.0.3",
|
|
44
|
+
"vite": "^6.3.2",
|
|
45
|
+
"vite-plugin-dts": "^4.5.4"
|
|
46
|
+
},
|
|
47
|
+
"files": [
|
|
48
|
+
"dist",
|
|
49
|
+
"src",
|
|
50
|
+
"src/css"
|
|
51
|
+
]
|
|
52
|
+
}
|
package/src/Alert/Alert.tsx
CHANGED
|
@@ -1,49 +1,49 @@
|
|
|
1
|
-
import React, { useState } from 'react';
|
|
2
|
-
import styles from '../css/alert.module.scss';
|
|
3
|
-
|
|
4
|
-
type AlertType = 'success' | 'error' | 'warning' | 'info';
|
|
5
|
-
|
|
6
|
-
interface EvoAlertProps {
|
|
7
|
-
type?: AlertType;
|
|
8
|
-
title?: string;
|
|
9
|
-
children: React.ReactNode;
|
|
10
|
-
dismissible?: boolean;
|
|
11
|
-
className?: string;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
const icons: Record<AlertType, string> = {
|
|
15
|
-
success: '✓', error: '✕', warning: '⚠', info: 'i',
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
export const EvoAlert = ({
|
|
19
|
-
type = 'info',
|
|
20
|
-
title,
|
|
21
|
-
children,
|
|
22
|
-
dismissible = false,
|
|
23
|
-
className = '',
|
|
24
|
-
}: EvoAlertProps) => {
|
|
25
|
-
const [dismissed, setDismissed] = useState(false);
|
|
26
|
-
if (dismissed) return null;
|
|
27
|
-
|
|
28
|
-
return (
|
|
29
|
-
<div
|
|
30
|
-
className={[styles.alert, styles[type], className].filter(Boolean).join(' ')}
|
|
31
|
-
role="alert"
|
|
32
|
-
>
|
|
33
|
-
<span className={styles.alertIcon}>{icons[type]}</span>
|
|
34
|
-
<div className={styles.alertContent}>
|
|
35
|
-
{title && <p className={styles.alertTitle}>{title}</p>}
|
|
36
|
-
<div className={styles.alertDescription}>{children}</div>
|
|
37
|
-
</div>
|
|
38
|
-
{dismissible && (
|
|
39
|
-
<button
|
|
40
|
-
className={styles.dismissBtn}
|
|
41
|
-
onClick={() => setDismissed(true)}
|
|
42
|
-
aria-label="Dismiss alert"
|
|
43
|
-
>
|
|
44
|
-
✕
|
|
45
|
-
</button>
|
|
46
|
-
)}
|
|
47
|
-
</div>
|
|
48
|
-
);
|
|
49
|
-
};
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import styles from '../css/alert.module.scss';
|
|
3
|
+
|
|
4
|
+
type AlertType = 'success' | 'error' | 'warning' | 'info';
|
|
5
|
+
|
|
6
|
+
interface EvoAlertProps {
|
|
7
|
+
type?: AlertType;
|
|
8
|
+
title?: string;
|
|
9
|
+
children: React.ReactNode;
|
|
10
|
+
dismissible?: boolean;
|
|
11
|
+
className?: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const icons: Record<AlertType, string> = {
|
|
15
|
+
success: '✓', error: '✕', warning: '⚠', info: 'i',
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export const EvoAlert = ({
|
|
19
|
+
type = 'info',
|
|
20
|
+
title,
|
|
21
|
+
children,
|
|
22
|
+
dismissible = false,
|
|
23
|
+
className = '',
|
|
24
|
+
}: EvoAlertProps) => {
|
|
25
|
+
const [dismissed, setDismissed] = useState(false);
|
|
26
|
+
if (dismissed) return null;
|
|
27
|
+
|
|
28
|
+
return (
|
|
29
|
+
<div
|
|
30
|
+
className={[styles.alert, styles[type], className].filter(Boolean).join(' ')}
|
|
31
|
+
role="alert"
|
|
32
|
+
>
|
|
33
|
+
<span className={styles.alertIcon}>{icons[type]}</span>
|
|
34
|
+
<div className={styles.alertContent}>
|
|
35
|
+
{title && <p className={styles.alertTitle}>{title}</p>}
|
|
36
|
+
<div className={styles.alertDescription}>{children}</div>
|
|
37
|
+
</div>
|
|
38
|
+
{dismissible && (
|
|
39
|
+
<button
|
|
40
|
+
className={styles.dismissBtn}
|
|
41
|
+
onClick={() => setDismissed(true)}
|
|
42
|
+
aria-label="Dismiss alert"
|
|
43
|
+
>
|
|
44
|
+
✕
|
|
45
|
+
</button>
|
|
46
|
+
)}
|
|
47
|
+
</div>
|
|
48
|
+
);
|
|
49
|
+
};
|