dst-rg 1.0.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/.gitlab-ci.yml +43 -0
- package/.storybook/main.ts +15 -0
- package/.storybook/preview.ts +15 -0
- package/README.md +254 -0
- package/components.json +21 -0
- package/dist/Avatar.png +0 -0
- package/dist/assets/index-CCq7hmG3.js +186 -0
- package/dist/assets/index-Mg-hjQGu.css +1 -0
- package/dist/index.html +15 -0
- package/dist/test.png +0 -0
- package/dist/vite.svg +1 -0
- package/eslint.config.js +29 -0
- package/index.html +14 -0
- package/package.json +102 -0
- package/postcss.config.mjs +11 -0
- package/rollup.config.mjs +55 -0
- package/src/assets/react.svg +1 -0
- package/src/assets/style/animation.css +27 -0
- package/src/assets/style/box-shadow.css +25 -0
- package/src/assets/style/colors.css +402 -0
- package/src/assets/style/dark-theme.css +288 -0
- package/src/assets/style/font-size.css +14 -0
- package/src/assets/style/gradient.css +3 -0
- package/src/assets/style/index.css +12 -0
- package/src/assets/style/light-theme.css +148 -0
- package/src/assets/style/line-height.css +13 -0
- package/src/assets/style/max-width.css +5 -0
- package/src/assets/style/radius.css +13 -0
- package/src/assets/style/utility-colors.css +166 -0
- package/src/components/Accordion/_.stories.tsx +75 -0
- package/src/components/Accordion/_.test.tsx +77 -0
- package/src/components/Accordion/index.tsx +47 -0
- package/src/components/Accordion/type.ts +24 -0
- package/src/components/Avatar/_.stories.tsx +179 -0
- package/src/components/Avatar/_.style.ts +40 -0
- package/src/components/Avatar/_.test.tsx +150 -0
- package/src/components/Avatar/_.types.ts +66 -0
- package/src/components/Avatar/index.tsx +63 -0
- package/src/components/Badge/_.stories.tsx +75 -0
- package/src/components/Badge/_.style.ts +53 -0
- package/src/components/Badge/_.test.tsx +27 -0
- package/src/components/Badge/_.types.ts +11 -0
- package/src/components/Badge/index.tsx +42 -0
- package/src/components/Breadcrumbs/_.stories.tsx +95 -0
- package/src/components/Breadcrumbs/_.test.tsx +29 -0
- package/src/components/Breadcrumbs/_.type.ts +15 -0
- package/src/components/Breadcrumbs/index.tsx +103 -0
- package/src/components/Button/_.stories.tsx +85 -0
- package/src/components/Button/_.style.ts +56 -0
- package/src/components/Button/_.test.tsx +103 -0
- package/src/components/Button/_.types.ts +14 -0
- package/src/components/Button/index.tsx +70 -0
- package/src/components/Checkbox/_.stories.tsx +96 -0
- package/src/components/Checkbox/_.style.ts +24 -0
- package/src/components/Checkbox/_.test.tsx +85 -0
- package/src/components/Checkbox/_.types.ts +23 -0
- package/src/components/Checkbox/index.tsx +93 -0
- package/src/components/CheckboxGroup/PaymentCard/_.stories.tsx +104 -0
- package/src/components/CheckboxGroup/PaymentCard/_.style.ts +28 -0
- package/src/components/CheckboxGroup/PaymentCard/_.test.tsx +58 -0
- package/src/components/CheckboxGroup/PaymentCard/_.types.ts +28 -0
- package/src/components/CheckboxGroup/PaymentCard/index.tsx +71 -0
- package/src/components/CheckboxGroup/PlanCard/_.stories.tsx +165 -0
- package/src/components/CheckboxGroup/PlanCard/_.style.ts +32 -0
- package/src/components/CheckboxGroup/PlanCard/_.test.tsx +54 -0
- package/src/components/CheckboxGroup/PlanCard/_.types.ts +35 -0
- package/src/components/CheckboxGroup/PlanCard/index.tsx +53 -0
- package/src/components/CheckboxGroup/UserCard/_.stories.tsx +89 -0
- package/src/components/CheckboxGroup/UserCard/_.style.ts +42 -0
- package/src/components/CheckboxGroup/UserCard/_.test.tsx +66 -0
- package/src/components/CheckboxGroup/UserCard/_.types.ts +26 -0
- package/src/components/CheckboxGroup/UserCard/index.tsx +75 -0
- package/src/components/Dropdown/_.stories.tsx +180 -0
- package/src/components/Dropdown/_.style.ts +108 -0
- package/src/components/Dropdown/_.test.tsx +334 -0
- package/src/components/Dropdown/_.types.ts +12 -0
- package/src/components/Dropdown/index.tsx +130 -0
- package/src/components/FileUpload/_.stories.tsx +74 -0
- package/src/components/FileUpload/_.style.ts +0 -0
- package/src/components/FileUpload/_.test.tsx +222 -0
- package/src/components/FileUpload/_.types.ts +53 -0
- package/src/components/FileUpload/index.tsx +44 -0
- package/src/components/ImageMagnify/_.stories.tsx +226 -0
- package/src/components/ImageMagnify/_.style.ts +109 -0
- package/src/components/ImageMagnify/_.types.ts +44 -0
- package/src/components/ImageMagnify/index.tsx +204 -0
- package/src/components/Input/_.stories.tsx +177 -0
- package/src/components/Input/_.style.ts +79 -0
- package/src/components/Input/_.test.tsx +146 -0
- package/src/components/Input/_.types.ts +66 -0
- package/src/components/Input/index.tsx +231 -0
- package/src/components/InputTags/_.stories.tsx +51 -0
- package/src/components/InputTags/_.style.ts +28 -0
- package/src/components/InputTags/_.test.tsx +123 -0
- package/src/components/InputTags/_.types.ts +26 -0
- package/src/components/InputTags/index.tsx +140 -0
- package/src/components/Message/_.stories.tsx +79 -0
- package/src/components/Message/_.style.ts +87 -0
- package/src/components/Message/_.test.tsx +73 -0
- package/src/components/Message/_.types.ts +13 -0
- package/src/components/Message/index.tsx +57 -0
- package/src/components/Metric/_.stories.tsx +142 -0
- package/src/components/Metric/_.style.ts +14 -0
- package/src/components/Metric/_.test.tsx +166 -0
- package/src/components/Metric/_.types.ts +18 -0
- package/src/components/Metric/index.tsx +100 -0
- package/src/components/Modal/_.stories.tsx +93 -0
- package/src/components/Modal/_.style.ts +31 -0
- package/src/components/Modal/_.test.tsx +90 -0
- package/src/components/Modal/_.types.ts +14 -0
- package/src/components/Modal/index.tsx +82 -0
- package/src/components/Pagination/_.stories.tsx +118 -0
- package/src/components/Pagination/_.test.tsx +51 -0
- package/src/components/Pagination/index.tsx +256 -0
- package/src/components/Pagination/type.ts +48 -0
- package/src/components/PriceSlider/_.stories.tsx +107 -0
- package/src/components/PriceSlider/_.test.tsx +63 -0
- package/src/components/PriceSlider/_.type.tsx +19 -0
- package/src/components/PriceSlider/index.tsx +86 -0
- package/src/components/Progress/_.stories.tsx +93 -0
- package/src/components/Progress/_.style.ts +15 -0
- package/src/components/Progress/_.test.tsx +34 -0
- package/src/components/Progress/_.types.ts +17 -0
- package/src/components/Progress/index.tsx +173 -0
- package/src/components/Radio/_.stories.tsx +391 -0
- package/src/components/Radio/_.style.ts +33 -0
- package/src/components/Radio/_.test.tsx +77 -0
- package/src/components/Radio/_.types.ts +14 -0
- package/src/components/Radio/index.tsx +59 -0
- package/src/components/Select/_.stories.tsx +308 -0
- package/src/components/Select/_.style.ts +5 -0
- package/src/components/Select/_.types.ts +24 -0
- package/src/components/Select/index.tsx +172 -0
- package/src/components/Switch/_.stories.tsx +61 -0
- package/src/components/Switch/_.test.tsx +69 -0
- package/src/components/Switch/_.type.ts +12 -0
- package/src/components/Switch/index.tsx +70 -0
- package/src/components/Tabs/_.stories.tsx +508 -0
- package/src/components/Tabs/_.style.ts +63 -0
- package/src/components/Tabs/_.test.tsx +174 -0
- package/src/components/Tabs/_.type.ts +19 -0
- package/src/components/Tabs/index.tsx +35 -0
- package/src/components/Tag/_.stories.tsx +78 -0
- package/src/components/Tag/_.style.ts +71 -0
- package/src/components/Tag/_.test.tsx +44 -0
- package/src/components/Tag/_.types.ts +27 -0
- package/src/components/Tag/index.tsx +46 -0
- package/src/components/TextArea/_.stories.tsx +62 -0
- package/src/components/TextArea/_.style.ts +11 -0
- package/src/components/TextArea/_.test.tsx +43 -0
- package/src/components/TextArea/_.types.ts +29 -0
- package/src/components/TextArea/index.tsx +83 -0
- package/src/components/Toast/_.style.tsx +27 -0
- package/src/components/Toast/_.type.ts +30 -0
- package/src/components/Toast/_.utils.ts +23 -0
- package/src/components/Toast/container.tsx +171 -0
- package/src/components/Toast/index.tsx +29 -0
- package/src/components/Tooltip/_.stories.tsx +106 -0
- package/src/components/Tooltip/_.style.ts +27 -0
- package/src/components/Tooltip/_.test.tsx +54 -0
- package/src/components/Tooltip/_.types.ts +31 -0
- package/src/components/Tooltip/index.tsx +80 -0
- package/src/components/developers/AmirHossein.tsx +149 -0
- package/src/components/developers/Fardin.tsx +130 -0
- package/src/components/developers/Maryam.tsx +260 -0
- package/src/components/developers/Milad.tsx +431 -0
- package/src/components/developers/Rasoul.tsx +198 -0
- package/src/components/index.ts +28 -0
- package/src/components/ui/accordion.tsx +162 -0
- package/src/components/ui/avatars-component/avatar-description.tsx +30 -0
- package/src/components/ui/avatars-component/avatar-groups.tsx +68 -0
- package/src/components/ui/avatars-component/avatar-single.tsx +50 -0
- package/src/components/ui/card.tsx +92 -0
- package/src/components/ui/checkbox-group/plan-card/basic/_.test.tsx +66 -0
- package/src/components/ui/checkbox-group/plan-card/basic/index.tsx +70 -0
- package/src/components/ui/checkbox-group/plan-card/with-header/_.test.tsx +110 -0
- package/src/components/ui/checkbox-group/plan-card/with-header/header.test.tsx +96 -0
- package/src/components/ui/checkbox-group/plan-card/with-header/header.tsx +74 -0
- package/src/components/ui/checkbox-group/plan-card/with-header/index.tsx +65 -0
- package/src/components/ui/file-content/File-content.tsx +43 -0
- package/src/components/ui/file-uploader-components/file-uploader-box.tsx +76 -0
- package/src/components/ui/file-uploader-components/file-uploader-item.tsx +64 -0
- package/src/components/ui/icon-wrapper/_.test.tsx +60 -0
- package/src/components/ui/icon-wrapper/index.tsx +19 -0
- package/src/components/ui/input-component/input-label.tsx +11 -0
- package/src/components/ui/number.tsx +18 -0
- package/src/components/ui/pagination/card-minimal-center-align.tsx +96 -0
- package/src/components/ui/pagination/card-minimal-right-aligne.tsx +90 -0
- package/src/components/ui/pagination/default-pagination.tsx +128 -0
- package/src/components/ui/pagination/get-pagination-item.tsx +36 -0
- package/src/components/ui/pagination/pagination-card-button-group-aligned.tsx +94 -0
- package/src/components/ui/pagination/pagination-card-minimal-left-aligned.tsx +90 -0
- package/src/components/ui/pagination/pagination-content.tsx +15 -0
- package/src/components/ui/pagination/pagination-item.tsx +11 -0
- package/src/components/ui/pagination/pagination-link.tsx +42 -0
- package/src/components/ui/tab-components/tabs-content.tsx +15 -0
- package/src/components/ui/tab-components/tabs-list.tsx +27 -0
- package/src/components/ui/tab-components/tabs-trigger.tsx +25 -0
- package/src/components/ui/text-content-wrapper.tsx +36 -0
- package/src/hooks/useClickOutside.ts +23 -0
- package/src/icons/general/ArrowLeft.tsx +31 -0
- package/src/icons/general/ArrowRight.tsx +31 -0
- package/src/icons/general/activity-heart.tsx +31 -0
- package/src/icons/general/activity.tsx +31 -0
- package/src/icons/general/anchor.tsx +31 -0
- package/src/icons/general/archive.tsx +31 -0
- package/src/icons/general/arrow-left.tsx +25 -0
- package/src/icons/general/arrow-right.tsx +25 -0
- package/src/icons/general/asterisk-01.tsx +31 -0
- package/src/icons/general/asterisk-02.tsx +31 -0
- package/src/icons/general/at-sign.tsx +31 -0
- package/src/icons/general/attention-mark.tsx +43 -0
- package/src/icons/general/bookmark-add.tsx +31 -0
- package/src/icons/general/bookmark.tsx +31 -0
- package/src/icons/general/chevron-left.tsx +25 -0
- package/src/icons/general/chevron-right.tsx +25 -0
- package/src/icons/general/circle-minues.tsx +25 -0
- package/src/icons/general/circle-plus.tsx +25 -0
- package/src/icons/general/circle-question-mark.tsx +32 -0
- package/src/icons/general/circle.tsx +32 -0
- package/src/icons/general/copy.tsx +43 -0
- package/src/icons/general/email.tsx +32 -0
- package/src/icons/general/home.tsx +25 -0
- package/src/icons/general/layer.tsx +36 -0
- package/src/icons/general/leading.tsx +19 -0
- package/src/icons/general/master-card.tsx +37 -0
- package/src/icons/general/minus.tsx +36 -0
- package/src/icons/general/plus.tsx +19 -0
- package/src/icons/general/remove.tsx +32 -0
- package/src/icons/general/slash-divider.tsx +26 -0
- package/src/icons/general/tick-box.tsx +37 -0
- package/src/icons/general/trailing.tsx +19 -0
- package/src/icons/general/unkown-format.tsx +25 -0
- package/src/icons/general/visa-card.tsx +38 -0
- package/src/icons/general/x-close.tsx +35 -0
- package/src/icons/icons.type.ts +7 -0
- package/src/index.css +21 -0
- package/src/index.ts +3 -0
- package/src/lib/utils.ts +6 -0
- package/src/lib/zIndexUtils.ts +2 -0
- package/src/main.tsx +50 -0
- package/src/vite-env.d.ts +1 -0
- package/tests/setup.ts +8 -0
- package/tsconfig.app.json +31 -0
- package/tsconfig.json +7 -0
- package/tsconfig.node.json +24 -0
- package/tsconfig.rollup.json +12 -0
- package/vite.config.ts +20 -0
- package/vitest.config.ts +47 -0
package/.gitlab-ci.yml
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# This file is a template, and might need editing before it works on your project.
|
|
2
|
+
# This is a sample GitLab CI/CD configuration file that should run without any modifications.
|
|
3
|
+
# It demonstrates a basic 3 stage CI/CD pipeline. Instead of real tests or scripts,
|
|
4
|
+
# it uses echo commands to simulate the pipeline execution.
|
|
5
|
+
#
|
|
6
|
+
# A pipeline is composed of independent jobs that run scripts, grouped into stages.
|
|
7
|
+
# Stages run in sequential order, but jobs within stages run in parallel.
|
|
8
|
+
#
|
|
9
|
+
# For more information, see: https://docs.gitlab.com/ee/ci/yaml/#stages
|
|
10
|
+
#
|
|
11
|
+
# You can copy and paste this template into a new `.gitlab-ci.yml` file.
|
|
12
|
+
# You should not add this template to an existing `.gitlab-ci.yml` file by using the `include:` keyword.
|
|
13
|
+
#
|
|
14
|
+
# To contribute improvements to CI/CD templates, please follow the Development guide at:
|
|
15
|
+
# https://docs.gitlab.com/development/cicd/templates/
|
|
16
|
+
# This specific template is located at:
|
|
17
|
+
# https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/ci/templates/Getting-Started.gitlab-ci.yml
|
|
18
|
+
|
|
19
|
+
stages: # List of stages for jobs, and their order of execution
|
|
20
|
+
- test
|
|
21
|
+
- deploy
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
unit-test-job: # This job runs in the test stage.
|
|
25
|
+
stage: test # It only starts when the job in the build stage completes successfully.
|
|
26
|
+
script:
|
|
27
|
+
- echo "Running unit tests... This will take about 60 seconds."
|
|
28
|
+
- pnpm install && pnpm test && pnpm build
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
deploy-job: # This job runs in the deploy stage.
|
|
32
|
+
stage: deploy # It only runs when *both* jobs in the test stage complete successfully.
|
|
33
|
+
environment: production
|
|
34
|
+
script:
|
|
35
|
+
- echo "Deploying application..."
|
|
36
|
+
- echo $SSH_USER
|
|
37
|
+
- echo $SERVER_HOST
|
|
38
|
+
- echo $DEPLOY_PATH
|
|
39
|
+
- whoami
|
|
40
|
+
- ssh $SSH_USER@$SERVER_HOST "cd $DEPLOY_PATH && git pull && pnpm install && pm2 restart all"
|
|
41
|
+
- echo "Application successfully deployed."
|
|
42
|
+
only:
|
|
43
|
+
- main
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { StorybookConfig } from "@storybook/react-vite";
|
|
2
|
+
|
|
3
|
+
const config: StorybookConfig = {
|
|
4
|
+
stories: ["../src/**/*.mdx", "../src/**/*.stories.@(js|jsx|mjs|ts|tsx)"],
|
|
5
|
+
addons: [
|
|
6
|
+
"@storybook/addon-onboarding",
|
|
7
|
+
"@chromatic-com/storybook",
|
|
8
|
+
"@storybook/addon-docs"
|
|
9
|
+
],
|
|
10
|
+
framework: {
|
|
11
|
+
name: "@storybook/react-vite",
|
|
12
|
+
options: {},
|
|
13
|
+
},
|
|
14
|
+
};
|
|
15
|
+
export default config;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import "../src/index.css";
|
|
2
|
+
import type { Preview } from "@storybook/react-vite";
|
|
3
|
+
|
|
4
|
+
const preview: Preview = {
|
|
5
|
+
parameters: {
|
|
6
|
+
controls: {
|
|
7
|
+
matchers: {
|
|
8
|
+
color: /(background|color)$/i,
|
|
9
|
+
date: /Date$/i,
|
|
10
|
+
},
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export default preview;
|
package/README.md
ADDED
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
# RG Design System Template – Developer Guide
|
|
2
|
+
|
|
3
|
+
A scalable, reusable React + TypeScript component library with Vite, Tailwind CSS, Storybook, ESLint, and Vitest. This README helps new contributors understand the structure, conventions, and workflows to confidently add or update code and resolve issues.
|
|
4
|
+
|
|
5
|
+
## Stack
|
|
6
|
+
- React 19, TypeScript 5, Vite 6
|
|
7
|
+
- Tailwind CSS 4 (with `@tailwindcss/vite`); PostCSS for CSS build
|
|
8
|
+
- Storybook 8 (React + Vite)
|
|
9
|
+
- Vitest 3 + Testing Library + JSDOM
|
|
10
|
+
- ESLint 9 (typescript-eslint, react-hooks, react-refresh)
|
|
11
|
+
- Rollup for library bundling (ESM + CJS + DTS)
|
|
12
|
+
|
|
13
|
+
## Project Structure
|
|
14
|
+
|
|
15
|
+
```
|
|
16
|
+
.
|
|
17
|
+
├─ src/
|
|
18
|
+
│ ├─ assets/
|
|
19
|
+
│ │ └─ style/ # Base CSS tokens and utilities (compiled into dist/style.css)
|
|
20
|
+
│ ├─ components/
|
|
21
|
+
│ │ ├─ <ComponentName>/ # One folder per public component
|
|
22
|
+
│ │ │ ├─ index.tsx # Component implementation (export default/named)
|
|
23
|
+
│ │ │ ├─ _.style.ts # Styles (e.g., cva, class composition)
|
|
24
|
+
│ │ │ ├─ _.types.ts|type.ts # Component props/types
|
|
25
|
+
│ │ │ ├─ _.stories.tsx # Storybook stories
|
|
26
|
+
│ │ │ └─ _.test.tsx # Unit tests (Vitest + Testing Library)
|
|
27
|
+
│ │ ├─ developers/ # Showcase profiles (excluded from coverage)
|
|
28
|
+
│ │ └─ ui/ # Internal building blocks (not public API)
|
|
29
|
+
│ ├─ hooks/ # Reusable hooks
|
|
30
|
+
│ ├─ icons/ # Icon components + types (excluded from coverage)
|
|
31
|
+
│ ├─ lib/ # Utilities shared by components
|
|
32
|
+
│ ├─ index.ts # Library public exports
|
|
33
|
+
│ ├─ index.css # Tailwind entry (built via PostCSS)
|
|
34
|
+
│ └─ main.tsx # Local playground entry (not part of build output)
|
|
35
|
+
├─ tests/setup.ts # Vitest setup (jsdom, matchers)
|
|
36
|
+
├─ vite.config.ts # Vite + Vitest base config (alias '@' → './src')
|
|
37
|
+
├─ vitest.config.ts # Test include/exclude and coverage rules
|
|
38
|
+
├─ eslint.config.js # ESLint rules and TS integration
|
|
39
|
+
├─ postcss.config.mjs # PostCSS pipeline (imports, autoprefixer)
|
|
40
|
+
├─ rollup.config.mjs # Library bundle (esm/cjs/dts) for publish
|
|
41
|
+
├─ package.json # Scripts, exports, deps, peer deps
|
|
42
|
+
├─ dist/ # Build output (ignored in dev)
|
|
43
|
+
└─ public/ # Static assets used by Storybook/demo
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### Naming and File Conventions
|
|
47
|
+
- Component folders are `PascalCase` and contain the standard set: `index.tsx`, `_.style.ts`, `_.types.ts` (or `type.ts`), `_.stories.tsx`, `_.test.tsx`.
|
|
48
|
+
- Internal-only primitives live under `src/components/ui` and should not be exported from the library root.
|
|
49
|
+
- The alias `@` resolves to `./src` (import like `import { cn } from '@/lib/utils'`).
|
|
50
|
+
- CSS tokens live in `src/assets/style/*.css`; the library bundles `dist/style.css` (see exports in `package.json`).
|
|
51
|
+
|
|
52
|
+
## Getting Started
|
|
53
|
+
|
|
54
|
+
Prereqs: Node 18+ (or 20+), PNPM recommended.
|
|
55
|
+
|
|
56
|
+
Install dependencies:
|
|
57
|
+
```bash
|
|
58
|
+
pnpm install
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
Run the dev playground (Vite):
|
|
62
|
+
```bash
|
|
63
|
+
pnpm dev
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Open Storybook for component docs:
|
|
67
|
+
```bash
|
|
68
|
+
pnpm story
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
Run tests:
|
|
72
|
+
```bash
|
|
73
|
+
pnpm test
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
Run tests with coverage:
|
|
77
|
+
```bash
|
|
78
|
+
pnpm coverage
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
Lint the repo:
|
|
82
|
+
```bash
|
|
83
|
+
pnpm lint
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
Build the library (types + CSS + bundles):
|
|
87
|
+
```bash
|
|
88
|
+
pnpm build
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
Full release build (test → vite build → rollup):
|
|
92
|
+
```bash
|
|
93
|
+
pnpm rollup
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
## Exports and Consumers
|
|
97
|
+
|
|
98
|
+
`package.json` exposes:
|
|
99
|
+
- ESM: `dist/index.mjs`
|
|
100
|
+
- CJS: `dist/index.js`
|
|
101
|
+
- Types: `dist/index.d.ts`
|
|
102
|
+
- CSS: `dist/style.css` (via subpath export)
|
|
103
|
+
|
|
104
|
+
Consumers can:
|
|
105
|
+
```tsx
|
|
106
|
+
import { Button } from 'rg-dst';
|
|
107
|
+
import 'rg-dst/dist/style.css';
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
## Adding a New Component
|
|
111
|
+
|
|
112
|
+
1) Scaffold folder: `src/components/<ComponentName>/` with files:
|
|
113
|
+
- `index.tsx` – component implementation
|
|
114
|
+
- `_.types.ts` – define prop types; export `ComponentNameProps`
|
|
115
|
+
- `_.style.ts` – class builders (e.g., with `class-variance-authority`) and helpers
|
|
116
|
+
- `_.stories.tsx` – at least default and variants stories
|
|
117
|
+
- `_.test.tsx` – render, states, a11y basics
|
|
118
|
+
|
|
119
|
+
2) Implement component:
|
|
120
|
+
- Keep public API small and typed. Prefer controlled props where appropriate.
|
|
121
|
+
- Compose classes using `clsx`/`cva`. Do not inline large style strings.
|
|
122
|
+
- Avoid leaking internal implementation details through props.
|
|
123
|
+
|
|
124
|
+
3) Export from library:
|
|
125
|
+
- Re-export from `src/components/index.ts` or `src/index.ts` according to the existing pattern.
|
|
126
|
+
|
|
127
|
+
4) Document in Storybook:
|
|
128
|
+
- Include controls for all public props.
|
|
129
|
+
- Add usage notes and edge cases in stories or MDX docs.
|
|
130
|
+
|
|
131
|
+
5) Tests:
|
|
132
|
+
- Use `@testing-library/react` with JSDOM.
|
|
133
|
+
- Cover critical behaviors, keyboard interactions, and edge states.
|
|
134
|
+
- Place snapshots only for minimal structural assurance (avoid brittle snapshots).
|
|
135
|
+
|
|
136
|
+
6) Styles and Tokens:
|
|
137
|
+
- Reuse tokens from `src/assets/style/*` when possible.
|
|
138
|
+
- If adding new primitive tokens, update CSS files with clear, scoped variables.
|
|
139
|
+
|
|
140
|
+
## Updating an Existing Component
|
|
141
|
+
|
|
142
|
+
1) Search for usages across stories, tests, and `src/components/ui` primitives before changing prop names or behavior.
|
|
143
|
+
|
|
144
|
+
2) Maintain backward compatibility when feasible. If a breaking change is necessary:
|
|
145
|
+
- Adjust stories and tests.
|
|
146
|
+
- Update release notes and communicate migration steps in the PR description.
|
|
147
|
+
|
|
148
|
+
3) Keep `_.types.ts` as the single source of truth for props and update stories/tests accordingly.
|
|
149
|
+
|
|
150
|
+
4) Performance and a11y:
|
|
151
|
+
- Use `React.memo`/`useMemo` only when it removes real work; avoid premature optimization.
|
|
152
|
+
- Ensure focus management and ARIA attributes are correct (especially for interactive components).
|
|
153
|
+
|
|
154
|
+
## Testing & Coverage
|
|
155
|
+
|
|
156
|
+
Vitest is configured with JSDOM and global test APIs. Defaults:
|
|
157
|
+
- Includes: `src/**/*.test.{ts,tsx}`, `src/**/*.spec.{ts,tsx}`
|
|
158
|
+
- Excludes: `node_modules`, `dist`, `**/*.stories.tsx`, `**/*.style.ts`, `**/*.types.ts`, `src/icons/**/*.{ts,tsx}`
|
|
159
|
+
|
|
160
|
+
Coverage includes `src/**/*.{ts,tsx}` with further excludes:
|
|
161
|
+
- Stories, styles, types, icons
|
|
162
|
+
- `src/components/developers/**`
|
|
163
|
+
- `tests/**`, `dist/**`, `src/main.tsx`, `src/vite-env.d.ts`
|
|
164
|
+
|
|
165
|
+
Command hints:
|
|
166
|
+
```bash
|
|
167
|
+
pnpm test # run unit tests
|
|
168
|
+
pnpm coverage # generate text/json/html coverage
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
## Linting & Code Style
|
|
172
|
+
|
|
173
|
+
ESLint rules are defined in `eslint.config.js`:
|
|
174
|
+
- Typescript-eslint recommended rules
|
|
175
|
+
- React hooks rules enforced
|
|
176
|
+
- `@typescript-eslint/no-explicit-any` is disabled where pragmatic
|
|
177
|
+
- `react-refresh/only-export-components` warned to keep HMR-friendly exports
|
|
178
|
+
|
|
179
|
+
Guidelines:
|
|
180
|
+
- Prefer clear, descriptive names over abbreviations.
|
|
181
|
+
- Keep components focused; extract internal UI into `src/components/ui`.
|
|
182
|
+
- Minimal comments; only for non-obvious rationale or caveats.
|
|
183
|
+
- Early returns over deep nesting; avoid broad try/catch.
|
|
184
|
+
|
|
185
|
+
## Styles & Theming
|
|
186
|
+
|
|
187
|
+
- Tailwind via Vite plugin; utility composition preferred.
|
|
188
|
+
- Shared tokens and utilities live in `src/assets/style/*.css`.
|
|
189
|
+
- Library CSS is built with `pnpm build:css` to `dist/style.css`. Consumers must import it.
|
|
190
|
+
|
|
191
|
+
## Icons
|
|
192
|
+
|
|
193
|
+
- Add icons to `src/icons/general` as React components.
|
|
194
|
+
- Keep icon types in `src/icons/icons.type.ts`.
|
|
195
|
+
- Icons are excluded from test coverage; still add basic validation where necessary.
|
|
196
|
+
|
|
197
|
+
## Aliases
|
|
198
|
+
|
|
199
|
+
`@` → `./src` (configured in both `vite.config.ts` and `vitest.config.ts`). Example:
|
|
200
|
+
```ts
|
|
201
|
+
import { cn } from '@/lib/utils'
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
## Scripts (from package.json)
|
|
205
|
+
|
|
206
|
+
- `pnpm dev` – Start Vite dev server (with `--host` for LAN testing)
|
|
207
|
+
- `pnpm build:css` – Build `src/index.css` to `dist/style.css` via PostCSS
|
|
208
|
+
- `pnpm build` – TypeScript build + CSS build + Vite build
|
|
209
|
+
- `pnpm rollup` – Run tests, Vite build, and Rollup bundle (esm/cjs/dts)
|
|
210
|
+
- `pnpm story` – Run Storybook on port 6006
|
|
211
|
+
- `pnpm build-storybook` – Generate static Storybook
|
|
212
|
+
- `pnpm test` – Run Vitest
|
|
213
|
+
- `pnpm coverage` – Vitest with coverage
|
|
214
|
+
- `pnpm lint` – Run ESLint
|
|
215
|
+
|
|
216
|
+
## Publishing Notes
|
|
217
|
+
|
|
218
|
+
- Ensure `peerDependencies` for `react` and `react-dom` are correct.
|
|
219
|
+
- Verify `exports` map and `types` in `package.json`.
|
|
220
|
+
- Run `pnpm rollup` and verify `dist/` contains `.mjs`, `.js`, `.d.ts`, and `style.css`.
|
|
221
|
+
|
|
222
|
+
## Troubleshooting
|
|
223
|
+
|
|
224
|
+
- Dev server fails to start
|
|
225
|
+
- Delete `node_modules` and lockfile, then `pnpm install`.
|
|
226
|
+
- Ensure Node version ≥ 18.
|
|
227
|
+
|
|
228
|
+
- Storybook cannot resolve `@` alias
|
|
229
|
+
- Restart Storybook after changes to `vite.config.ts`.
|
|
230
|
+
- Confirm alias is set in both `vite.config.ts` and Storybook config (React-Vite preset handles this).
|
|
231
|
+
|
|
232
|
+
- Tests fail with DOM-related errors
|
|
233
|
+
- Ensure `jsdom` environment is set (it is in config). Check `tests/setup.ts` path.
|
|
234
|
+
|
|
235
|
+
- Coverage missing for new files
|
|
236
|
+
- Confirm files are within `src/` and not in an excluded pattern.
|
|
237
|
+
|
|
238
|
+
- Styles not applied in consumer app
|
|
239
|
+
- Remind consumers to import `'rg-dst/dist/style.css'`.
|
|
240
|
+
|
|
241
|
+
## Contribution Workflow
|
|
242
|
+
|
|
243
|
+
1. Create a feature branch: `git checkout -b feat/<short-name>`
|
|
244
|
+
2. Implement changes with stories and tests.
|
|
245
|
+
3. Run `pnpm lint && pnpm test && pnpm build` locally.
|
|
246
|
+
4. Open a PR with:
|
|
247
|
+
- Summary of changes
|
|
248
|
+
- Screenshots (stories) if visual
|
|
249
|
+
- Breaking changes and migration notes
|
|
250
|
+
5. Request review; address feedback; squash and merge.
|
|
251
|
+
|
|
252
|
+
---
|
|
253
|
+
|
|
254
|
+
Questions or issues? Open an issue with context, repro steps, and environment details.
|
package/components.json
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://ui.shadcn.com/schema.json",
|
|
3
|
+
"style": "new-york",
|
|
4
|
+
"rsc": false,
|
|
5
|
+
"tsx": true,
|
|
6
|
+
"tailwind": {
|
|
7
|
+
"config": "",
|
|
8
|
+
"css": "src/index.css",
|
|
9
|
+
"baseColor": "neutral",
|
|
10
|
+
"cssVariables": true,
|
|
11
|
+
"prefix": ""
|
|
12
|
+
},
|
|
13
|
+
"aliases": {
|
|
14
|
+
"components": "@/components",
|
|
15
|
+
"utils": "@/lib/utils",
|
|
16
|
+
"ui": "@/components/ui",
|
|
17
|
+
"lib": "@/lib",
|
|
18
|
+
"hooks": "@/hooks"
|
|
19
|
+
},
|
|
20
|
+
"iconLibrary": "lucide"
|
|
21
|
+
}
|
package/dist/Avatar.png
ADDED
|
Binary file
|