am-shared-assets 0.0.2
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/.gitlab-ci.yml +31 -0
- package/.storybook/main.ts +17 -0
- package/.storybook/preview.ts +22 -0
- package/.storybook/vitest.setup.ts +7 -0
- package/Dockerfile +36 -0
- package/README.md +73 -0
- package/docker-compose.yml +12 -0
- package/eslint.config.js +23 -0
- package/index.html +13 -0
- package/package.json +61 -0
- package/postcss.config.js +6 -0
- package/public/vite.svg +1 -0
- package/src/App.tsx +8 -0
- package/src/components/Alert.tsx +194 -0
- package/src/components/Badge.tsx +48 -0
- package/src/components/Button.tsx +137 -0
- package/src/components/Chip.tsx +139 -0
- package/src/components/Input.tsx +137 -0
- package/src/components/Radio.tsx +89 -0
- package/src/components/RangeSlider.tsx +106 -0
- package/src/components/Select.tsx +13 -0
- package/src/components/Switch.tsx +76 -0
- package/src/components/Tooltip.tsx +111 -0
- package/src/icons/components/AddIcon.tsx +27 -0
- package/src/icons/components/ArrowDownIcon.tsx +25 -0
- package/src/icons/components/ArrowRightIcon.tsx +37 -0
- package/src/icons/components/BagIcon.tsx +25 -0
- package/src/icons/components/BoxIcon.tsx +43 -0
- package/src/icons/components/BoxTimeIcon.tsx +47 -0
- package/src/icons/components/CardTickIcon.tsx +54 -0
- package/src/icons/components/CardsIcon.tsx +48 -0
- package/src/icons/components/CategoryIcon.tsx +37 -0
- package/src/icons/components/ChevronBottomIcon.tsx +22 -0
- package/src/icons/components/ChevronLeftIcon.tsx +29 -0
- package/src/icons/components/ChevronRightIcon.tsx +29 -0
- package/src/icons/components/ChevronTopIcon.tsx +29 -0
- package/src/icons/components/CloseCircleIcon.tsx +25 -0
- package/src/icons/components/CloseIcon.tsx +29 -0
- package/src/icons/components/DislikeIcon.tsx +32 -0
- package/src/icons/components/EditIcon.tsx +39 -0
- package/src/icons/components/HeartIcon.tsx +28 -0
- package/src/icons/components/HomeIcon.tsx +19 -0
- package/src/icons/components/InfoIcon.tsx +25 -0
- package/src/icons/components/LikeIcon.tsx +32 -0
- package/src/icons/components/MessageIcon.tsx +50 -0
- package/src/icons/components/MoneyIcon.tsx +57 -0
- package/src/icons/components/MoreIcon.tsx +33 -0
- package/src/icons/components/OutlineTickCircleIcon.tsx +35 -0
- package/src/icons/components/RotateBoxIcon.tsx +56 -0
- package/src/icons/components/RotateInfoIcon.tsx +34 -0
- package/src/icons/components/SearchIcon.tsx +35 -0
- package/src/icons/components/SettingIcon.tsx +69 -0
- package/src/icons/components/ShareIcon.tsx +37 -0
- package/src/icons/components/ShopIcon.tsx +56 -0
- package/src/icons/components/ShoppingCartIcon.tsx +53 -0
- package/src/icons/components/SpinnerIcon.tsx +25 -0
- package/src/icons/components/StarIcon.tsx +29 -0
- package/src/icons/components/TickCircleIcon.tsx +25 -0
- package/src/icons/components/TrashIcon.tsx +56 -0
- package/src/icons/components/TruckIcon.tsx +51 -0
- package/src/icons/components/UserIcon.tsx +29 -0
- package/src/icons/components/WalletCheckIcon.tsx +52 -0
- package/src/icons/components/WarningIcon.tsx +19 -0
- package/src/icons/index.ts +83 -0
- package/src/index.css +36 -0
- package/src/index.ts +2 -0
- package/src/main.tsx +10 -0
- package/src/stories/Alert.stories.ts +22 -0
- package/src/stories/Badge.stories.tsx +20 -0
- package/src/stories/Button.stories.tsx +108 -0
- package/src/stories/Chip.stories.ts +20 -0
- package/src/stories/Configure.mdx +364 -0
- package/src/stories/IconGallery.stories.tsx +99 -0
- package/src/stories/Input.stories.ts +21 -0
- package/src/stories/Radio.stories.tsx +21 -0
- package/src/stories/RangeSlider.stories.tsx +68 -0
- package/src/stories/Select.stories.ts +21 -0
- package/src/stories/Switch.stories.tsx +21 -0
- package/src/stories/Tooltip.stories.ts +20 -0
- package/src/stories/assets/accessibility.png +0 -0
- package/src/stories/assets/accessibility.svg +1 -0
- package/src/stories/assets/addon-library.png +0 -0
- package/src/stories/assets/assets.png +0 -0
- package/src/stories/assets/avif-test-image.avif +0 -0
- package/src/stories/assets/context.png +0 -0
- package/src/stories/assets/discord.svg +1 -0
- package/src/stories/assets/docs.png +0 -0
- package/src/stories/assets/figma-plugin.png +0 -0
- package/src/stories/assets/fonts/woff/IRANSansXFaNum-Bold.woff +0 -0
- package/src/stories/assets/fonts/woff/IRANSansXFaNum-DemiBold.woff +0 -0
- package/src/stories/assets/fonts/woff/IRANSansXFaNum-Medium.woff +0 -0
- package/src/stories/assets/fonts/woff/IRANSansXFaNum-Regular.woff +0 -0
- package/src/stories/assets/fonts/woff2/IRANSansXFaNum-Bold.woff2 +0 -0
- package/src/stories/assets/fonts/woff2/IRANSansXFaNum-DemiBold.woff2 +0 -0
- package/src/stories/assets/fonts/woff2/IRANSansXFaNum-Medium.woff2 +0 -0
- package/src/stories/assets/fonts/woff2/IRANSansXFaNum-Regular.woff2 +0 -0
- package/src/stories/assets/github.svg +1 -0
- package/src/stories/assets/share.png +0 -0
- package/src/stories/assets/styling.png +0 -0
- package/src/stories/assets/testing.png +0 -0
- package/src/stories/assets/theming.png +0 -0
- package/src/stories/assets/tutorials.svg +1 -0
- package/src/stories/assets/youtube.svg +1 -0
- package/tailwind.config.js +165 -0
- package/tsconfig.app.json +28 -0
- package/tsconfig.json +7 -0
- package/tsconfig.node.json +26 -0
- package/vite.config.ts +38 -0
- package/vitest.shims.d.ts +1 -0
package/.gitlab-ci.yml
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
stages:
|
|
2
|
+
- build
|
|
3
|
+
- deploy
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
before_script:
|
|
7
|
+
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
|
|
8
|
+
|
|
9
|
+
build:
|
|
10
|
+
stage: build
|
|
11
|
+
environment: production
|
|
12
|
+
script:
|
|
13
|
+
- docker compose build
|
|
14
|
+
- docker compose push
|
|
15
|
+
only:
|
|
16
|
+
- main
|
|
17
|
+
tags:
|
|
18
|
+
- build
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
deploy:
|
|
22
|
+
stage: deploy
|
|
23
|
+
environment: production
|
|
24
|
+
script:
|
|
25
|
+
- docker compose pull
|
|
26
|
+
- docker compose up -d --force-recreate
|
|
27
|
+
only:
|
|
28
|
+
- main
|
|
29
|
+
when: manual
|
|
30
|
+
tags:
|
|
31
|
+
- prod
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { StorybookConfig } from '@storybook/react-vite';
|
|
2
|
+
|
|
3
|
+
const config: StorybookConfig = {
|
|
4
|
+
"stories": [
|
|
5
|
+
"../src/**/*.mdx",
|
|
6
|
+
"../src/**/*.stories.@(js|jsx|mjs|ts|tsx)"
|
|
7
|
+
],
|
|
8
|
+
"addons": [
|
|
9
|
+
"@chromatic-com/storybook",
|
|
10
|
+
"@storybook/addon-vitest",
|
|
11
|
+
"@storybook/addon-a11y",
|
|
12
|
+
"@storybook/addon-docs",
|
|
13
|
+
"@storybook/addon-onboarding"
|
|
14
|
+
],
|
|
15
|
+
"framework": "@storybook/react-vite"
|
|
16
|
+
};
|
|
17
|
+
export default config;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { Preview } from '@storybook/react-vite'
|
|
2
|
+
import "./../src/index.css"
|
|
3
|
+
|
|
4
|
+
const preview: Preview = {
|
|
5
|
+
parameters: {
|
|
6
|
+
controls: {
|
|
7
|
+
matchers: {
|
|
8
|
+
color: /(background|color)$/i,
|
|
9
|
+
date: /Date$/i,
|
|
10
|
+
},
|
|
11
|
+
},
|
|
12
|
+
|
|
13
|
+
a11y: {
|
|
14
|
+
// 'todo' - show a11y violations in the test UI only
|
|
15
|
+
// 'error' - fail CI on a11y violations
|
|
16
|
+
// 'off' - skip a11y checks entirely
|
|
17
|
+
test: 'todo'
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export default preview;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import * as a11yAddonAnnotations from "@storybook/addon-a11y/preview";
|
|
2
|
+
import { setProjectAnnotations } from '@storybook/react-vite';
|
|
3
|
+
import * as projectAnnotations from './preview';
|
|
4
|
+
|
|
5
|
+
// This is an important step to apply the right configuration when testing your stories.
|
|
6
|
+
// More info at: https://storybook.js.org/docs/api/portable-stories/portable-stories-vitest#setprojectannotations
|
|
7
|
+
setProjectAnnotations([a11yAddonAnnotations, projectAnnotations]);
|
package/Dockerfile
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
FROM node:24-alpine AS base
|
|
2
|
+
|
|
3
|
+
ENV NEXT_TELEMETRY_DISABLED=1
|
|
4
|
+
ENV PNPM_HOME="/pnpm"
|
|
5
|
+
ENV PATH="$PNPM_HOME:$PATH"
|
|
6
|
+
|
|
7
|
+
#RUN npm config set registry https://repository.aghsatmarket.com/repository/npm-proxy/
|
|
8
|
+
RUN npm install -g corepack@latest serve
|
|
9
|
+
RUN corepack enable
|
|
10
|
+
|
|
11
|
+
WORKDIR /app
|
|
12
|
+
|
|
13
|
+
# Dependencies
|
|
14
|
+
FROM base AS dependencies
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
COPY package.json package-lock.json ./
|
|
18
|
+
RUN npm install
|
|
19
|
+
# install lightweight static file server
|
|
20
|
+
|
|
21
|
+
# Build Storybook
|
|
22
|
+
FROM base AS build
|
|
23
|
+
|
|
24
|
+
COPY --from=dependencies /app/node_modules ./node_modules
|
|
25
|
+
COPY . .
|
|
26
|
+
|
|
27
|
+
RUN npm run build-storybook
|
|
28
|
+
|
|
29
|
+
# Production runtime
|
|
30
|
+
FROM nginx:latest AS run
|
|
31
|
+
|
|
32
|
+
COPY --from=build /app/storybook-static /usr/share/nginx/html
|
|
33
|
+
|
|
34
|
+
EXPOSE 80
|
|
35
|
+
|
|
36
|
+
CMD ["nginx", "-g", "daemon off;"]
|
package/README.md
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
# React + TypeScript + Vite
|
|
2
|
+
|
|
3
|
+
This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.
|
|
4
|
+
|
|
5
|
+
Currently, two official plugins are available:
|
|
6
|
+
|
|
7
|
+
- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react) uses [Babel](https://babeljs.io/) (or [oxc](https://oxc.rs) when used in [rolldown-vite](https://vite.dev/guide/rolldown)) for Fast Refresh
|
|
8
|
+
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh
|
|
9
|
+
|
|
10
|
+
## React Compiler
|
|
11
|
+
|
|
12
|
+
The React Compiler is not enabled on this template because of its impact on dev & build performances. To add it, see [this documentation](https://react.dev/learn/react-compiler/installation).
|
|
13
|
+
|
|
14
|
+
## Expanding the ESLint configuration
|
|
15
|
+
|
|
16
|
+
If you are developing a production application, we recommend updating the configuration to enable type-aware lint rules:
|
|
17
|
+
|
|
18
|
+
```js
|
|
19
|
+
export default defineConfig([
|
|
20
|
+
globalIgnores(['dist']),
|
|
21
|
+
{
|
|
22
|
+
files: ['**/*.{ts,tsx}'],
|
|
23
|
+
extends: [
|
|
24
|
+
// Other configs...
|
|
25
|
+
|
|
26
|
+
// Remove tseslint.configs.recommended and replace with this
|
|
27
|
+
tseslint.configs.recommendedTypeChecked,
|
|
28
|
+
// Alternatively, use this for stricter rules
|
|
29
|
+
tseslint.configs.strictTypeChecked,
|
|
30
|
+
// Optionally, add this for stylistic rules
|
|
31
|
+
tseslint.configs.stylisticTypeChecked,
|
|
32
|
+
|
|
33
|
+
// Other configs...
|
|
34
|
+
],
|
|
35
|
+
languageOptions: {
|
|
36
|
+
parserOptions: {
|
|
37
|
+
project: ['./tsconfig.node.json', './tsconfig.app.json'],
|
|
38
|
+
tsconfigRootDir: import.meta.dirname,
|
|
39
|
+
},
|
|
40
|
+
// other options...
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
])
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
You can also install [eslint-plugin-react-x](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-x) and [eslint-plugin-react-dom](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-dom) for React-specific lint rules:
|
|
47
|
+
|
|
48
|
+
```js
|
|
49
|
+
// eslint.config.js
|
|
50
|
+
import reactX from 'eslint-plugin-react-x'
|
|
51
|
+
import reactDom from 'eslint-plugin-react-dom'
|
|
52
|
+
|
|
53
|
+
export default defineConfig([
|
|
54
|
+
globalIgnores(['dist']),
|
|
55
|
+
{
|
|
56
|
+
files: ['**/*.{ts,tsx}'],
|
|
57
|
+
extends: [
|
|
58
|
+
// Other configs...
|
|
59
|
+
// Enable lint rules for React
|
|
60
|
+
reactX.configs['recommended-typescript'],
|
|
61
|
+
// Enable lint rules for React DOM
|
|
62
|
+
reactDom.configs.recommended,
|
|
63
|
+
],
|
|
64
|
+
languageOptions: {
|
|
65
|
+
parserOptions: {
|
|
66
|
+
project: ['./tsconfig.node.json', './tsconfig.app.json'],
|
|
67
|
+
tsconfigRootDir: import.meta.dirname,
|
|
68
|
+
},
|
|
69
|
+
// other options...
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
])
|
|
73
|
+
```
|
package/eslint.config.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// For more info, see https://github.com/storybookjs/eslint-plugin-storybook#configuration-flat-config-format
|
|
2
|
+
import storybook from "eslint-plugin-storybook";
|
|
3
|
+
|
|
4
|
+
import js from '@eslint/js'
|
|
5
|
+
import globals from 'globals'
|
|
6
|
+
import reactHooks from 'eslint-plugin-react-hooks'
|
|
7
|
+
import reactRefresh from 'eslint-plugin-react-refresh'
|
|
8
|
+
import tseslint from 'typescript-eslint'
|
|
9
|
+
import { defineConfig, globalIgnores } from 'eslint/config'
|
|
10
|
+
|
|
11
|
+
export default defineConfig([globalIgnores(['dist']), {
|
|
12
|
+
files: ['**/*.{ts,tsx}'],
|
|
13
|
+
extends: [
|
|
14
|
+
js.configs.recommended,
|
|
15
|
+
tseslint.configs.recommended,
|
|
16
|
+
reactHooks.configs.flat.recommended,
|
|
17
|
+
reactRefresh.configs.vite,
|
|
18
|
+
],
|
|
19
|
+
languageOptions: {
|
|
20
|
+
ecmaVersion: 2020,
|
|
21
|
+
globals: globals.browser,
|
|
22
|
+
},
|
|
23
|
+
}, ...storybook.configs["flat/recommended"]])
|
package/index.html
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
|
+
<title>shared-assets</title>
|
|
8
|
+
</head>
|
|
9
|
+
<body>
|
|
10
|
+
<div id="root"></div>
|
|
11
|
+
<script type="module" src="/src/main.tsx"></script>
|
|
12
|
+
</body>
|
|
13
|
+
</html>
|
package/package.json
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "am-shared-assets",
|
|
3
|
+
"version": "0.0.2",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "A demo package for Total TypeScript",
|
|
6
|
+
"keywords": ["demo", "typescript"],
|
|
7
|
+
"homepage": "https://github.com/mattpocock/tt-package-demo",
|
|
8
|
+
"bugs": {
|
|
9
|
+
"url": "https://github.com/mattpocock/tt-package-demo/issues"
|
|
10
|
+
},
|
|
11
|
+
"author": "Matt Pocock <team@totaltypescript.com> (https://totaltypescript.com)",
|
|
12
|
+
"repository": {
|
|
13
|
+
"type": "git",
|
|
14
|
+
"url": "git+https://github.com/mattpocock/tt-package-demo.git"
|
|
15
|
+
},
|
|
16
|
+
"scripts": {
|
|
17
|
+
"dev": "vite",
|
|
18
|
+
"build": "tsc -b && vite build",
|
|
19
|
+
"lint": "eslint .",
|
|
20
|
+
"preview": "vite preview",
|
|
21
|
+
"storybook": "storybook dev -p 6006",
|
|
22
|
+
"build-storybook": "storybook build"
|
|
23
|
+
},
|
|
24
|
+
"dependencies": {
|
|
25
|
+
"@emotion/react": "^11.14.0",
|
|
26
|
+
"@emotion/styled": "^11.14.1",
|
|
27
|
+
"@mui/material": "^9.0.0",
|
|
28
|
+
"clsx": "^2.1.1",
|
|
29
|
+
"postcss": "^8.4.47",
|
|
30
|
+
"react": "^19.2.0",
|
|
31
|
+
"react-dom": "^19.2.0",
|
|
32
|
+
"tailwindcss": "^3.4.14"
|
|
33
|
+
},
|
|
34
|
+
"devDependencies": {
|
|
35
|
+
"@chromatic-com/storybook": "^5.0.1",
|
|
36
|
+
"@eslint/js": "^9.39.1",
|
|
37
|
+
"@storybook/addon-a11y": "^10.2.17",
|
|
38
|
+
"@storybook/addon-docs": "^10.2.17",
|
|
39
|
+
"@storybook/addon-onboarding": "^10.2.17",
|
|
40
|
+
"@storybook/addon-vitest": "^10.2.17",
|
|
41
|
+
"@storybook/react-vite": "^10.2.17",
|
|
42
|
+
"@types/node": "^24.10.1",
|
|
43
|
+
"@types/react": "^19.2.7",
|
|
44
|
+
"@types/react-dom": "^19.2.3",
|
|
45
|
+
"@vitejs/plugin-react": "^5.1.1",
|
|
46
|
+
"@vitest/browser-playwright": "^4.0.18",
|
|
47
|
+
"@vitest/coverage-v8": "^4.0.18",
|
|
48
|
+
"autoprefixer": "^10.4.20",
|
|
49
|
+
"eslint": "^9.39.1",
|
|
50
|
+
"eslint-plugin-react-hooks": "^7.0.1",
|
|
51
|
+
"eslint-plugin-react-refresh": "^0.4.24",
|
|
52
|
+
"eslint-plugin-storybook": "^10.2.17",
|
|
53
|
+
"globals": "^16.5.0",
|
|
54
|
+
"playwright": "^1.58.2",
|
|
55
|
+
"storybook": "^10.2.17",
|
|
56
|
+
"typescript": "~5.9.3",
|
|
57
|
+
"typescript-eslint": "^8.48.0",
|
|
58
|
+
"vite": "^7.3.1",
|
|
59
|
+
"vitest": "^4.0.18"
|
|
60
|
+
}
|
|
61
|
+
}
|
package/public/vite.svg
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="31.88" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 257"><defs><linearGradient id="IconifyId1813088fe1fbc01fb466" x1="-.828%" x2="57.636%" y1="7.652%" y2="78.411%"><stop offset="0%" stop-color="#41D1FF"></stop><stop offset="100%" stop-color="#BD34FE"></stop></linearGradient><linearGradient id="IconifyId1813088fe1fbc01fb467" x1="43.376%" x2="50.316%" y1="2.242%" y2="89.03%"><stop offset="0%" stop-color="#FFEA83"></stop><stop offset="8.333%" stop-color="#FFDD35"></stop><stop offset="100%" stop-color="#FFA800"></stop></linearGradient></defs><path fill="url(#IconifyId1813088fe1fbc01fb466)" d="M255.153 37.938L134.897 252.976c-2.483 4.44-8.862 4.466-11.382.048L.875 37.958c-2.746-4.814 1.371-10.646 6.827-9.67l120.385 21.517a6.537 6.537 0 0 0 2.322-.004l117.867-21.483c5.438-.991 9.574 4.796 6.877 9.62Z"></path><path fill="url(#IconifyId1813088fe1fbc01fb467)" d="M185.432.063L96.44 17.501a3.268 3.268 0 0 0-2.634 3.014l-5.474 92.456a3.268 3.268 0 0 0 3.997 3.378l24.777-5.718c2.318-.535 4.413 1.507 3.936 3.838l-7.361 36.047c-.495 2.426 1.782 4.5 4.151 3.78l15.304-4.649c2.372-.72 4.652 1.36 4.15 3.788l-11.698 56.621c-.732 3.542 3.979 5.473 5.943 2.437l1.313-2.028l72.516-144.72c1.215-2.423-.88-5.186-3.54-4.672l-25.505 4.922c-2.396.462-4.435-1.77-3.759-4.114l16.646-57.705c.677-2.35-1.37-4.583-3.769-4.113Z"></path></svg>
|
package/src/App.tsx
ADDED
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
import {
|
|
3
|
+
CloseIcon,
|
|
4
|
+
InfoIcon,
|
|
5
|
+
CloseCircleIcon,
|
|
6
|
+
TickCircleIcon,
|
|
7
|
+
WarningIcon,
|
|
8
|
+
} from "../icons";
|
|
9
|
+
import clsx from "clsx";
|
|
10
|
+
|
|
11
|
+
const sizes: { [key: string]: string } = {
|
|
12
|
+
sm: "text-xs",
|
|
13
|
+
md: "text-sm",
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const widths: { [key: string]: string } = {
|
|
17
|
+
default: "w-[342px] min-w-[342px]",
|
|
18
|
+
full: "w-full",
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const bgColors: { [key: string]: string } = {
|
|
22
|
+
default: "bg-default-100",
|
|
23
|
+
primary: "bg-primary-50",
|
|
24
|
+
secondary: "bg-secondary-50",
|
|
25
|
+
success: "bg-success-50",
|
|
26
|
+
warning: "bg-warning-50",
|
|
27
|
+
danger: "bg-danger-50",
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const titleColors: { [key: string]: string } = {
|
|
31
|
+
default: "text-default-900",
|
|
32
|
+
primary: "text-base-primary",
|
|
33
|
+
secondary: "text-base-secondary",
|
|
34
|
+
success: "text-base-success",
|
|
35
|
+
warning: "text-default-900",
|
|
36
|
+
danger: "text-base-danger",
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
const descriptionColors: { [key: string]: string } = {
|
|
40
|
+
default: "text-default-600",
|
|
41
|
+
primary: "text-base-primary",
|
|
42
|
+
secondary: "text-base-secondary",
|
|
43
|
+
success: "text-base-success",
|
|
44
|
+
warning: "text-default-600",
|
|
45
|
+
danger: "text-base-danger",
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
const buttonBgColors: { [key: string]: string } = {
|
|
49
|
+
default: "bg-default-300",
|
|
50
|
+
primary: "bg-base-primary",
|
|
51
|
+
secondary: "bg-base-secondary",
|
|
52
|
+
success: "bg-base-success",
|
|
53
|
+
warning: "bg-base-warning",
|
|
54
|
+
danger: "bg-base-danger",
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
const buttonTextColors: { [key: string]: string } = {
|
|
58
|
+
white: "text-white",
|
|
59
|
+
black: "text-default-900",
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
const closeButtonColors: { [key: string]: string } = {
|
|
63
|
+
default: "#a1a1aa",
|
|
64
|
+
primary: "#A9BCE3",
|
|
65
|
+
secondary: "#E2CDA6",
|
|
66
|
+
success: "#a2e9c1",
|
|
67
|
+
warning: "#fbdba7",
|
|
68
|
+
danger: "#faa0bf",
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
const infoIconAlignments: { [key: string]: string } = {
|
|
72
|
+
start: "items-start",
|
|
73
|
+
center: "items-center",
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
const infoIconColors: { [key: string]: string } = {
|
|
77
|
+
default: "#000",
|
|
78
|
+
primary: "#112E62",
|
|
79
|
+
secondary: "#C59C4E",
|
|
80
|
+
success: "#17c964",
|
|
81
|
+
warning: "#f5a524",
|
|
82
|
+
danger: "#f31260",
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
const alertIcons: { [key: string]: ReactNode } = {
|
|
86
|
+
success: <TickCircleIcon color="#17C964" />,
|
|
87
|
+
warning: <WarningIcon color="#F5A524" />,
|
|
88
|
+
danger: <CloseCircleIcon color="#F31260" />,
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
const radiuses: { [key: string]: string } = {
|
|
92
|
+
none: "rounded-none",
|
|
93
|
+
sm: "rounded-md",
|
|
94
|
+
md: "rounded-xl",
|
|
95
|
+
lg: "rounded-[22px]",
|
|
96
|
+
full: "rounded-full",
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
interface AlertProps {
|
|
100
|
+
title?: string;
|
|
101
|
+
description?: string;
|
|
102
|
+
color?:
|
|
103
|
+
| "default"
|
|
104
|
+
| "primary"
|
|
105
|
+
| "secondary"
|
|
106
|
+
| "success"
|
|
107
|
+
| "warning"
|
|
108
|
+
| "danger";
|
|
109
|
+
size?: "sm" | "md";
|
|
110
|
+
width?: "default" | "full";
|
|
111
|
+
rounded?: "none" | "sm" | "md" | "lg" | "full";
|
|
112
|
+
infoIconAlignment?: "start" | "center";
|
|
113
|
+
isInfoIcon?: boolean;
|
|
114
|
+
hasCloseButton?: boolean;
|
|
115
|
+
hasButton?: boolean;
|
|
116
|
+
buttonTitle?: string;
|
|
117
|
+
buttonTextColor?: "black" | "white";
|
|
118
|
+
buttonClickHandler?: () => void;
|
|
119
|
+
closeAlertHandler?: () => void;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export const Alert = ({
|
|
123
|
+
title,
|
|
124
|
+
description,
|
|
125
|
+
color = "default",
|
|
126
|
+
size = "md",
|
|
127
|
+
width = "default",
|
|
128
|
+
rounded = "none",
|
|
129
|
+
infoIconAlignment,
|
|
130
|
+
isInfoIcon = true,
|
|
131
|
+
hasCloseButton = true,
|
|
132
|
+
hasButton = false,
|
|
133
|
+
buttonTitle,
|
|
134
|
+
buttonTextColor = "black",
|
|
135
|
+
buttonClickHandler,
|
|
136
|
+
closeAlertHandler,
|
|
137
|
+
}: AlertProps) => {
|
|
138
|
+
const cls = clsx(
|
|
139
|
+
widths[width],
|
|
140
|
+
sizes[size],
|
|
141
|
+
radiuses[rounded],
|
|
142
|
+
bgColors[color],
|
|
143
|
+
);
|
|
144
|
+
|
|
145
|
+
return (
|
|
146
|
+
<div className={`relative flex justify-between p-3 ${cls}`}>
|
|
147
|
+
<div
|
|
148
|
+
className={`flex ${infoIconAlignment ? infoIconAlignments[infoIconAlignment] : hasButton ? "items-center" : title && description ? "items-start" : "items-center"} gap-3`}
|
|
149
|
+
>
|
|
150
|
+
<div className="mt-[1px]">
|
|
151
|
+
{isInfoIcon || !alertIcons[color] ? (
|
|
152
|
+
<InfoIcon color={infoIconColors[color]} />
|
|
153
|
+
) : (
|
|
154
|
+
alertIcons[color]
|
|
155
|
+
)}
|
|
156
|
+
</div>
|
|
157
|
+
<div>
|
|
158
|
+
{title && (
|
|
159
|
+
<h2 className={`font-semibold ${titleColors[color]}`}>{title}</h2>
|
|
160
|
+
)}
|
|
161
|
+
{description && (
|
|
162
|
+
<p className={descriptionColors[color]}>{description}</p>
|
|
163
|
+
)}
|
|
164
|
+
</div>
|
|
165
|
+
</div>
|
|
166
|
+
{hasButton ? (
|
|
167
|
+
<div className="flex items-center">
|
|
168
|
+
<button
|
|
169
|
+
onClick={buttonClickHandler}
|
|
170
|
+
className={`h-8 px-3 rounded-md ${buttonBgColors[color]} ${buttonTextColors[buttonTextColor]}`}
|
|
171
|
+
>
|
|
172
|
+
{buttonTitle}
|
|
173
|
+
</button>
|
|
174
|
+
{hasCloseButton && (
|
|
175
|
+
<button
|
|
176
|
+
onClick={closeAlertHandler}
|
|
177
|
+
className="absolute -top-1 -left-1 border border-default-300 bg-default-100 rounded-full"
|
|
178
|
+
>
|
|
179
|
+
<CloseIcon color={closeButtonColors["default"]} size={14} />
|
|
180
|
+
</button>
|
|
181
|
+
)}
|
|
182
|
+
</div>
|
|
183
|
+
) : (
|
|
184
|
+
hasCloseButton && (
|
|
185
|
+
<div>
|
|
186
|
+
<button onClick={closeAlertHandler}>
|
|
187
|
+
<CloseIcon color={closeButtonColors[color]} />
|
|
188
|
+
</button>
|
|
189
|
+
</div>
|
|
190
|
+
)
|
|
191
|
+
)}
|
|
192
|
+
</div>
|
|
193
|
+
);
|
|
194
|
+
};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import clsx from "clsx";
|
|
2
|
+
|
|
3
|
+
const sizes = {
|
|
4
|
+
sm: "h-5 text-xs px-2",
|
|
5
|
+
md: "h-6 text-sm px-2.5",
|
|
6
|
+
lg: "h-7 text-sm px-3",
|
|
7
|
+
};
|
|
8
|
+
const colors = {
|
|
9
|
+
neutral: "bg-default-500",
|
|
10
|
+
default: "bg-default-200",
|
|
11
|
+
primary: "bg-layout-focus",
|
|
12
|
+
danger: "bg-base-danger",
|
|
13
|
+
success: "bg-base-success",
|
|
14
|
+
};
|
|
15
|
+
const textColors = {
|
|
16
|
+
white: "text-content-1",
|
|
17
|
+
black: "text-layout-fg",
|
|
18
|
+
};
|
|
19
|
+
const types = {
|
|
20
|
+
pill: "rounded-full",
|
|
21
|
+
Rectangle: "rounded-xxs",
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
interface IBadgeProps {
|
|
25
|
+
label: string;
|
|
26
|
+
size?: "sm" | "md" | "lg";
|
|
27
|
+
color?: "neutral" | "default" | "primary" | "danger" | "success";
|
|
28
|
+
textColor?: "white" | "black";
|
|
29
|
+
type?: "pill" | "Rectangle";
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const Badge = ({
|
|
33
|
+
label,
|
|
34
|
+
color = "default",
|
|
35
|
+
type = "pill",
|
|
36
|
+
size = "md",
|
|
37
|
+
textColor = "black",
|
|
38
|
+
}: IBadgeProps) => {
|
|
39
|
+
const cls = clsx(
|
|
40
|
+
colors[color],
|
|
41
|
+
textColors[textColor],
|
|
42
|
+
sizes[size],
|
|
43
|
+
types[type],
|
|
44
|
+
);
|
|
45
|
+
return <div className={`flex justify-center items-center ${cls}`}>{label}</div>;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export default Badge;
|