@yh-ui/theme 0.1.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.
@@ -0,0 +1,238 @@
1
+ export const colorTokens = {
2
+ primary: {
3
+ DEFAULT: "#409eff",
4
+ light: {
5
+ 1: "#53a8ff",
6
+ 2: "#66b1ff",
7
+ 3: "#79bbff",
8
+ 4: "#8cc5ff",
9
+ 5: "#a0cfff",
10
+ 6: "#b3d8ff",
11
+ 7: "#c6e2ff",
12
+ 8: "#d9ecff",
13
+ 9: "#ecf5ff"
14
+ },
15
+ dark: {
16
+ 2: "#337ecc"
17
+ }
18
+ },
19
+ success: {
20
+ DEFAULT: "#67c23a",
21
+ light: {
22
+ 3: "#95d475",
23
+ 5: "#b3e19d",
24
+ 7: "#d1edc4",
25
+ 9: "#f0f9eb"
26
+ },
27
+ dark: {
28
+ 2: "#529b2e"
29
+ }
30
+ },
31
+ warning: {
32
+ DEFAULT: "#e6a23c",
33
+ light: {
34
+ 3: "#eebe77",
35
+ 5: "#f3d19e",
36
+ 7: "#f8e3c5",
37
+ 9: "#fdf6ec"
38
+ },
39
+ dark: {
40
+ 2: "#b88230"
41
+ }
42
+ },
43
+ danger: {
44
+ DEFAULT: "#f56c6c",
45
+ light: {
46
+ 3: "#f89898",
47
+ 5: "#fab6b6",
48
+ 7: "#fcd3d3",
49
+ 9: "#fef0f0"
50
+ },
51
+ dark: {
52
+ 2: "#c45656"
53
+ }
54
+ },
55
+ info: {
56
+ DEFAULT: "#909399",
57
+ light: {
58
+ 3: "#b1b3b8",
59
+ 5: "#c8c9cc",
60
+ 7: "#dedfe0",
61
+ 9: "#f4f4f5"
62
+ },
63
+ dark: {
64
+ 2: "#73767a"
65
+ }
66
+ }
67
+ };
68
+ export const textColorTokens = {
69
+ primary: "#303133",
70
+ regular: "#606266",
71
+ secondary: "#909399",
72
+ placeholder: "#a8abb2",
73
+ disabled: "#c0c4cc"
74
+ };
75
+ export const borderColorTokens = {
76
+ DEFAULT: "#dcdfe6",
77
+ light: "#e4e7ed",
78
+ lighter: "#ebeef5",
79
+ extraLight: "#f2f6fc",
80
+ dark: "#d4d7de",
81
+ darker: "#cdd0d6"
82
+ };
83
+ export const fillColorTokens = {
84
+ DEFAULT: "#f0f2f5",
85
+ light: "#f5f7fa",
86
+ lighter: "#fafafa",
87
+ extraLight: "#fafcff",
88
+ dark: "#ebedf0",
89
+ darker: "#e6e8eb",
90
+ blank: "#ffffff"
91
+ };
92
+ export const bgColorTokens = {
93
+ DEFAULT: "#ffffff",
94
+ page: "#f2f3f5",
95
+ overlay: "#ffffff"
96
+ };
97
+ export const spacingTokens = {
98
+ none: "0",
99
+ xs: "4px",
100
+ sm: "8px",
101
+ md: "16px",
102
+ lg: "24px",
103
+ xl: "32px",
104
+ xxl: "48px"
105
+ };
106
+ export const radiusTokens = {
107
+ none: "0",
108
+ sm: "2px",
109
+ base: "4px",
110
+ md: "8px",
111
+ lg: "12px",
112
+ xl: "16px",
113
+ round: "20px",
114
+ circle: "50%"
115
+ };
116
+ export const fontSizeTokens = {
117
+ xs: "12px",
118
+ sm: "13px",
119
+ base: "14px",
120
+ md: "16px",
121
+ lg: "18px",
122
+ xl: "20px",
123
+ xxl: "24px"
124
+ };
125
+ export const lineHeightTokens = {
126
+ none: "1",
127
+ tight: "1.25",
128
+ snug: "1.375",
129
+ normal: "1.5",
130
+ relaxed: "1.625",
131
+ loose: "2"
132
+ };
133
+ export const fontWeightTokens = {
134
+ light: "300",
135
+ normal: "400",
136
+ medium: "500",
137
+ semibold: "600",
138
+ bold: "700"
139
+ };
140
+ export const shadowTokens = {
141
+ sm: "0 1px 2px 0 rgba(0, 0, 0, 0.05)",
142
+ base: "0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px -1px rgba(0, 0, 0, 0.1)",
143
+ md: "0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1)",
144
+ lg: "0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1)",
145
+ xl: "0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1)"
146
+ };
147
+ export const durationTokens = {
148
+ fast: "150ms",
149
+ base: "200ms",
150
+ slow: "300ms"
151
+ };
152
+ export const timingTokens = {
153
+ ease: "ease",
154
+ easeIn: "cubic-bezier(0.4, 0, 1, 1)",
155
+ easeOut: "cubic-bezier(0, 0, 0.2, 1)",
156
+ easeInOut: "cubic-bezier(0.4, 0, 0.2, 1)",
157
+ linear: "linear"
158
+ };
159
+ export const zIndexTokens = {
160
+ normal: "1",
161
+ top: "1000",
162
+ popper: "2000",
163
+ overlay: "2001",
164
+ modal: "2002",
165
+ popover: "2003",
166
+ tooltip: "2004",
167
+ loading: "2005"
168
+ };
169
+ export const breakpointTokens = {
170
+ xs: "0",
171
+ sm: "576px",
172
+ md: "768px",
173
+ lg: "992px",
174
+ xl: "1200px",
175
+ xxl: "1400px"
176
+ };
177
+ export const fontFamilyTokens = {
178
+ base: "-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans', sans-serif",
179
+ monospace: "'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, Courier, monospace",
180
+ serif: "Georgia, Cambria, 'Times New Roman', Times, serif"
181
+ };
182
+ export const accessibilityTokens = {
183
+ focusRingColor: "#409eff",
184
+ focusRingWidth: "2px",
185
+ focusRingOffset: "2px",
186
+ focusRingOpacity: "0.2"
187
+ };
188
+ export const maskTokens = {
189
+ DEFAULT: "rgba(0, 0, 0, 0.5)",
190
+ light: "rgba(0, 0, 0, 0.3)",
191
+ extraLight: "rgba(0, 0, 0, 0.1)"
192
+ };
193
+ export const scrollbarTokens = {
194
+ width: "6px",
195
+ thumbColor: "#c0c4cc",
196
+ thumbHoverColor: "#909399",
197
+ trackColor: "transparent",
198
+ thumbRadius: "3px"
199
+ };
200
+ export const componentSizeTokens = {
201
+ large: {
202
+ height: "40px",
203
+ fontSize: "14px",
204
+ paddingX: "20px"
205
+ },
206
+ default: {
207
+ height: "32px",
208
+ fontSize: "14px",
209
+ paddingX: "16px"
210
+ },
211
+ small: {
212
+ height: "24px",
213
+ fontSize: "12px",
214
+ paddingX: "12px"
215
+ }
216
+ };
217
+ export const designTokens = {
218
+ colors: colorTokens,
219
+ textColors: textColorTokens,
220
+ borderColors: borderColorTokens,
221
+ fillColors: fillColorTokens,
222
+ bgColors: bgColorTokens,
223
+ spacing: spacingTokens,
224
+ radius: radiusTokens,
225
+ fontSize: fontSizeTokens,
226
+ lineHeight: lineHeightTokens,
227
+ fontWeight: fontWeightTokens,
228
+ fontFamily: fontFamilyTokens,
229
+ shadow: shadowTokens,
230
+ duration: durationTokens,
231
+ timing: timingTokens,
232
+ zIndex: zIndexTokens,
233
+ componentSize: componentSizeTokens,
234
+ breakpoints: breakpointTokens,
235
+ accessibility: accessibilityTokens,
236
+ mask: maskTokens,
237
+ scrollbar: scrollbarTokens
238
+ };
package/package.json ADDED
@@ -0,0 +1,52 @@
1
+ {
2
+ "name": "@yh-ui/theme",
3
+ "version": "0.1.0",
4
+ "description": "YH-UI theme and design tokens",
5
+ "type": "module",
6
+ "main": "./dist/index.cjs",
7
+ "module": "./dist/index.mjs",
8
+ "types": "./dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/index.d.ts",
12
+ "import": "./dist/index.mjs",
13
+ "require": "./dist/index.cjs"
14
+ },
15
+ "./styles/*": "./src/styles/*",
16
+ "./*": {
17
+ "types": "./dist/*.d.ts",
18
+ "import": "./dist/*.mjs",
19
+ "require": "./dist/*.cjs"
20
+ }
21
+ },
22
+ "files": [
23
+ "dist",
24
+ "src/styles"
25
+ ],
26
+ "publishConfig": {
27
+ "access": "public"
28
+ },
29
+ "repository": {
30
+ "type": "git",
31
+ "url": "https://github.com/1079161148/yh-ui.git",
32
+ "directory": "packages/theme"
33
+ },
34
+ "keywords": [
35
+ "yh-ui",
36
+ "theme",
37
+ "design-tokens"
38
+ ],
39
+ "homepage": "https://yh-ui.dev",
40
+ "author": "YH-UI Team",
41
+ "peerDependencies": {
42
+ "vue": "^3.5.27"
43
+ },
44
+ "license": "MIT",
45
+ "devDependencies": {
46
+ "viewerjs": "^1.11.7"
47
+ },
48
+ "scripts": {
49
+ "build": "unbuild",
50
+ "dev": "unbuild --stub"
51
+ }
52
+ }
@@ -0,0 +1,9 @@
1
+ /**
2
+ * YH-UI 组件全局样式
3
+ * 注意:组件样式已由各 Vue SFC <style> 块自行携带
4
+ * 此文件仅保留基础变量和 mixin 的引用,供外部按需导入
5
+ */
6
+
7
+ @use 'variables' as *;
8
+ @use 'mixins/mixins' as *;
9
+ @use 'reset' as *;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * YH-UI Base Styles
3
+ * 主入口文件 —— 仅包含基础主题层
4
+ * 组件样式由各组件的 Vue SFC <style> 块自行携带
5
+ */
6
+
7
+ @use 'variables';
8
+ @use 'reset';
@@ -0,0 +1,96 @@
1
+ @use 'sass:string';
2
+ @use 'sass:list';
3
+ @use 'sass:meta';
4
+ @use '../variables' as *;
5
+
6
+ // BEM
7
+ $namespace: 'yh' !default;
8
+ $state-prefix: 'is-' !default;
9
+ $modifier-separator: '--' !default;
10
+ $element-separator: '__' !default;
11
+
12
+ // 声明全局变量
13
+ $B: null;
14
+ $E: null;
15
+
16
+ @function containsSpecial($selector) {
17
+ $selector: meta.inspect($selector);
18
+ // 如果选择器包含修饰符、状态前缀或冒号(伪类)
19
+ @if string.index($selector, $modifier-separator) or
20
+ string.index($selector, '.' + $state-prefix) or
21
+ string.index($selector, ':')
22
+ {
23
+ @return true;
24
+ }
25
+ @return false;
26
+ }
27
+
28
+ @mixin b($block) {
29
+ $B: $namespace + '-' + $block !global;
30
+ .#{$B} {
31
+ @content;
32
+ }
33
+ }
34
+
35
+ @mixin e($element) {
36
+ $E: $element !global;
37
+ $selector: &;
38
+ $currentSelector: '';
39
+
40
+ @each $unit in $element {
41
+ $currentSelector: #{$currentSelector + '.' + $B + $element-separator + $unit};
42
+ @if $unit != list.nth($element, list.length($element)) {
43
+ $currentSelector: #{$currentSelector + ','};
44
+ }
45
+ }
46
+
47
+ @if containsSpecial($selector) {
48
+ @at-root {
49
+ #{$selector} {
50
+ #{$currentSelector} {
51
+ @content;
52
+ }
53
+ }
54
+ }
55
+ } @else {
56
+ @at-root {
57
+ #{$currentSelector} {
58
+ @content;
59
+ }
60
+ }
61
+ }
62
+ }
63
+
64
+ @mixin m($modifier) {
65
+ $selector: &;
66
+ $currentSelector: '';
67
+
68
+ @each $unit in $modifier {
69
+ $currentSelector: #{$currentSelector + $selector + $modifier-separator + $unit};
70
+ @if $unit != list.nth($modifier, list.length($modifier)) {
71
+ $currentSelector: #{$currentSelector + ','};
72
+ }
73
+ }
74
+
75
+ @at-root {
76
+ #{$currentSelector} {
77
+ @content;
78
+ }
79
+ }
80
+ }
81
+
82
+ @mixin when($state) {
83
+ @at-root {
84
+ &.#{$state-prefix + $state} {
85
+ @content;
86
+ }
87
+ }
88
+ }
89
+
90
+ @mixin is($state, $condition: true) {
91
+ @if $condition {
92
+ &.#{$state-prefix + $state} {
93
+ @content;
94
+ }
95
+ }
96
+ }
@@ -0,0 +1,131 @@
1
+ /**
2
+ * YH-UI Reset Styles
3
+ * 基础样式重置
4
+ */
5
+
6
+ *,
7
+ *::before,
8
+ *::after {
9
+ box-sizing: border-box;
10
+ }
11
+
12
+ html,
13
+ body {
14
+ /* 仅在变量未定义时应用默认值,防止干扰宿主框架 */
15
+ margin: 0;
16
+ padding: 0;
17
+ }
18
+
19
+ html {
20
+ font-family: var(--yh-font-family);
21
+ font-size: var(--yh-font-size-base);
22
+ line-height: var(--yh-line-height-normal);
23
+ color: var(--yh-text-color-primary);
24
+ /* 移除强制背景色,允许 VitePress 暗黑模式控制 */
25
+ -webkit-font-smoothing: antialiased;
26
+ -moz-osx-font-smoothing: grayscale;
27
+ text-rendering: optimizeLegibility;
28
+ }
29
+
30
+ a {
31
+ color: var(--yh-color-primary);
32
+ text-decoration: none;
33
+ cursor: pointer;
34
+
35
+ &:hover {
36
+ color: var(--yh-color-primary-light-3);
37
+ }
38
+
39
+ &:active {
40
+ color: var(--yh-color-primary-dark-2);
41
+ }
42
+ }
43
+
44
+ button {
45
+ font-family: inherit;
46
+ font-size: inherit;
47
+ line-height: inherit;
48
+ color: inherit;
49
+ background: transparent;
50
+ border: none;
51
+ cursor: pointer;
52
+
53
+ &:focus {
54
+ outline: none;
55
+ }
56
+
57
+ &:disabled {
58
+ cursor: not-allowed;
59
+ }
60
+ }
61
+
62
+ input,
63
+ textarea,
64
+ select {
65
+ font-family: inherit;
66
+ font-size: inherit;
67
+ line-height: inherit;
68
+ color: inherit;
69
+ background: transparent;
70
+ border: none;
71
+
72
+ &:focus {
73
+ outline: none;
74
+ }
75
+
76
+ &::placeholder {
77
+ color: var(--yh-text-color-placeholder);
78
+ }
79
+
80
+ &:disabled {
81
+ cursor: not-allowed;
82
+ }
83
+ }
84
+
85
+ ul,
86
+ ol {
87
+ list-style: none;
88
+ }
89
+
90
+ img,
91
+ svg {
92
+ display: block;
93
+ max-width: 100%;
94
+ height: auto;
95
+ }
96
+
97
+ table {
98
+ border-collapse: collapse;
99
+ border-spacing: 0;
100
+ }
101
+
102
+ hr {
103
+ border: none;
104
+ border-top: 1px solid var(--yh-border-color);
105
+ }
106
+
107
+ /* 滚动条样式 */
108
+ ::-webkit-scrollbar {
109
+ width: 6px;
110
+ height: 6px;
111
+ }
112
+
113
+ ::-webkit-scrollbar-track {
114
+ background: var(--yh-fill-color-light);
115
+ border-radius: 3px;
116
+ }
117
+
118
+ ::-webkit-scrollbar-thumb {
119
+ background: var(--yh-text-color-disabled);
120
+ border-radius: 3px;
121
+
122
+ &:hover {
123
+ background: var(--yh-text-color-secondary);
124
+ }
125
+ }
126
+
127
+ /* Firefox 滚动条 */
128
+ * {
129
+ scrollbar-width: thin;
130
+ scrollbar-color: var(--yh-text-color-disabled) var(--yh-fill-color-light);
131
+ }