qm-law-ui 0.0.1 → 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/README.md +2 -0
- package/{src/styles/variables.css → dist/theme.css} +83 -0
- package/package.json +7 -4
- package/src/components/law-button/index.vue +0 -106
- package/src/components/law-button/types.ts +0 -22
- package/src/components/law-dialog/index.vue +0 -100
- package/src/components/law-dialog/types.ts +0 -12
- package/src/env.d.ts +0 -12
- package/src/hooks/use-law-theme.ts +0 -66
- package/src/index.ts +0 -35
- package/src/styles/theme.css +0 -84
- package/src/utils/index.ts +0 -32
package/README.md
CHANGED
|
@@ -33,6 +33,8 @@ import "qm-law-ui/style.css"; // ③ 组件聚合样式(构建产物)
|
|
|
33
33
|
|
|
34
34
|
> **顺序不可调换**:`element-plus.css` → `qm-law-ui/theme.css` → `qm-law-ui/style.css`
|
|
35
35
|
|
|
36
|
+
**无需配置 Vite alias**。自 `0.0.2` 起,`dist/theme.css` 会随包发布,直接 `import 'qm-law-ui/theme.css'` 即可。若你曾用 `0.0.1` 并配置了指向 `src/styles/theme.css` 的 alias,请删除该 alias 并升级到 `0.0.2+`。
|
|
37
|
+
|
|
36
38
|
## 插件注册
|
|
37
39
|
|
|
38
40
|
```ts
|
|
@@ -190,3 +190,86 @@
|
|
|
190
190
|
--law-shadow-xl: 0 16px 32px rgba(0, 0, 0, 0.56);
|
|
191
191
|
--law-box-shadow: var(--law-shadow-md);
|
|
192
192
|
}
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* LawUI Theme Mapping Layer
|
|
196
|
+
* Maps Law0S Design Tokens (--law-*) to Element Plus (--el-*)
|
|
197
|
+
*/
|
|
198
|
+
:root,
|
|
199
|
+
:root.dark,
|
|
200
|
+
html.dark,
|
|
201
|
+
[data-theme="dark"] {
|
|
202
|
+
/* Brand & functional colors */
|
|
203
|
+
--el-color-primary: var(--law-color-primary);
|
|
204
|
+
--el-color-success: var(--law-color-success);
|
|
205
|
+
--el-color-warning: var(--law-color-warning);
|
|
206
|
+
--el-color-danger: var(--law-color-danger);
|
|
207
|
+
--el-color-error: var(--law-color-danger);
|
|
208
|
+
--el-color-info: var(--law-color-info);
|
|
209
|
+
|
|
210
|
+
--el-color-primary-light-3: var(--law-primary-300);
|
|
211
|
+
--el-color-primary-light-5: var(--law-primary-200);
|
|
212
|
+
--el-color-primary-light-7: var(--law-primary-100);
|
|
213
|
+
--el-color-primary-light-8: var(--law-primary-50);
|
|
214
|
+
--el-color-primary-light-9: var(--law-primary-50);
|
|
215
|
+
--el-color-primary-dark-2: var(--law-primary-600);
|
|
216
|
+
|
|
217
|
+
/* Typography */
|
|
218
|
+
--el-font-family: var(--law-font-family-zh);
|
|
219
|
+
--el-font-size-extra-large: var(--law-font-size-h1);
|
|
220
|
+
--el-font-size-large: var(--law-font-size-h3);
|
|
221
|
+
--el-font-size-medium: var(--law-font-size-h4);
|
|
222
|
+
--el-font-size-base: var(--law-font-size-body);
|
|
223
|
+
--el-font-size-small: var(--law-font-size-caption);
|
|
224
|
+
--el-font-size-extra-small: var(--law-font-size-mini);
|
|
225
|
+
--el-font-weight-primary: var(--law-font-weight-medium);
|
|
226
|
+
--el-font-line-height-primary: var(--law-line-height-body);
|
|
227
|
+
|
|
228
|
+
/* Text colors */
|
|
229
|
+
--el-text-color-primary: var(--law-text-primary);
|
|
230
|
+
--el-text-color-regular: var(--law-text-regular);
|
|
231
|
+
--el-text-color-secondary: var(--law-text-secondary);
|
|
232
|
+
--el-text-color-placeholder: var(--law-text-placeholder);
|
|
233
|
+
--el-text-color-disabled: var(--law-text-color-disabled);
|
|
234
|
+
|
|
235
|
+
/* Border */
|
|
236
|
+
--el-border-width: var(--law-border-width);
|
|
237
|
+
--el-border-color: var(--law-border-color);
|
|
238
|
+
--el-border-color-light: var(--law-border-color-light);
|
|
239
|
+
--el-border-color-lighter: var(--law-border-color-lighter);
|
|
240
|
+
--el-border-color-hover: var(--law-border-color);
|
|
241
|
+
|
|
242
|
+
/* Background & fill */
|
|
243
|
+
--el-bg-color: var(--law-bg-white);
|
|
244
|
+
--el-bg-color-page: var(--law-bg-page);
|
|
245
|
+
--el-bg-color-overlay: var(--law-bg-white);
|
|
246
|
+
--el-fill-color: var(--law-fill-color);
|
|
247
|
+
--el-fill-color-light: var(--law-fill-color-light);
|
|
248
|
+
--el-fill-color-lighter: var(--law-border-color-lighter);
|
|
249
|
+
--el-fill-color-blank: var(--law-fill-color-blank);
|
|
250
|
+
--el-disabled-bg-color: var(--law-bg-disabled);
|
|
251
|
+
--el-disabled-text-color: var(--law-text-placeholder);
|
|
252
|
+
--el-disabled-border-color: var(--law-border-color-light);
|
|
253
|
+
|
|
254
|
+
/* Radius */
|
|
255
|
+
--el-border-radius-base: var(--law-radius-sm);
|
|
256
|
+
--el-border-radius-small: var(--law-radius-sm);
|
|
257
|
+
--el-border-radius-round: var(--law-radius-lg);
|
|
258
|
+
|
|
259
|
+
/* Shadow */
|
|
260
|
+
--el-box-shadow: var(--law-box-shadow);
|
|
261
|
+
--el-box-shadow-light: var(--law-shadow-sm);
|
|
262
|
+
--el-box-shadow-lighter: var(--law-shadow-sm);
|
|
263
|
+
--el-box-shadow-dark: var(--law-shadow-lg);
|
|
264
|
+
|
|
265
|
+
/* Component size (align with Law button tokens) */
|
|
266
|
+
--el-component-size-large: var(--law-btn-size-lg);
|
|
267
|
+
--el-component-size: var(--law-btn-size-md);
|
|
268
|
+
--el-component-size-small: var(--law-btn-size-sm);
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
:root.dark,
|
|
272
|
+
html.dark,
|
|
273
|
+
[data-theme="dark"] {
|
|
274
|
+
color-scheme: dark;
|
|
275
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "qm-law-ui",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.2",
|
|
4
4
|
"description": "Law0S Design System components built on Vue 3 and Element Plus",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.umd.cjs",
|
|
@@ -15,14 +15,17 @@
|
|
|
15
15
|
"./theme.css": "./dist/theme.css",
|
|
16
16
|
"./style.css": "./dist/style.css"
|
|
17
17
|
},
|
|
18
|
+
"sideEffects": [
|
|
19
|
+
"**/*.css",
|
|
20
|
+
"dist/**/*.css"
|
|
21
|
+
],
|
|
18
22
|
"files": [
|
|
19
|
-
"dist"
|
|
20
|
-
"src"
|
|
23
|
+
"dist"
|
|
21
24
|
],
|
|
22
25
|
"scripts": {
|
|
23
26
|
"dev": "vite --config examples/vite.config.ts",
|
|
24
27
|
"preview": "vite preview --config examples/vite.config.ts",
|
|
25
|
-
"build": "vue-tsc --noEmit && vite build",
|
|
28
|
+
"build": "vue-tsc --noEmit && vite build && node -e \"require('node:fs').accessSync('dist/theme.css')\"",
|
|
26
29
|
"prepublishOnly": "pnpm run build"
|
|
27
30
|
},
|
|
28
31
|
"keywords": [
|
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<el-button
|
|
3
|
-
v-bind="mergedProps"
|
|
4
|
-
:style="computedStyle"
|
|
5
|
-
class="law-button"
|
|
6
|
-
@click="onClick"
|
|
7
|
-
>
|
|
8
|
-
<slot />
|
|
9
|
-
<template v-if="$slots.loading" #loading>
|
|
10
|
-
<slot name="loading" />
|
|
11
|
-
</template>
|
|
12
|
-
<template v-if="$slots.icon" #icon>
|
|
13
|
-
<slot name="icon" />
|
|
14
|
-
</template>
|
|
15
|
-
</el-button>
|
|
16
|
-
</template>
|
|
17
|
-
|
|
18
|
-
<script setup lang="ts">
|
|
19
|
-
import { ElButton } from 'element-plus'
|
|
20
|
-
import { computed, useAttrs } from 'vue'
|
|
21
|
-
import type { LawButtonProps, LawButtonSize } from './types'
|
|
22
|
-
|
|
23
|
-
defineOptions({
|
|
24
|
-
name: 'LawButton',
|
|
25
|
-
inheritAttrs: false,
|
|
26
|
-
})
|
|
27
|
-
|
|
28
|
-
const props = withDefaults(defineProps<LawButtonProps>(), {
|
|
29
|
-
lawSize: 'md',
|
|
30
|
-
})
|
|
31
|
-
|
|
32
|
-
const emit = defineEmits<{
|
|
33
|
-
click: [evt: MouseEvent]
|
|
34
|
-
}>()
|
|
35
|
-
|
|
36
|
-
const attrs = useAttrs()
|
|
37
|
-
|
|
38
|
-
const elSizeMap: Record<LawButtonSize, 'large' | 'default' | 'small'> = {
|
|
39
|
-
lg: 'large',
|
|
40
|
-
md: 'default',
|
|
41
|
-
sm: 'small',
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
const mergedProps = computed(() => {
|
|
45
|
-
const { lawSize, size, ...rest } = props
|
|
46
|
-
return {
|
|
47
|
-
...attrs,
|
|
48
|
-
...rest,
|
|
49
|
-
size: size ?? elSizeMap[lawSize],
|
|
50
|
-
}
|
|
51
|
-
})
|
|
52
|
-
|
|
53
|
-
const computedStyle = computed(() => {
|
|
54
|
-
const heightMap: Record<LawButtonSize, string> = {
|
|
55
|
-
lg: 'var(--law-btn-size-lg)',
|
|
56
|
-
md: 'var(--law-btn-size-md)',
|
|
57
|
-
sm: 'var(--law-btn-size-sm)',
|
|
58
|
-
}
|
|
59
|
-
return {
|
|
60
|
-
minHeight: heightMap[props.lawSize],
|
|
61
|
-
}
|
|
62
|
-
})
|
|
63
|
-
|
|
64
|
-
function onClick(evt: MouseEvent) {
|
|
65
|
-
emit('click', evt)
|
|
66
|
-
}
|
|
67
|
-
</script>
|
|
68
|
-
|
|
69
|
-
<style scoped>
|
|
70
|
-
.law-button {
|
|
71
|
-
font-family: var(--law-font-family-zh);
|
|
72
|
-
border-radius: var(--law-radius-sm);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
.law-button.el-button--default:not(.is-disabled):hover {
|
|
76
|
-
background-color: var(--law-btn-default-hover-bg);
|
|
77
|
-
color: var(--law-btn-default-hover-color);
|
|
78
|
-
border-color: var(--law-primary);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
.law-button.el-button--primary:not(.is-disabled):hover {
|
|
82
|
-
background-color: var(--law-btn-primary-hover-bg);
|
|
83
|
-
color: var(--law-btn-primary-hover-color);
|
|
84
|
-
border-color: var(--law-btn-primary-hover-bg);
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
.law-button.el-button--success:not(.is-disabled):hover {
|
|
88
|
-
background-color: var(--law-btn-success-hover-bg);
|
|
89
|
-
color: var(--law-btn-success-hover-color);
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
.law-button.el-button--warning:not(.is-disabled):hover {
|
|
93
|
-
background-color: var(--law-btn-warning-hover-bg);
|
|
94
|
-
color: var(--law-btn-warning-hover-color);
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
.law-button.el-button--danger:not(.is-disabled):hover {
|
|
98
|
-
background-color: var(--law-btn-danger-hover-bg);
|
|
99
|
-
color: var(--law-btn-danger-hover-color);
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
.law-button.el-button--info:not(.is-disabled):hover {
|
|
103
|
-
background-color: var(--law-btn-info-hover-bg);
|
|
104
|
-
color: var(--law-btn-info-hover-color);
|
|
105
|
-
}
|
|
106
|
-
</style>
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
ButtonEmits,
|
|
3
|
-
ButtonProps,
|
|
4
|
-
} from "element-plus/es/components/button";
|
|
5
|
-
|
|
6
|
-
/** Law 按钮尺寸(对齐 Law0S 设计规范) */
|
|
7
|
-
export type LawButtonSize = "lg" | "md" | "sm";
|
|
8
|
-
|
|
9
|
-
export interface LawButtonOwnProps {
|
|
10
|
-
/** Law 设计规范尺寸,映射至 Element Plus size */
|
|
11
|
-
lawSize?: LawButtonSize;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export type LawButtonProps = LawButtonOwnProps & Partial<ButtonProps>;
|
|
15
|
-
|
|
16
|
-
export type LawButtonEmits = ButtonEmits;
|
|
17
|
-
|
|
18
|
-
export type LawButtonSlots = {
|
|
19
|
-
default?: () => unknown;
|
|
20
|
-
loading?: () => unknown;
|
|
21
|
-
icon?: () => unknown;
|
|
22
|
-
};
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<el-dialog
|
|
3
|
-
v-bind="mergedProps"
|
|
4
|
-
class="law-dialog"
|
|
5
|
-
@open="onOpen"
|
|
6
|
-
@opened="onOpened"
|
|
7
|
-
@close="onClose"
|
|
8
|
-
@closed="onClosed"
|
|
9
|
-
@update:model-value="onUpdateModelValue"
|
|
10
|
-
@open-auto-focus="onOpenAutoFocus"
|
|
11
|
-
@close-auto-focus="onCloseAutoFocus"
|
|
12
|
-
>
|
|
13
|
-
<slot />
|
|
14
|
-
<template v-if="$slots.header" #header="headerProps">
|
|
15
|
-
<slot name="header" v-bind="headerProps" />
|
|
16
|
-
</template>
|
|
17
|
-
<template v-if="$slots.title" #title>
|
|
18
|
-
<slot name="title" />
|
|
19
|
-
</template>
|
|
20
|
-
<template v-if="$slots.footer" #footer>
|
|
21
|
-
<slot name="footer" />
|
|
22
|
-
</template>
|
|
23
|
-
</el-dialog>
|
|
24
|
-
</template>
|
|
25
|
-
|
|
26
|
-
<script setup lang="ts">
|
|
27
|
-
import { ElDialog } from 'element-plus'
|
|
28
|
-
import { computed, useAttrs } from 'vue'
|
|
29
|
-
import type { LawDialogProps } from './types'
|
|
30
|
-
|
|
31
|
-
defineOptions({
|
|
32
|
-
name: 'LawDialog',
|
|
33
|
-
inheritAttrs: false,
|
|
34
|
-
})
|
|
35
|
-
|
|
36
|
-
const props = defineProps<LawDialogProps>()
|
|
37
|
-
|
|
38
|
-
const emit = defineEmits<{
|
|
39
|
-
open: []
|
|
40
|
-
opened: []
|
|
41
|
-
close: []
|
|
42
|
-
closed: []
|
|
43
|
-
'update:modelValue': [value: boolean]
|
|
44
|
-
openAutoFocus: []
|
|
45
|
-
closeAutoFocus: []
|
|
46
|
-
}>()
|
|
47
|
-
|
|
48
|
-
const attrs = useAttrs()
|
|
49
|
-
|
|
50
|
-
const mergedProps = computed(() => ({
|
|
51
|
-
...attrs,
|
|
52
|
-
...props,
|
|
53
|
-
}))
|
|
54
|
-
|
|
55
|
-
function onOpen() {
|
|
56
|
-
emit('open')
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
function onOpened() {
|
|
60
|
-
emit('opened')
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
function onClose() {
|
|
64
|
-
emit('close')
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
function onClosed() {
|
|
68
|
-
emit('closed')
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
function onUpdateModelValue(value: boolean) {
|
|
72
|
-
emit('update:modelValue', value)
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
function onOpenAutoFocus() {
|
|
76
|
-
emit('openAutoFocus')
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
function onCloseAutoFocus() {
|
|
80
|
-
emit('closeAutoFocus')
|
|
81
|
-
}
|
|
82
|
-
</script>
|
|
83
|
-
|
|
84
|
-
<style scoped>
|
|
85
|
-
.law-dialog {
|
|
86
|
-
--el-dialog-border-radius: var(--law-radius-md);
|
|
87
|
-
font-family: var(--law-font-family-zh);
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
.law-dialog :deep(.el-dialog__header) {
|
|
91
|
-
color: var(--law-text-primary);
|
|
92
|
-
font-weight: var(--law-font-weight-semibold);
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
.law-dialog :deep(.el-dialog__body) {
|
|
96
|
-
color: var(--law-text-regular);
|
|
97
|
-
font-size: var(--law-font-size-body);
|
|
98
|
-
line-height: var(--law-line-height-body);
|
|
99
|
-
}
|
|
100
|
-
</style>
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { DialogEmits, DialogProps } from 'element-plus/es/components/dialog'
|
|
2
|
-
|
|
3
|
-
export type LawDialogProps = Partial<DialogProps>
|
|
4
|
-
|
|
5
|
-
export type LawDialogEmits = DialogEmits
|
|
6
|
-
|
|
7
|
-
export type LawDialogSlots = {
|
|
8
|
-
default?: () => unknown
|
|
9
|
-
header?: (props: { close: () => void; titleId: string; titleClass: string }) => unknown
|
|
10
|
-
title?: () => unknown
|
|
11
|
-
footer?: () => unknown
|
|
12
|
-
}
|
package/src/env.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/// <reference types="vite/client" />
|
|
2
|
-
|
|
3
|
-
declare module '*.vue' {
|
|
4
|
-
import type { DefineComponent } from 'vue'
|
|
5
|
-
const component: DefineComponent<object, object, unknown>
|
|
6
|
-
export default component
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
declare module '*.css' {
|
|
10
|
-
const css: string
|
|
11
|
-
export default css
|
|
12
|
-
}
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import { ref, type Ref } from 'vue'
|
|
2
|
-
|
|
3
|
-
export type LawThemeMode = 'light' | 'dark'
|
|
4
|
-
|
|
5
|
-
export interface UseLawThemeReturn {
|
|
6
|
-
mode: Ref<LawThemeMode>
|
|
7
|
-
setTheme: (theme: LawThemeMode) => void
|
|
8
|
-
toggleTheme: () => void
|
|
9
|
-
isDark: () => boolean
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
const THEME_ATTR = 'data-theme'
|
|
13
|
-
const DARK_CLASS = 'dark'
|
|
14
|
-
|
|
15
|
-
function applyTheme(theme: LawThemeMode) {
|
|
16
|
-
if (typeof document === 'undefined') return
|
|
17
|
-
|
|
18
|
-
const root = document.documentElement
|
|
19
|
-
|
|
20
|
-
if (theme === 'dark') {
|
|
21
|
-
root.setAttribute(THEME_ATTR, 'dark')
|
|
22
|
-
root.classList.add(DARK_CLASS)
|
|
23
|
-
} else {
|
|
24
|
-
root.removeAttribute(THEME_ATTR)
|
|
25
|
-
root.classList.remove(DARK_CLASS)
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
function detectTheme(): LawThemeMode {
|
|
30
|
-
if (typeof document === 'undefined') return 'light'
|
|
31
|
-
|
|
32
|
-
const root = document.documentElement
|
|
33
|
-
if (
|
|
34
|
-
root.getAttribute(THEME_ATTR) === 'dark'
|
|
35
|
-
|| root.classList.contains(DARK_CLASS)
|
|
36
|
-
) {
|
|
37
|
-
return 'dark'
|
|
38
|
-
}
|
|
39
|
-
return 'light'
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export function useLawTheme(initial: LawThemeMode = 'light'): UseLawThemeReturn {
|
|
43
|
-
const mode = ref<LawThemeMode>(detectTheme() || initial)
|
|
44
|
-
|
|
45
|
-
function setTheme(theme: LawThemeMode) {
|
|
46
|
-
mode.value = theme
|
|
47
|
-
applyTheme(theme)
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
function toggleTheme() {
|
|
51
|
-
setTheme(mode.value === 'dark' ? 'light' : 'dark')
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
function isDark() {
|
|
55
|
-
return mode.value === 'dark'
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
applyTheme(mode.value)
|
|
59
|
-
|
|
60
|
-
return {
|
|
61
|
-
mode,
|
|
62
|
-
setTheme,
|
|
63
|
-
toggleTheme,
|
|
64
|
-
isDark,
|
|
65
|
-
}
|
|
66
|
-
}
|
package/src/index.ts
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import type { App, Plugin } from 'vue'
|
|
2
|
-
import LawButton from './components/law-button/index.vue'
|
|
3
|
-
import LawDialog from './components/law-dialog/index.vue'
|
|
4
|
-
|
|
5
|
-
export { LawButton, LawDialog }
|
|
6
|
-
export { useLawTheme } from './hooks/use-law-theme'
|
|
7
|
-
export type { LawThemeMode, UseLawThemeReturn } from './hooks/use-law-theme'
|
|
8
|
-
export * from './utils'
|
|
9
|
-
export type {
|
|
10
|
-
LawButtonProps,
|
|
11
|
-
LawButtonEmits,
|
|
12
|
-
LawButtonSlots,
|
|
13
|
-
LawButtonSize,
|
|
14
|
-
LawButtonOwnProps,
|
|
15
|
-
} from './components/law-button/types'
|
|
16
|
-
export type {
|
|
17
|
-
LawDialogProps,
|
|
18
|
-
LawDialogEmits,
|
|
19
|
-
LawDialogSlots,
|
|
20
|
-
} from './components/law-dialog/types'
|
|
21
|
-
|
|
22
|
-
const components = [LawButton, LawDialog] as const
|
|
23
|
-
|
|
24
|
-
const LawUI: Plugin = {
|
|
25
|
-
install(app: App) {
|
|
26
|
-
components.forEach((component) => {
|
|
27
|
-
const name = component.name
|
|
28
|
-
if (name) {
|
|
29
|
-
app.component(name, component)
|
|
30
|
-
}
|
|
31
|
-
})
|
|
32
|
-
},
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export default LawUI
|
package/src/styles/theme.css
DELETED
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* LawUI Theme Mapping Layer
|
|
3
|
-
* Maps Law0S Design Tokens (--law-*) to Element Plus (--el-*)
|
|
4
|
-
*/
|
|
5
|
-
@import "./variables.css";
|
|
6
|
-
|
|
7
|
-
:root,
|
|
8
|
-
:root.dark,
|
|
9
|
-
html.dark,
|
|
10
|
-
[data-theme="dark"] {
|
|
11
|
-
/* Brand & functional colors */
|
|
12
|
-
--el-color-primary: var(--law-color-primary);
|
|
13
|
-
--el-color-success: var(--law-color-success);
|
|
14
|
-
--el-color-warning: var(--law-color-warning);
|
|
15
|
-
--el-color-danger: var(--law-color-danger);
|
|
16
|
-
--el-color-error: var(--law-color-danger);
|
|
17
|
-
--el-color-info: var(--law-color-info);
|
|
18
|
-
|
|
19
|
-
--el-color-primary-light-3: var(--law-primary-300);
|
|
20
|
-
--el-color-primary-light-5: var(--law-primary-200);
|
|
21
|
-
--el-color-primary-light-7: var(--law-primary-100);
|
|
22
|
-
--el-color-primary-light-8: var(--law-primary-50);
|
|
23
|
-
--el-color-primary-light-9: var(--law-primary-50);
|
|
24
|
-
--el-color-primary-dark-2: var(--law-primary-600);
|
|
25
|
-
|
|
26
|
-
/* Typography */
|
|
27
|
-
--el-font-family: var(--law-font-family-zh);
|
|
28
|
-
--el-font-size-extra-large: var(--law-font-size-h1);
|
|
29
|
-
--el-font-size-large: var(--law-font-size-h3);
|
|
30
|
-
--el-font-size-medium: var(--law-font-size-h4);
|
|
31
|
-
--el-font-size-base: var(--law-font-size-body);
|
|
32
|
-
--el-font-size-small: var(--law-font-size-caption);
|
|
33
|
-
--el-font-size-extra-small: var(--law-font-size-mini);
|
|
34
|
-
--el-font-weight-primary: var(--law-font-weight-medium);
|
|
35
|
-
--el-font-line-height-primary: var(--law-line-height-body);
|
|
36
|
-
|
|
37
|
-
/* Text colors */
|
|
38
|
-
--el-text-color-primary: var(--law-text-primary);
|
|
39
|
-
--el-text-color-regular: var(--law-text-regular);
|
|
40
|
-
--el-text-color-secondary: var(--law-text-secondary);
|
|
41
|
-
--el-text-color-placeholder: var(--law-text-placeholder);
|
|
42
|
-
--el-text-color-disabled: var(--law-text-color-disabled);
|
|
43
|
-
|
|
44
|
-
/* Border */
|
|
45
|
-
--el-border-width: var(--law-border-width);
|
|
46
|
-
--el-border-color: var(--law-border-color);
|
|
47
|
-
--el-border-color-light: var(--law-border-color-light);
|
|
48
|
-
--el-border-color-lighter: var(--law-border-color-lighter);
|
|
49
|
-
--el-border-color-hover: var(--law-border-color);
|
|
50
|
-
|
|
51
|
-
/* Background & fill */
|
|
52
|
-
--el-bg-color: var(--law-bg-white);
|
|
53
|
-
--el-bg-color-page: var(--law-bg-page);
|
|
54
|
-
--el-bg-color-overlay: var(--law-bg-white);
|
|
55
|
-
--el-fill-color: var(--law-fill-color);
|
|
56
|
-
--el-fill-color-light: var(--law-fill-color-light);
|
|
57
|
-
--el-fill-color-lighter: var(--law-border-color-lighter);
|
|
58
|
-
--el-fill-color-blank: var(--law-fill-color-blank);
|
|
59
|
-
--el-disabled-bg-color: var(--law-bg-disabled);
|
|
60
|
-
--el-disabled-text-color: var(--law-text-placeholder);
|
|
61
|
-
--el-disabled-border-color: var(--law-border-color-light);
|
|
62
|
-
|
|
63
|
-
/* Radius */
|
|
64
|
-
--el-border-radius-base: var(--law-radius-sm);
|
|
65
|
-
--el-border-radius-small: var(--law-radius-sm);
|
|
66
|
-
--el-border-radius-round: var(--law-radius-lg);
|
|
67
|
-
|
|
68
|
-
/* Shadow */
|
|
69
|
-
--el-box-shadow: var(--law-box-shadow);
|
|
70
|
-
--el-box-shadow-light: var(--law-shadow-sm);
|
|
71
|
-
--el-box-shadow-lighter: var(--law-shadow-sm);
|
|
72
|
-
--el-box-shadow-dark: var(--law-shadow-lg);
|
|
73
|
-
|
|
74
|
-
/* Component size (align with Law button tokens) */
|
|
75
|
-
--el-component-size-large: var(--law-btn-size-lg);
|
|
76
|
-
--el-component-size: var(--law-btn-size-md);
|
|
77
|
-
--el-component-size-small: var(--law-btn-size-sm);
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
:root.dark,
|
|
81
|
-
html.dark,
|
|
82
|
-
[data-theme="dark"] {
|
|
83
|
-
color-scheme: dark;
|
|
84
|
-
}
|
package/src/utils/index.ts
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import type { LawThemeMode } from '../hooks/use-law-theme'
|
|
2
|
-
|
|
3
|
-
const THEME_ATTR = 'data-theme'
|
|
4
|
-
const DARK_CLASS = 'dark'
|
|
5
|
-
|
|
6
|
-
/** 判断当前是否为暗色模式 */
|
|
7
|
-
export function isLawDarkMode(): boolean {
|
|
8
|
-
if (typeof document === 'undefined') return false
|
|
9
|
-
|
|
10
|
-
const root = document.documentElement
|
|
11
|
-
return root.getAttribute(THEME_ATTR) === 'dark' || root.classList.contains(DARK_CLASS)
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
/** 获取当前主题模式 */
|
|
15
|
-
export function getLawThemeMode(): LawThemeMode {
|
|
16
|
-
return isLawDarkMode() ? 'dark' : 'light'
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
/** 合并 class 名称 */
|
|
20
|
-
export function mergeLawClass(...classes: Array<string | false | null | undefined>): string {
|
|
21
|
-
return classes.filter(Boolean).join(' ')
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
/** 将 Law 按钮尺寸映射为 Element Plus size */
|
|
25
|
-
export function mapLawButtonSize(size: 'lg' | 'md' | 'sm'): 'large' | 'default' | 'small' {
|
|
26
|
-
const map = {
|
|
27
|
-
lg: 'large',
|
|
28
|
-
md: 'default',
|
|
29
|
-
sm: 'small',
|
|
30
|
-
} as const
|
|
31
|
-
return map[size]
|
|
32
|
-
}
|