seven-design-ui 0.0.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/.eslintrc.json +35 -0
- package/.prettierrc.json +10 -0
- package/CONTRIBUTING.md +350 -0
- package/PROJECT_STRUCTURE.md +343 -0
- package/README.md +83 -0
- package/app/globals.css +125 -0
- package/app/layout.tsx +45 -0
- package/app/page.tsx +202 -0
- package/components/theme-provider.tsx +11 -0
- package/components/ui/accordion.tsx +66 -0
- package/components/ui/alert-dialog.tsx +157 -0
- package/components/ui/alert.tsx +66 -0
- package/components/ui/aspect-ratio.tsx +11 -0
- package/components/ui/avatar.tsx +53 -0
- package/components/ui/badge.tsx +46 -0
- package/components/ui/breadcrumb.tsx +109 -0
- package/components/ui/button-group.tsx +83 -0
- package/components/ui/button.tsx +60 -0
- package/components/ui/calendar.tsx +213 -0
- package/components/ui/card.tsx +92 -0
- package/components/ui/carousel.tsx +241 -0
- package/components/ui/chart.tsx +353 -0
- package/components/ui/checkbox.tsx +32 -0
- package/components/ui/collapsible.tsx +33 -0
- package/components/ui/command.tsx +184 -0
- package/components/ui/context-menu.tsx +252 -0
- package/components/ui/dialog.tsx +143 -0
- package/components/ui/drawer.tsx +135 -0
- package/components/ui/dropdown-menu.tsx +257 -0
- package/components/ui/empty.tsx +104 -0
- package/components/ui/field.tsx +244 -0
- package/components/ui/form.tsx +167 -0
- package/components/ui/hover-card.tsx +44 -0
- package/components/ui/input-group.tsx +169 -0
- package/components/ui/input-otp.tsx +77 -0
- package/components/ui/input.tsx +21 -0
- package/components/ui/item.tsx +193 -0
- package/components/ui/kbd.tsx +28 -0
- package/components/ui/label.tsx +24 -0
- package/components/ui/menubar.tsx +276 -0
- package/components/ui/navigation-menu.tsx +166 -0
- package/components/ui/pagination.tsx +127 -0
- package/components/ui/popover.tsx +48 -0
- package/components/ui/progress.tsx +31 -0
- package/components/ui/radio-group.tsx +45 -0
- package/components/ui/resizable.tsx +56 -0
- package/components/ui/scroll-area.tsx +58 -0
- package/components/ui/select.tsx +185 -0
- package/components/ui/separator.tsx +28 -0
- package/components/ui/sheet.tsx +139 -0
- package/components/ui/sidebar.tsx +726 -0
- package/components/ui/skeleton.tsx +13 -0
- package/components/ui/slider.tsx +63 -0
- package/components/ui/sonner.tsx +25 -0
- package/components/ui/spinner.tsx +16 -0
- package/components/ui/switch.tsx +31 -0
- package/components/ui/table.tsx +116 -0
- package/components/ui/tabs.tsx +66 -0
- package/components/ui/textarea.tsx +18 -0
- package/components/ui/toast.tsx +129 -0
- package/components/ui/toaster.tsx +35 -0
- package/components/ui/toggle-group.tsx +73 -0
- package/components/ui/toggle.tsx +47 -0
- package/components/ui/tooltip.tsx +61 -0
- package/components/ui/use-mobile.tsx +19 -0
- package/components/ui/use-toast.ts +191 -0
- package/components.json +21 -0
- package/docs/components/button.mdx +155 -0
- package/docs/components/input.mdx +157 -0
- package/docs/components/pagination.mdx +186 -0
- package/docs/components/switch.mdx +134 -0
- package/docs/doc_build/.nojekyll +0 -0
- package/docs/doc_build/404.html +15 -0
- package/docs/doc_build/components/button.html +39 -0
- package/docs/doc_build/components/input.html +39 -0
- package/docs/doc_build/components/pagination.html +39 -0
- package/docs/doc_build/components/switch.html +38 -0
- package/docs/doc_build/guide/introduction.html +58 -0
- package/docs/doc_build/guide/quick-start.html +98 -0
- package/docs/doc_build/guide/theme.html +139 -0
- package/docs/doc_build/index.html +15 -0
- package/docs/doc_build/logo.svg +1 -0
- package/docs/doc_build/static/css/styles.5a3e7113.css +1 -0
- package/docs/doc_build/static/js/414.04bb58dd.js +6 -0
- package/docs/doc_build/static/js/414.04bb58dd.js.LICENSE.txt +21 -0
- package/docs/doc_build/static/js/async/166.f43be01a.js +2 -0
- package/docs/doc_build/static/js/async/166.f43be01a.js.LICENSE.txt +19 -0
- package/docs/doc_build/static/js/async/218.cd780e24.js +1 -0
- package/docs/doc_build/static/js/async/232.11414fd7.js +1 -0
- package/docs/doc_build/static/js/async/416.b217df75.js +1 -0
- package/docs/doc_build/static/js/async/509.97958e51.js +1 -0
- package/docs/doc_build/static/js/async/512.9047d21e.js +1 -0
- package/docs/doc_build/static/js/async/531.131f5963.js +1 -0
- package/docs/doc_build/static/js/async/562.b402b94f.js +2 -0
- package/docs/doc_build/static/js/async/562.b402b94f.js.LICENSE.txt +11 -0
- package/docs/doc_build/static/js/async/637.cb5d76c9.js +1 -0
- package/docs/doc_build/static/js/async/712.558b85be.js +1 -0
- package/docs/doc_build/static/js/index.0991c749.js +1 -0
- package/docs/doc_build/static/js/lib-react.ce4199ca.js +2 -0
- package/docs/doc_build/static/js/lib-react.ce4199ca.js.LICENSE.txt +49 -0
- package/docs/doc_build/static/js/lib-router.4000fe55.js +2 -0
- package/docs/doc_build/static/js/lib-router.4000fe55.js.LICENSE.txt +32 -0
- package/docs/doc_build/static/js/styles.f2af9a40.js +1 -0
- package/docs/doc_build/static/search_index.72c9c372.json +1 -0
- package/docs/docs/public/logo.svg +1 -0
- package/docs/guide/introduction.md +50 -0
- package/docs/guide/quick-start.md +132 -0
- package/docs/guide/theme.md +230 -0
- package/docs/index.md +85 -0
- package/docs/package.json +22 -0
- package/docs/public/logo.svg +1 -0
- package/docs/rspress.config.ts +116 -0
- package/hooks/use-mobile.ts +19 -0
- package/hooks/use-toast.ts +191 -0
- package/next.config.mjs +11 -0
- package/package.json +75 -0
- package/packages/components/package.json +34 -0
- package/packages/components/src/button/Button.tsx +83 -0
- package/packages/components/src/button/button.css +256 -0
- package/packages/components/src/button/index.ts +2 -0
- package/packages/components/src/index.ts +8 -0
- package/packages/components/src/input/Input.tsx +230 -0
- package/packages/components/src/input/index.ts +2 -0
- package/packages/components/src/input/input.css +99 -0
- package/packages/components/src/pagination/Pagination.tsx +271 -0
- package/packages/components/src/pagination/index.ts +1 -0
- package/packages/components/src/pagination/pagination.css +225 -0
- package/packages/components/src/switch/Switch.tsx +145 -0
- package/packages/components/src/switch/index.ts +2 -0
- package/packages/components/src/switch/switch.css +119 -0
- package/packages/components/tsconfig.json +12 -0
- package/packages/components/vite.config.ts +31 -0
- package/packages/core/package.json +23 -0
- package/packages/core/src/hooks/useControllableState.ts +31 -0
- package/packages/core/src/hooks/useEventListener.ts +37 -0
- package/packages/core/src/index.ts +7 -0
- package/packages/core/src/utils/classnames.ts +48 -0
- package/packages/core/tsconfig.json +12 -0
- package/packages/core/vite.config.ts +24 -0
- package/packages/theme/package.json +20 -0
- package/packages/theme/src/index.css +138 -0
- package/packages/theme/src/index.ts +1 -0
- package/packages/theme/vite.config.ts +21 -0
- package/play/index.html +13 -0
- package/play/package.json +25 -0
- package/play/src/App.tsx +237 -0
- package/play/src/index.css +93 -0
- package/play/src/main.tsx +14 -0
- package/play/tsconfig.json +8 -0
- package/play/vite.config.ts +10 -0
- package/pnpm-workspace.yaml +4 -0
- package/postcss.config.mjs +8 -0
- package/public/logo.svg +1 -0
- package/scripts/build.sh +19 -0
- package/scripts/deploy-docs.js +38 -0
- package/styles/globals.css +125 -0
- package/tsconfig.json +30 -0
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { defineConfig } from 'vite'
|
|
2
|
+
import { resolve } from 'path'
|
|
3
|
+
|
|
4
|
+
export default defineConfig({
|
|
5
|
+
build: {
|
|
6
|
+
lib: {
|
|
7
|
+
entry: resolve(__dirname, 'src/index.ts'),
|
|
8
|
+
name: 'SevenDesignCore',
|
|
9
|
+
formats: ['es', 'cjs'],
|
|
10
|
+
fileName: (format) => `index.${format === 'es' ? 'esm' : 'cjs'}.js`,
|
|
11
|
+
},
|
|
12
|
+
rollupOptions: {
|
|
13
|
+
external: ['react', 'react-dom'],
|
|
14
|
+
output: {
|
|
15
|
+
globals: {
|
|
16
|
+
react: 'React',
|
|
17
|
+
'react-dom': 'ReactDOM',
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
outDir: 'dist',
|
|
22
|
+
emptyOutDir: true,
|
|
23
|
+
},
|
|
24
|
+
})
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@seven-design-ui/theme",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "SevenDesign UI 主题样式包",
|
|
5
|
+
"main": "dist/index.css",
|
|
6
|
+
"module": "dist/index.css",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"files": [
|
|
9
|
+
"dist",
|
|
10
|
+
"src"
|
|
11
|
+
],
|
|
12
|
+
"scripts": {
|
|
13
|
+
"build": "vite build",
|
|
14
|
+
"dev": "vite build --watch"
|
|
15
|
+
},
|
|
16
|
+
"peerDependencies": {},
|
|
17
|
+
"publishConfig": {
|
|
18
|
+
"access": "public"
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
/* SevenDesign 主题样式 */
|
|
2
|
+
|
|
3
|
+
/* ========== CSS Variables ========== */
|
|
4
|
+
:root {
|
|
5
|
+
/* 品牌色 */
|
|
6
|
+
--sd-color-primary: #409eff;
|
|
7
|
+
--sd-color-success: #67c23a;
|
|
8
|
+
--sd-color-warning: #e6a23c;
|
|
9
|
+
--sd-color-danger: #f56c6c;
|
|
10
|
+
--sd-color-info: #909399;
|
|
11
|
+
|
|
12
|
+
/* 主色调色板 */
|
|
13
|
+
--sd-color-primary-light-3: #79bbff;
|
|
14
|
+
--sd-color-primary-light-5: #a0cfff;
|
|
15
|
+
--sd-color-primary-light-7: #c6e2ff;
|
|
16
|
+
--sd-color-primary-light-8: #d9ecff;
|
|
17
|
+
--sd-color-primary-light-9: #ecf5ff;
|
|
18
|
+
--sd-color-primary-dark-2: #337ecc;
|
|
19
|
+
|
|
20
|
+
/* Success 色调色板 */
|
|
21
|
+
--sd-color-success-light-5: #b3e19d;
|
|
22
|
+
--sd-color-success-light-9: #f0f9eb;
|
|
23
|
+
|
|
24
|
+
/* Warning 色调色板 */
|
|
25
|
+
--sd-color-warning-light-5: #f3d19e;
|
|
26
|
+
--sd-color-warning-light-9: #fdf6ec;
|
|
27
|
+
|
|
28
|
+
/* Danger 色调色板 */
|
|
29
|
+
--sd-color-danger-light-5: #f89898;
|
|
30
|
+
--sd-color-danger-light-9: #fef0f0;
|
|
31
|
+
|
|
32
|
+
/* Info 色调色板 */
|
|
33
|
+
--sd-color-info-light-5: #c8c9cc;
|
|
34
|
+
--sd-color-info-light-9: #f4f4f5;
|
|
35
|
+
|
|
36
|
+
/* 中性色 */
|
|
37
|
+
--sd-color-white: #ffffff;
|
|
38
|
+
--sd-color-black: #000000;
|
|
39
|
+
--sd-text-color-primary: #303133;
|
|
40
|
+
--sd-text-color-regular: #606266;
|
|
41
|
+
--sd-text-color-secondary: #909399;
|
|
42
|
+
--sd-text-color-placeholder: #a8abb2;
|
|
43
|
+
--sd-text-color-disabled: #c0c4cc;
|
|
44
|
+
|
|
45
|
+
/* 边框颜色 */
|
|
46
|
+
--sd-border-color: #dcdfe6;
|
|
47
|
+
--sd-border-color-light: #e4e7ed;
|
|
48
|
+
--sd-border-color-lighter: #ebeef5;
|
|
49
|
+
--sd-border-color-extra-light: #f2f6fc;
|
|
50
|
+
--sd-border-color-dark: #d4d7de;
|
|
51
|
+
--sd-border-color-darker: #cdd0d6;
|
|
52
|
+
|
|
53
|
+
/* 背景色 */
|
|
54
|
+
--sd-fill-color-blank: #ffffff;
|
|
55
|
+
--sd-bg-color: #ffffff;
|
|
56
|
+
--sd-bg-color-page: #f2f3f5;
|
|
57
|
+
--sd-bg-color-overlay: #ffffff;
|
|
58
|
+
|
|
59
|
+
/* 尺寸 */
|
|
60
|
+
--sd-border-radius-base: 4px;
|
|
61
|
+
--sd-border-radius-small: 2px;
|
|
62
|
+
--sd-border-radius-round: 20px;
|
|
63
|
+
--sd-border-radius-circle: 100%;
|
|
64
|
+
|
|
65
|
+
/* 字体大小 */
|
|
66
|
+
--sd-font-size-extra-large: 20px;
|
|
67
|
+
--sd-font-size-large: 18px;
|
|
68
|
+
--sd-font-size-medium: 16px;
|
|
69
|
+
--sd-font-size-base: 14px;
|
|
70
|
+
--sd-font-size-small: 13px;
|
|
71
|
+
--sd-font-size-extra-small: 12px;
|
|
72
|
+
|
|
73
|
+
/* 组件尺寸 */
|
|
74
|
+
--sd-component-size-large: 40px;
|
|
75
|
+
--sd-component-size-default: 32px;
|
|
76
|
+
--sd-component-size-small: 24px;
|
|
77
|
+
|
|
78
|
+
/* 阴影 */
|
|
79
|
+
--sd-box-shadow-base: 0 2px 4px rgba(0, 0, 0, 0.12), 0 0 6px rgba(0, 0, 0, 0.04);
|
|
80
|
+
--sd-box-shadow-light: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
|
|
81
|
+
--sd-box-shadow-lighter: 0 2px 8px 0 rgba(0, 0, 0, 0.06);
|
|
82
|
+
--sd-box-shadow-dark: 0 2px 16px 0 rgba(0, 0, 0, 0.12);
|
|
83
|
+
|
|
84
|
+
/* 禁用状态 */
|
|
85
|
+
--sd-disabled-bg-color: var(--sd-fill-color-blank);
|
|
86
|
+
--sd-disabled-text-color: var(--sd-text-color-placeholder);
|
|
87
|
+
--sd-disabled-border-color: var(--sd-border-color-light);
|
|
88
|
+
|
|
89
|
+
/* 过渡动画 */
|
|
90
|
+
--sd-transition-duration: 0.3s;
|
|
91
|
+
--sd-transition-duration-fast: 0.2s;
|
|
92
|
+
--sd-transition-function-ease-in-out-bezier: cubic-bezier(0.645, 0.045, 0.355, 1);
|
|
93
|
+
--sd-transition-function-fast-bezier: cubic-bezier(0.23, 1, 0.32, 1);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/* 暗色主题 */
|
|
97
|
+
.sd-dark {
|
|
98
|
+
--sd-color-primary: #409eff;
|
|
99
|
+
--sd-text-color-primary: #e5eaf3;
|
|
100
|
+
--sd-text-color-regular: #cfd3dc;
|
|
101
|
+
--sd-text-color-secondary: #a3a6ad;
|
|
102
|
+
--sd-text-color-placeholder: #8d9095;
|
|
103
|
+
--sd-text-color-disabled: #6c6e72;
|
|
104
|
+
--sd-border-color: #4c4d4f;
|
|
105
|
+
--sd-border-color-light: #414243;
|
|
106
|
+
--sd-border-color-lighter: #363637;
|
|
107
|
+
--sd-border-color-extra-light: #2b2b2c;
|
|
108
|
+
--sd-fill-color-blank: #1d1e1f;
|
|
109
|
+
--sd-bg-color: #141414;
|
|
110
|
+
--sd-bg-color-page: #0a0a0a;
|
|
111
|
+
--sd-bg-color-overlay: #1d1e1f;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/* ========== 重置样式 ========== */
|
|
115
|
+
* {
|
|
116
|
+
box-sizing: border-box;
|
|
117
|
+
margin: 0;
|
|
118
|
+
padding: 0;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/* ========== 工具类 ========== */
|
|
122
|
+
.sd-clearfix::after {
|
|
123
|
+
content: '';
|
|
124
|
+
display: table;
|
|
125
|
+
clear: both;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
.sd-sr-only {
|
|
129
|
+
position: absolute;
|
|
130
|
+
width: 1px;
|
|
131
|
+
height: 1px;
|
|
132
|
+
padding: 0;
|
|
133
|
+
margin: -1px;
|
|
134
|
+
overflow: hidden;
|
|
135
|
+
clip: rect(0, 0, 0, 0);
|
|
136
|
+
white-space: nowrap;
|
|
137
|
+
border-width: 0;
|
|
138
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import './index.css'
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { defineConfig } from 'vite'
|
|
2
|
+
import { resolve } from 'path'
|
|
3
|
+
|
|
4
|
+
export default defineConfig({
|
|
5
|
+
build: {
|
|
6
|
+
lib: {
|
|
7
|
+
entry: resolve(__dirname, 'src/index.ts'),
|
|
8
|
+
name: 'SevenDesignTheme',
|
|
9
|
+
fileName: 'index',
|
|
10
|
+
formats: ['es'],
|
|
11
|
+
},
|
|
12
|
+
outDir: 'dist',
|
|
13
|
+
cssCodeSplit: false,
|
|
14
|
+
emptyOutDir: true,
|
|
15
|
+
rollupOptions: {
|
|
16
|
+
output: {
|
|
17
|
+
assetFileNames: 'index.css',
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
})
|
package/play/index.html
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="zh-CN">
|
|
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>SevenDesign Playground</title>
|
|
8
|
+
</head>
|
|
9
|
+
<body>
|
|
10
|
+
<div id="root"></div>
|
|
11
|
+
<script type="module" src="/src/main.tsx"></script>
|
|
12
|
+
</body>
|
|
13
|
+
</html>
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@seven-design-ui/play",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"private": true,
|
|
5
|
+
"description": "SevenDesign 组件开发调试环境",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"dev": "vite",
|
|
8
|
+
"build": "vite build",
|
|
9
|
+
"preview": "vite preview"
|
|
10
|
+
},
|
|
11
|
+
"dependencies": {
|
|
12
|
+
"@seven-design-ui/components": "workspace:*",
|
|
13
|
+
"@seven-design-ui/core": "workspace:*",
|
|
14
|
+
"@seven-design-ui/theme": "workspace:*",
|
|
15
|
+
"react": "19.2.3",
|
|
16
|
+
"react-dom": "19.2.3"
|
|
17
|
+
},
|
|
18
|
+
"devDependencies": {
|
|
19
|
+
"@types/react": "^19.0.0",
|
|
20
|
+
"@types/react-dom": "^19.0.0",
|
|
21
|
+
"@vitejs/plugin-react": "^4.2.1",
|
|
22
|
+
"typescript": "^5.3.3",
|
|
23
|
+
"vite": "^5.0.11"
|
|
24
|
+
}
|
|
25
|
+
}
|
package/play/src/App.tsx
ADDED
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { useState } from 'react'
|
|
4
|
+
import { Button, Input, Switch, Pagination } from '@seven-design-ui/components'
|
|
5
|
+
|
|
6
|
+
function CustomContentSwitch() {
|
|
7
|
+
const [switch1, setSwitch1] = useState(true)
|
|
8
|
+
const [switch2, setSwitch2] = useState(false)
|
|
9
|
+
const [switch3, setSwitch3] = useState(true)
|
|
10
|
+
const [switch4, setSwitch4] = useState(false)
|
|
11
|
+
|
|
12
|
+
return (
|
|
13
|
+
<div style={{ marginTop: '20px' }}>
|
|
14
|
+
<h3>自定义开关内容和背景色测试</h3>
|
|
15
|
+
|
|
16
|
+
<div style={{ display: 'flex', gap: '20px', alignItems: 'center', marginBottom: '20px' }}>
|
|
17
|
+
<div style={{ display: 'flex', flexDirection: 'column', alignItems: 'center', gap: '8px' }}>
|
|
18
|
+
<Switch
|
|
19
|
+
checkedNode="开"
|
|
20
|
+
unCheckedNode="关"
|
|
21
|
+
checked={switch1}
|
|
22
|
+
onChange={setSwitch1}
|
|
23
|
+
/>
|
|
24
|
+
<span style={{ fontSize: '12px', color: '#666' }}>文字内容</span>
|
|
25
|
+
</div>
|
|
26
|
+
|
|
27
|
+
<div style={{ display: 'flex', flexDirection: 'column', alignItems: 'center', gap: '8px' }}>
|
|
28
|
+
<Switch
|
|
29
|
+
checkedNode="1"
|
|
30
|
+
unCheckedNode="0"
|
|
31
|
+
checked={switch2}
|
|
32
|
+
onChange={setSwitch2}
|
|
33
|
+
/>
|
|
34
|
+
<span style={{ fontSize: '12px', color: '#666' }}>数字内容</span>
|
|
35
|
+
</div>
|
|
36
|
+
|
|
37
|
+
<div style={{ display: 'flex', flexDirection: 'column', alignItems: 'center', gap: '8px' }}>
|
|
38
|
+
<Switch
|
|
39
|
+
checkedNode="✓"
|
|
40
|
+
unCheckedNode="✗"
|
|
41
|
+
checked={switch3}
|
|
42
|
+
onChange={setSwitch3}
|
|
43
|
+
/>
|
|
44
|
+
<span style={{ fontSize: '12px', color: '#666' }}>符号内容</span>
|
|
45
|
+
</div>
|
|
46
|
+
|
|
47
|
+
<div style={{ display: 'flex', flexDirection: 'column', alignItems: 'center', gap: '8px' }}>
|
|
48
|
+
<Switch
|
|
49
|
+
checkedNode={<span style={{ color: 'green', fontWeight: 'bold' }}>开</span>}
|
|
50
|
+
unCheckedNode={<span style={{ color: 'red', fontWeight: 'bold' }}>关</span>}
|
|
51
|
+
defaultChecked={true}
|
|
52
|
+
/>
|
|
53
|
+
<span style={{ fontSize: '12px', color: '#666' }}>React元素内容</span>
|
|
54
|
+
</div>
|
|
55
|
+
</div>
|
|
56
|
+
|
|
57
|
+
<div style={{ display: 'flex', gap: '20px', alignItems: 'center', marginBottom: '20px' }}>
|
|
58
|
+
<div style={{ display: 'flex', flexDirection: 'column', alignItems: 'center', gap: '8px' }}>
|
|
59
|
+
<Switch
|
|
60
|
+
checkedColor="green"
|
|
61
|
+
unCheckedColor="red"
|
|
62
|
+
checked={switch4}
|
|
63
|
+
onChange={setSwitch4}
|
|
64
|
+
/>
|
|
65
|
+
<span style={{ fontSize: '12px', color: '#666' }}>自定义背景色</span>
|
|
66
|
+
</div>
|
|
67
|
+
</div>
|
|
68
|
+
|
|
69
|
+
<p style={{ fontSize: '12px', color: '#666' }}>
|
|
70
|
+
状态: 开关1={switch1 ? '开' : '关'}, 开关2={switch2 ? '1' : '0'}, 开关3={switch3 ? '✓' : '✗'}, 开关4={switch4 ? '绿' : '红'}
|
|
71
|
+
</p>
|
|
72
|
+
</div>
|
|
73
|
+
)
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function App() {
|
|
77
|
+
const [inputValue, setInputValue] = useState('')
|
|
78
|
+
const [switchChecked, setSwitchChecked] = useState(false)
|
|
79
|
+
const [loading, setLoading] = useState(false)
|
|
80
|
+
const [paginationPage, setPaginationPage] = useState(1)
|
|
81
|
+
const [paginationSize, setPaginationSize] = useState(10)
|
|
82
|
+
|
|
83
|
+
const handleClick = () => {
|
|
84
|
+
setLoading(true)
|
|
85
|
+
setTimeout(() => setLoading(false), 2000)
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const handlePaginationChange = (page: number, pageSize: number) => {
|
|
89
|
+
setPaginationPage(page)
|
|
90
|
+
setPaginationSize(pageSize)
|
|
91
|
+
console.log(`页码: ${page}, 每页容量: ${pageSize}`)
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
return (
|
|
95
|
+
<div className="app">
|
|
96
|
+
<header className="app-header">
|
|
97
|
+
<h1>SevenDesign 组件库调试环境</h1>
|
|
98
|
+
<p>本地开发和测试组件的 Playground</p>
|
|
99
|
+
</header>
|
|
100
|
+
|
|
101
|
+
<main className="app-main">
|
|
102
|
+
{/* Button 示例 */}
|
|
103
|
+
<section className="demo-section">
|
|
104
|
+
<h2>Button 按钮</h2>
|
|
105
|
+
<div className="demo-row">
|
|
106
|
+
<Button>默认按钮</Button>
|
|
107
|
+
<Button type="primary">主要按钮</Button>
|
|
108
|
+
<Button type="success">成功按钮</Button>
|
|
109
|
+
<Button type="warning">警告按钮</Button>
|
|
110
|
+
<Button type="danger">危险按钮</Button>
|
|
111
|
+
<Button type="info">信息按钮</Button>
|
|
112
|
+
</div>
|
|
113
|
+
<div className="demo-row">
|
|
114
|
+
<Button plain>朴素按钮</Button>
|
|
115
|
+
<Button type="primary" plain>
|
|
116
|
+
主要按钮
|
|
117
|
+
</Button>
|
|
118
|
+
<Button type="success" plain>
|
|
119
|
+
成功按钮
|
|
120
|
+
</Button>
|
|
121
|
+
</div>
|
|
122
|
+
<div className="demo-row">
|
|
123
|
+
<Button round>圆角按钮</Button>
|
|
124
|
+
<Button type="primary" round>
|
|
125
|
+
主要按钮
|
|
126
|
+
</Button>
|
|
127
|
+
</div>
|
|
128
|
+
<div className="demo-row">
|
|
129
|
+
<Button size="large">大型按钮</Button>
|
|
130
|
+
<Button>默认按钮</Button>
|
|
131
|
+
<Button size="small">小型按钮</Button>
|
|
132
|
+
</div>
|
|
133
|
+
<div className="demo-row">
|
|
134
|
+
<Button loading={loading} type="primary" onClick={handleClick}>
|
|
135
|
+
{loading ? '加载中...' : '点击加载'}
|
|
136
|
+
</Button>
|
|
137
|
+
<Button disabled>禁用按钮</Button>
|
|
138
|
+
</div>
|
|
139
|
+
</section>
|
|
140
|
+
|
|
141
|
+
{/* Input 示例 */}
|
|
142
|
+
<section className="demo-section">
|
|
143
|
+
<h2>Input 输入框</h2>
|
|
144
|
+
<div className="demo-column">
|
|
145
|
+
<Input placeholder="请输入内容" value={inputValue} onInput={setInputValue} />
|
|
146
|
+
<Input placeholder="可清空的输入框" clearable />
|
|
147
|
+
<Input placeholder="密码输入框" type="password" showPassword />
|
|
148
|
+
<Input placeholder="禁用状态" disabled />
|
|
149
|
+
<div className="demo-row">
|
|
150
|
+
<Input placeholder="大尺寸" size="large" />
|
|
151
|
+
<Input placeholder="默认尺寸" />
|
|
152
|
+
<Input placeholder="小尺寸" size="small" />
|
|
153
|
+
</div>
|
|
154
|
+
</div>
|
|
155
|
+
</section>
|
|
156
|
+
|
|
157
|
+
{/* Switch 示例 */}
|
|
158
|
+
<section className="demo-section">
|
|
159
|
+
<h2>Switch 开关</h2>
|
|
160
|
+
<div className="demo-row">
|
|
161
|
+
<Switch checked={switchChecked} onChange={setSwitchChecked} />
|
|
162
|
+
<Switch defaultChecked />
|
|
163
|
+
<Switch disabled />
|
|
164
|
+
<Switch loading />
|
|
165
|
+
</div>
|
|
166
|
+
<p className="demo-tip">当前状态: {switchChecked ? '开启' : '关闭'}</p>
|
|
167
|
+
|
|
168
|
+
{/* 自定义内容测试 */}
|
|
169
|
+
<CustomContentSwitch />
|
|
170
|
+
</section>
|
|
171
|
+
|
|
172
|
+
{/* Pagination 示例 */}
|
|
173
|
+
<section className="demo-section">
|
|
174
|
+
<h2>Pagination 分页器</h2>
|
|
175
|
+
|
|
176
|
+
{/* 基础使用 */}
|
|
177
|
+
<div className="demo-column">
|
|
178
|
+
<h3>基础使用</h3>
|
|
179
|
+
<Pagination
|
|
180
|
+
total={100}
|
|
181
|
+
defaultCurrent={1}
|
|
182
|
+
defaultPageSize={10}
|
|
183
|
+
onChange={handlePaginationChange}
|
|
184
|
+
/>
|
|
185
|
+
<p className="demo-tip">当前页码: {paginationPage}, 每页容量: {paginationSize}</p>
|
|
186
|
+
</div>
|
|
187
|
+
|
|
188
|
+
{/* 不同大小 */}
|
|
189
|
+
<div className="demo-column">
|
|
190
|
+
<h3>不同大小</h3>
|
|
191
|
+
<div className="demo-row">
|
|
192
|
+
<div style={{ display: 'flex', flexDirection: 'column', alignItems: 'center', gap: '8px' }}>
|
|
193
|
+
<Pagination total={50} size="s" />
|
|
194
|
+
<span style={{ fontSize: '12px', color: '#666' }}>小尺寸 (s)</span>
|
|
195
|
+
</div>
|
|
196
|
+
<div style={{ display: 'flex', flexDirection: 'column', alignItems: 'center', gap: '8px' }}>
|
|
197
|
+
<Pagination total={50} size="m" />
|
|
198
|
+
<span style={{ fontSize: '12px', color: '#666' }}>中等尺寸 (m)</span>
|
|
199
|
+
</div>
|
|
200
|
+
</div>
|
|
201
|
+
</div>
|
|
202
|
+
|
|
203
|
+
{/* 自定义页码按钮数 */}
|
|
204
|
+
<div className="demo-column">
|
|
205
|
+
<h3>自定义最大页码按钮数</h3>
|
|
206
|
+
<Pagination total={200} pagerCount={5} defaultCurrent={10} />
|
|
207
|
+
<p className="demo-tip">最大显示5个页码按钮</p>
|
|
208
|
+
</div>
|
|
209
|
+
|
|
210
|
+
{/* 自定义每页容量选项 */}
|
|
211
|
+
<div className="demo-column">
|
|
212
|
+
<h3>自定义每页容量选项</h3>
|
|
213
|
+
<Pagination
|
|
214
|
+
total={500}
|
|
215
|
+
pageSizeOptions={[5, 10, 20, 50]}
|
|
216
|
+
defaultPageSize={5}
|
|
217
|
+
/>
|
|
218
|
+
<p className="demo-tip">每页容量选项: 5, 10, 20, 50</p>
|
|
219
|
+
</div>
|
|
220
|
+
|
|
221
|
+
{/* 跳转功能 */}
|
|
222
|
+
<div className="demo-column">
|
|
223
|
+
<h3>跳转功能</h3>
|
|
224
|
+
<Pagination
|
|
225
|
+
total={100}
|
|
226
|
+
showQuickJumper={true}
|
|
227
|
+
defaultCurrent={5}
|
|
228
|
+
/>
|
|
229
|
+
<p className="demo-tip">可以直接跳转到指定页码</p>
|
|
230
|
+
</div>
|
|
231
|
+
</section>
|
|
232
|
+
</main>
|
|
233
|
+
</div>
|
|
234
|
+
)
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
export default App
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
* {
|
|
2
|
+
margin: 0;
|
|
3
|
+
padding: 0;
|
|
4
|
+
box-sizing: border-box;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
body {
|
|
8
|
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu',
|
|
9
|
+
'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
|
|
10
|
+
-webkit-font-smoothing: antialiased;
|
|
11
|
+
-moz-osx-font-smoothing: grayscale;
|
|
12
|
+
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
|
13
|
+
min-height: 100vh;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.app {
|
|
17
|
+
max-width: 1200px;
|
|
18
|
+
margin: 0 auto;
|
|
19
|
+
padding: 40px 20px;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.app-header {
|
|
23
|
+
text-align: center;
|
|
24
|
+
color: white;
|
|
25
|
+
margin-bottom: 60px;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.app-header h1 {
|
|
29
|
+
font-size: 48px;
|
|
30
|
+
font-weight: 700;
|
|
31
|
+
margin-bottom: 12px;
|
|
32
|
+
text-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.app-header p {
|
|
36
|
+
font-size: 18px;
|
|
37
|
+
opacity: 0.9;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.app-main {
|
|
41
|
+
display: flex;
|
|
42
|
+
flex-direction: column;
|
|
43
|
+
gap: 40px;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.demo-section {
|
|
47
|
+
background: white;
|
|
48
|
+
border-radius: 12px;
|
|
49
|
+
padding: 32px;
|
|
50
|
+
box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.demo-section h2 {
|
|
54
|
+
font-size: 24px;
|
|
55
|
+
color: #303133;
|
|
56
|
+
margin-bottom: 24px;
|
|
57
|
+
padding-bottom: 12px;
|
|
58
|
+
border-bottom: 2px solid #f0f0f0;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.demo-row {
|
|
62
|
+
display: flex;
|
|
63
|
+
align-items: center;
|
|
64
|
+
gap: 12px;
|
|
65
|
+
flex-wrap: wrap;
|
|
66
|
+
margin-bottom: 16px;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
.demo-column {
|
|
70
|
+
display: flex;
|
|
71
|
+
flex-direction: column;
|
|
72
|
+
gap: 16px;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
.demo-tip {
|
|
76
|
+
margin-top: 12px;
|
|
77
|
+
padding: 12px;
|
|
78
|
+
background: #f0f9ff;
|
|
79
|
+
border-left: 4px solid #409eff;
|
|
80
|
+
color: #606266;
|
|
81
|
+
font-size: 14px;
|
|
82
|
+
border-radius: 4px;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
@media (max-width: 768px) {
|
|
86
|
+
.app-header h1 {
|
|
87
|
+
font-size: 32px;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
.demo-section {
|
|
91
|
+
padding: 20px;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { StrictMode } from 'react'
|
|
2
|
+
import { createRoot } from 'react-dom/client'
|
|
3
|
+
import App from './App'
|
|
4
|
+
import './index.css'
|
|
5
|
+
import '../../packages/components/dist/style.css'
|
|
6
|
+
|
|
7
|
+
const root = document.getElementById('root')
|
|
8
|
+
if (root) {
|
|
9
|
+
createRoot(root).render(
|
|
10
|
+
<StrictMode>
|
|
11
|
+
<App />
|
|
12
|
+
</StrictMode>
|
|
13
|
+
)
|
|
14
|
+
}
|