quick-platform 1.0.46
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/LICENSE +21 -0
- package/README.md +63 -0
- package/dist/application/constants.d.ts +4 -0
- package/dist/application/index.d.ts +29 -0
- package/dist/application/manage.d.ts +31 -0
- package/dist/business/index.d.ts +72 -0
- package/dist/business/version.d.ts +7 -0
- package/dist/components/IconFont.d.ts +4 -0
- package/dist/components/LocalDebug.d.ts +6 -0
- package/dist/components/MicroApp.d.ts +14 -0
- package/dist/components/Permission.d.ts +6 -0
- package/dist/components/context.d.ts +3 -0
- package/dist/components/i18n.d.ts +2 -0
- package/dist/config.d.ts +2 -0
- package/dist/config.js +2 -0
- package/dist/config.js.map +1 -0
- package/dist/event.d.ts +13 -0
- package/dist/index-543d110b.js +547 -0
- package/dist/index-543d110b.js.map +1 -0
- package/dist/index-be61d86b.js +2 -0
- package/dist/index-be61d86b.js.map +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/theme/define/color.d.ts +9 -0
- package/dist/theme/define/font.d.ts +50 -0
- package/dist/theme/define/index.d.ts +5 -0
- package/dist/theme/define/size.d.ts +24 -0
- package/dist/theme/define/style.d.ts +21 -0
- package/dist/theme/doc.d.ts +2 -0
- package/dist/theme/index.d.ts +3 -0
- package/dist/theme/lib/index.d.ts +1 -0
- package/dist/theme/react/hook.d.ts +5 -0
- package/dist/theme/react/index.d.ts +3 -0
- package/dist/theme/uno.d.ts +19 -0
- package/dist/utils/i18n.d.ts +6 -0
- package/dist/utils/image.d.ts +2 -0
- package/dist/utils/index.d.ts +5 -0
- package/dist/utils/localstorage.d.ts +6 -0
- package/dist/utils/request.d.ts +37 -0
- package/dist/utils/utils.d.ts +3 -0
- package/package.json +67 -0
- package/src/application/constants.ts +7 -0
- package/src/application/index.ts +82 -0
- package/src/application/manage.ts +119 -0
- package/src/business/declare.d.ts +39 -0
- package/src/business/index.ts +130 -0
- package/src/business/version.ts +58 -0
- package/src/components/IconFont.ts +11 -0
- package/src/components/LocalDebug.ts +244 -0
- package/src/components/MicroApp.ts +97 -0
- package/src/components/Permission.ts +13 -0
- package/src/components/context.ts +31 -0
- package/src/components/i18n.ts +17 -0
- package/src/config.ts +3 -0
- package/src/event.ts +24 -0
- package/src/index.ts +38 -0
- package/src/theme/define/color.ts +53 -0
- package/src/theme/define/font.ts +29 -0
- package/src/theme/define/index.ts +8 -0
- package/src/theme/define/size.ts +31 -0
- package/src/theme/define/style.ts +41 -0
- package/src/theme/doc.tsx +438 -0
- package/src/theme/index.ts +5 -0
- package/src/theme/lib/index.ts +15 -0
- package/src/theme/react/hook.ts +42 -0
- package/src/theme/react/index.ts +14 -0
- package/src/theme/uno.ts +218 -0
- package/src/utils/i18n.ts +84 -0
- package/src/utils/image.ts +52 -0
- package/src/utils/index.ts +9 -0
- package/src/utils/localstorage.ts +32 -0
- package/src/utils/request.ts +173 -0
- package/src/utils/utils.ts +15 -0
package/src/index.ts
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { registerApp, getCurrentApp } from './application';
|
|
2
|
+
|
|
3
|
+
import MicroApp from './components/MicroApp';
|
|
4
|
+
|
|
5
|
+
import Permission from './components/Permission';
|
|
6
|
+
import LocalDebug from './components/LocalDebug';
|
|
7
|
+
|
|
8
|
+
import I18nFC from './components/i18n';
|
|
9
|
+
|
|
10
|
+
import IconFont from './components/IconFont';
|
|
11
|
+
import { App, useAppData } from './components/context';
|
|
12
|
+
|
|
13
|
+
import AppEvent from './event';
|
|
14
|
+
|
|
15
|
+
import * as Utils from './utils';
|
|
16
|
+
|
|
17
|
+
import * as Authentication from './business';
|
|
18
|
+
|
|
19
|
+
export * from './theme';
|
|
20
|
+
|
|
21
|
+
const win: any = window;
|
|
22
|
+
const debugKey = '__quick_platform_get_current_app__';
|
|
23
|
+
win[debugKey] = getCurrentApp;
|
|
24
|
+
|
|
25
|
+
export {
|
|
26
|
+
App,
|
|
27
|
+
useAppData,
|
|
28
|
+
getCurrentApp,
|
|
29
|
+
registerApp,
|
|
30
|
+
LocalDebug,
|
|
31
|
+
MicroApp,
|
|
32
|
+
Permission,
|
|
33
|
+
IconFont,
|
|
34
|
+
AppEvent,
|
|
35
|
+
Utils,
|
|
36
|
+
Authentication,
|
|
37
|
+
I18nFC,
|
|
38
|
+
};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
const DefaultOpacity = (0.6 * 255).toString(16);
|
|
2
|
+
|
|
3
|
+
// eslint-disable-next-line import/no-mutable-exports
|
|
4
|
+
export let PrimaryColor = '#ff6600';
|
|
5
|
+
|
|
6
|
+
export const generateVar = (name: string) => {
|
|
7
|
+
return `--color-g-${name}`;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
//
|
|
11
|
+
/* todo 预留主题色阶
|
|
12
|
+
{
|
|
13
|
+
'brand-1': string;
|
|
14
|
+
'brand-2': string;
|
|
15
|
+
'brand-3': string;
|
|
16
|
+
'brand-4': string;
|
|
17
|
+
'brand-5': string;
|
|
18
|
+
'brand-6': string;
|
|
19
|
+
}
|
|
20
|
+
*/
|
|
21
|
+
export const BrandColor = {} as const;
|
|
22
|
+
|
|
23
|
+
export const updateBrandColor = (color: string) => {
|
|
24
|
+
PrimaryColor = color;
|
|
25
|
+
return BrandColor;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
// todo 预留中性色
|
|
29
|
+
// export const NeutralColor = {} ;
|
|
30
|
+
|
|
31
|
+
// // todo 预留中性色-浅色
|
|
32
|
+
// export const NeutralHelperColor: Record<
|
|
33
|
+
// `${keyof typeof NeutralColor}-6`,
|
|
34
|
+
// string
|
|
35
|
+
// > = Object.keys(NeutralColor).reduce<any>((map, key) => {
|
|
36
|
+
// map[`${key}-6`] =
|
|
37
|
+
// NeutralColor[key as unknown as keyof typeof NeutralColor] + DefaultOpacity;
|
|
38
|
+
// return map;
|
|
39
|
+
// }, {});
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* todo预留功能色
|
|
43
|
+
*/
|
|
44
|
+
export const FunctionalColor = {};
|
|
45
|
+
|
|
46
|
+
export const FunctionalHelperColor: typeof FunctionalColor = Object.keys(
|
|
47
|
+
FunctionalColor
|
|
48
|
+
).reduce<any>((map, key) => {
|
|
49
|
+
map[`${key}-6`] =
|
|
50
|
+
FunctionalColor[(key as unknown) as keyof typeof FunctionalColor] +
|
|
51
|
+
DefaultOpacity;
|
|
52
|
+
return map;
|
|
53
|
+
}, {});
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export const EnFont = 'Inter';
|
|
2
|
+
export const NumberFont = 'Inter';
|
|
3
|
+
|
|
4
|
+
const font = (size: number, _lineHeight?: number) => {
|
|
5
|
+
return { fontSize: size, fontWeight: 'initial' };
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
const bold = (_font: ReturnType<typeof font>) => {
|
|
9
|
+
return { ..._font, fontWeight: 'bold' };
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export const TextFont = {
|
|
13
|
+
Normal: font(13, 22),
|
|
14
|
+
NormalBold: bold(font(13, 22)),
|
|
15
|
+
Small: font(12, 20),
|
|
16
|
+
SmallBold: bold(font(12, 20)),
|
|
17
|
+
Middle: font(14, 22),
|
|
18
|
+
MiddleBold: bold(font(14, 22)),
|
|
19
|
+
Large: font(16, 28),
|
|
20
|
+
LargeBold: bold(font(16, 28)),
|
|
21
|
+
Helper: font(12, 20),
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export const TitleFont = {
|
|
25
|
+
Normal: font(14, 24),
|
|
26
|
+
// Small: font(16, 24),
|
|
27
|
+
Middle: font(16, 28),
|
|
28
|
+
// Large: font(24, 32),
|
|
29
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
const DefaultSize = 4;
|
|
2
|
+
// todo 还未定义,暂时不处理
|
|
3
|
+
export const BaseSize: {
|
|
4
|
+
'size-1': number;
|
|
5
|
+
'size-2': number;
|
|
6
|
+
'size-3': number;
|
|
7
|
+
'size-4': number;
|
|
8
|
+
'size-5': number;
|
|
9
|
+
'size-6': number;
|
|
10
|
+
'size-7': number;
|
|
11
|
+
'size-8': number;
|
|
12
|
+
'size-9': number;
|
|
13
|
+
'size-10': number;
|
|
14
|
+
} = Array.from({ length: 10 }).reduce<any>((map, _, index) => {
|
|
15
|
+
map[`size-${index + 1}`] = (index + 1) * DefaultSize;
|
|
16
|
+
return map;
|
|
17
|
+
}, {});
|
|
18
|
+
|
|
19
|
+
export const ComponentSize = {};
|
|
20
|
+
|
|
21
|
+
export const MarginSize = {};
|
|
22
|
+
export const IconSize = { normal: 16 };
|
|
23
|
+
|
|
24
|
+
// 参考 https://www.woshipm.com/pd/4736098.html
|
|
25
|
+
export const ResponsiveScreenSize = {
|
|
26
|
+
s: 480,
|
|
27
|
+
m: 640,
|
|
28
|
+
l: 1024,
|
|
29
|
+
xl: 1366,
|
|
30
|
+
xxl: 1920,
|
|
31
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
const border = (width: number, style: 'dashed' | 'solid') => {
|
|
2
|
+
return {
|
|
3
|
+
borderStyle: style,
|
|
4
|
+
borderWidth: width,
|
|
5
|
+
borderColor: '#F0F0F0', // todo
|
|
6
|
+
};
|
|
7
|
+
};
|
|
8
|
+
const borderRadius = (radius: number) => {
|
|
9
|
+
return { borderRadius: radius };
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export const BorderRadius = {
|
|
13
|
+
Small: borderRadius(6),
|
|
14
|
+
Normal: borderRadius(8),
|
|
15
|
+
// Large: borderRadius(10), // todo
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export const Border = {
|
|
19
|
+
SolidStroke: border(1, 'solid'),
|
|
20
|
+
// SolidNormal: border(2, 'solid'),
|
|
21
|
+
// SolidBold: border(3, 'solid'),
|
|
22
|
+
DashedStroke: border(1, 'dashed'),
|
|
23
|
+
// DashedNormal: border(2, 'dashed'),
|
|
24
|
+
// DashedBold: border(3, 'dashed'),
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
// const shadow = (x: number, y: number, b: number, s: number) => {
|
|
28
|
+
// return {
|
|
29
|
+
// offsetX: x,
|
|
30
|
+
// offsetY: y,
|
|
31
|
+
// blurRadius: b,
|
|
32
|
+
// spreadRadius: s,
|
|
33
|
+
// color: '#00000020',
|
|
34
|
+
// };
|
|
35
|
+
// };
|
|
36
|
+
|
|
37
|
+
export const Shadow = {
|
|
38
|
+
// Level1: shadow(0, 2, 5, 0),
|
|
39
|
+
// Level2: shadow(0, 4, 10, 0),
|
|
40
|
+
// Level3: shadow(0, 8, 20, 0),
|
|
41
|
+
};
|
|
@@ -0,0 +1,438 @@
|
|
|
1
|
+
import React, { useContext, useState } from 'react';
|
|
2
|
+
|
|
3
|
+
import classNames from 'classnames';
|
|
4
|
+
|
|
5
|
+
import { Color, Font, Size, Style } from './define';
|
|
6
|
+
import { ThemeHOC, useThemePrimaryColor } from './react';
|
|
7
|
+
|
|
8
|
+
const ThemeContext = React.createContext<{ mode: 'js' | 'uno' }>({
|
|
9
|
+
mode: 'js',
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
const Button: React.FC<any> = props => {
|
|
13
|
+
return <div onClick={props.onClick}>{props.children}</div>;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const useTheme = () => {
|
|
17
|
+
return useContext(ThemeContext).mode;
|
|
18
|
+
};
|
|
19
|
+
const mUno = (mode: string, value: any) => {
|
|
20
|
+
if (mode === 'uno') return value;
|
|
21
|
+
return typeof value === 'string' ? '' : {};
|
|
22
|
+
};
|
|
23
|
+
const mJs = (mode: string, value: any) => {
|
|
24
|
+
if (mode === 'js') return value;
|
|
25
|
+
return typeof value === 'string' ? '' : {};
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const useThemeMatch = () => {
|
|
29
|
+
const mode = useTheme();
|
|
30
|
+
return {
|
|
31
|
+
Uno(value: any) {
|
|
32
|
+
return mUno(mode, value);
|
|
33
|
+
},
|
|
34
|
+
Js(value: any) {
|
|
35
|
+
return mJs(mode, value);
|
|
36
|
+
},
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
const Cls: React.FC<{ js?: React.ReactNode }> = props => {
|
|
41
|
+
const mode = useTheme();
|
|
42
|
+
if (mode === 'js') {
|
|
43
|
+
return (
|
|
44
|
+
<div className="bg-gray">
|
|
45
|
+
{'js->'}
|
|
46
|
+
{props.js}
|
|
47
|
+
</div>
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
return <div className="bg-gray">{props.children}</div>;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
const ColorList: React.FC<{ colors: any; name: string }> = ({
|
|
54
|
+
colors,
|
|
55
|
+
name,
|
|
56
|
+
}) => {
|
|
57
|
+
const keys = Object.keys(colors);
|
|
58
|
+
console.log(
|
|
59
|
+
'%c [ halvee>colors]-56',
|
|
60
|
+
'font-size:13px; background:pink; color:#bf2c9f;',
|
|
61
|
+
colors
|
|
62
|
+
);
|
|
63
|
+
const mode = useTheme();
|
|
64
|
+
return (
|
|
65
|
+
<div className="flex-box">
|
|
66
|
+
<div className="color-black font-500 rounded-lg shadow-2xl flex-col m-2 bg-blue size-20 flex-box">
|
|
67
|
+
{name}
|
|
68
|
+
</div>
|
|
69
|
+
{keys.map((key, index) => {
|
|
70
|
+
return (
|
|
71
|
+
<div
|
|
72
|
+
key={key}
|
|
73
|
+
style={mJs(mode, { backgroundColor: colors[key] })}
|
|
74
|
+
className={`
|
|
75
|
+
size-30 flex-box rounded-lg shadow-2xl flex-col m-2
|
|
76
|
+
${index > keys.length / 2 ? 'color-white' : 'color-black'}
|
|
77
|
+
${mUno(mode, `bg-q-${key}`)}
|
|
78
|
+
`}
|
|
79
|
+
>
|
|
80
|
+
<Cls jsNode="">{`.bg-q-${key}`}</Cls>
|
|
81
|
+
<div>{key}</div>
|
|
82
|
+
<div>{colors[key]}</div>
|
|
83
|
+
</div>
|
|
84
|
+
);
|
|
85
|
+
})}
|
|
86
|
+
</div>
|
|
87
|
+
);
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
// ' bg-q-brand-1 bg-q-brand-2 bg-q-brand-3 bg-q-brand-4 bg-q-brand-5 bg-q-brand-6 bg-q-brand-7 bg-q-brand-8 bg-q-brand-9 bg-q-brand-10
|
|
91
|
+
// bg-q-grey-1 bg-q-grey-2 bg-q-grey-3 bg-q-grey-4 bg-q-grey-6 bg-q-grey-8 bg-q-grey-10
|
|
92
|
+
// bg-q-grey-1-6 bg-q-grey-2-6 bg-q-grey-3-6 bg-q-grey-4-6 bg-q-grey-6-6 bg-q-grey-8-6 bg-q-grey-10-6
|
|
93
|
+
// bg-q-error bg-q-warn bg-q-success bg-q-link bg-q-yellow bg-q-cyan bg-q-purple
|
|
94
|
+
// bg-q-error-6 bg-q-warn-6 bg-q-success-6 bg-q-link-6 bg-q-yellow-6 bg-q-cyan-6 bg-q-purple-6 bg-q-primary';
|
|
95
|
+
|
|
96
|
+
const ColorDoc: React.FC<{ test?: string }> = props => {
|
|
97
|
+
console.log(
|
|
98
|
+
'%c [ halvee>]-93',
|
|
99
|
+
'font-size:13px; background:pink; color:#bf2c9f;',
|
|
100
|
+
Color
|
|
101
|
+
);
|
|
102
|
+
return (
|
|
103
|
+
<div className={`border-3 border-solid m-10 ${props.test}`}>
|
|
104
|
+
<Cls>
|
|
105
|
+
<div className="bg-q-primary">主题色(bg-q-primary)</div>
|
|
106
|
+
</Cls>
|
|
107
|
+
<Cls>
|
|
108
|
+
<div className="text-q-primary">主题色(color-q-primary)</div>
|
|
109
|
+
</Cls>
|
|
110
|
+
<div style={{ color: Color.PrimaryColor }}>
|
|
111
|
+
js:
|
|
112
|
+
{'{Color.PrimaryColor}'}
|
|
113
|
+
</div>
|
|
114
|
+
{/* <ColorList key={1} colors={BrandColor} name="主题色" /> */}
|
|
115
|
+
{/* <ColorList key={2} colors={NeutralColor} name="中性色" />
|
|
116
|
+
<ColorList key={4} colors={NeutralHelperColor} name="中性色-遮罩" />
|
|
117
|
+
<ColorList key={3} colors={FunctionalColor} name="功能色" />
|
|
118
|
+
<ColorList key={4} colors={FunctionalHelperColor} name="功能色-遮罩" /> */}
|
|
119
|
+
</div>
|
|
120
|
+
);
|
|
121
|
+
};
|
|
122
|
+
const toLine = (str: string) => {
|
|
123
|
+
return str.replace(/\B([A-Z])/g, '-$1').toLowerCase();
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
// 'text-q-normal text-q-normal-bold text-q-small text-q-small-bold text-q-middle-bold text-q-large text-q-large-bold'
|
|
127
|
+
// 'title-q-normal title-q-small title-q-large title-q-middle text-q-helper'
|
|
128
|
+
// 'topic-q-normal topic-q-small topic-q-large'
|
|
129
|
+
const FontList: React.FC<{
|
|
130
|
+
fonts: any;
|
|
131
|
+
name: string;
|
|
132
|
+
prefix: string;
|
|
133
|
+
jsPrefix: string;
|
|
134
|
+
}> = ({ fonts, name, prefix, jsPrefix }) => {
|
|
135
|
+
const keys = Object.keys(fonts);
|
|
136
|
+
const mode = useTheme();
|
|
137
|
+
return (
|
|
138
|
+
<div className="flex flex-(row items-center wrap)">
|
|
139
|
+
<div className="color-black font-500 rounded-lg shadow-2xl flex-col m-2 bg-blue size-20 flex-box shrink-0">
|
|
140
|
+
{name}
|
|
141
|
+
</div>
|
|
142
|
+
{keys.map(key => {
|
|
143
|
+
return (
|
|
144
|
+
<span
|
|
145
|
+
key={key}
|
|
146
|
+
className={classNames(
|
|
147
|
+
'rounded-lg shadow-2xl flex-col m-2 bg-#00000020',
|
|
148
|
+
mUno(mode, `${prefix}-q-${toLine(key)}`)
|
|
149
|
+
)}
|
|
150
|
+
style={mJs(mode, {
|
|
151
|
+
...fonts[key],
|
|
152
|
+
lineHeight: `${fonts[key].lineHeight}px`,
|
|
153
|
+
})}
|
|
154
|
+
>
|
|
155
|
+
<Cls js={`Theme.${jsPrefix}.${key}`}>{`.${prefix}-q-${toLine(
|
|
156
|
+
key
|
|
157
|
+
)}`}</Cls>
|
|
158
|
+
<br />
|
|
159
|
+
<span>
|
|
160
|
+
{key}:{JSON.stringify(fonts[key])}
|
|
161
|
+
</span>
|
|
162
|
+
</span>
|
|
163
|
+
);
|
|
164
|
+
})}
|
|
165
|
+
</div>
|
|
166
|
+
);
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
const FontDoc: React.FC = () => {
|
|
170
|
+
return (
|
|
171
|
+
<div className="border-3 border-solid m-10">
|
|
172
|
+
<FontList
|
|
173
|
+
key="text"
|
|
174
|
+
fonts={Font.TextFont}
|
|
175
|
+
jsPrefix="Font.TextFont"
|
|
176
|
+
name="文本字体"
|
|
177
|
+
prefix="text"
|
|
178
|
+
/>
|
|
179
|
+
<FontList
|
|
180
|
+
key="title"
|
|
181
|
+
fonts={Font.TitleFont}
|
|
182
|
+
jsPrefix="Font.TitleFont"
|
|
183
|
+
name="标题字体"
|
|
184
|
+
prefix="title"
|
|
185
|
+
/>
|
|
186
|
+
</div>
|
|
187
|
+
);
|
|
188
|
+
};
|
|
189
|
+
'flex-(col none)';
|
|
190
|
+
// 'size-q-1 size-q-2 size-q-3 size-q-4 size-q-5 size-q-6 size-q-7 size-q-8 size-q-9 size-q-10'
|
|
191
|
+
// 'size-q-mini size-q-small size-q-default size-q-large'
|
|
192
|
+
// 'm-q-s m-q-m m-q-l m-q-xl m-q-xxl m-q-xxxl'
|
|
193
|
+
// 'p-q-s p-q-m p-q-l p-q-xl p-q-xxl p-q-xxxl'
|
|
194
|
+
// 'gap-q-s gap-q-m gap-q-l gap-q-xl gap-q-xxl gap-q-xxxl'
|
|
195
|
+
const SizeList: React.FC<{
|
|
196
|
+
size: any;
|
|
197
|
+
name: string;
|
|
198
|
+
isMargin?: boolean;
|
|
199
|
+
isPadding?: boolean;
|
|
200
|
+
}> = ({ size, name, isMargin = false, isPadding = false }) => {
|
|
201
|
+
const keys = Object.keys(size);
|
|
202
|
+
const { Js, Uno } = useThemeMatch();
|
|
203
|
+
return (
|
|
204
|
+
<div className="flex flex-wrap flex-row">
|
|
205
|
+
<div className="color-black font-500 rounded-lg shadow-2xl flex-col m-2 bg-blue size-20 flex-box">
|
|
206
|
+
{name}
|
|
207
|
+
</div>
|
|
208
|
+
{keys.map(key => {
|
|
209
|
+
const s = (v: number) => Math.min(200, v);
|
|
210
|
+
const cls = isMargin
|
|
211
|
+
? Uno(`m-q-${key.replace('size-', '')}`)
|
|
212
|
+
: isPadding
|
|
213
|
+
? Uno(`p-q-${key.replace('size-', '')}`)
|
|
214
|
+
: Uno(`size-q-${key.replace('size-', '')}`);
|
|
215
|
+
return (
|
|
216
|
+
<div key={key} className="m-2">
|
|
217
|
+
<span>
|
|
218
|
+
<Cls> {`.${cls}`}</Cls>
|
|
219
|
+
{key}:{`${size[key]}px`}
|
|
220
|
+
<div
|
|
221
|
+
style={isPadding ? Js({ padding: s(size[key]) }) : {}}
|
|
222
|
+
className={classNames({
|
|
223
|
+
'border border-solid': isMargin,
|
|
224
|
+
'bg-#C9CDD4': isPadding,
|
|
225
|
+
[cls]: isPadding,
|
|
226
|
+
})}
|
|
227
|
+
>
|
|
228
|
+
<div
|
|
229
|
+
className={classNames('flex-col bg-#00000020', cls, {
|
|
230
|
+
'size-100px': isMargin || isPadding,
|
|
231
|
+
})}
|
|
232
|
+
style={
|
|
233
|
+
isMargin
|
|
234
|
+
? Js({
|
|
235
|
+
width: 100,
|
|
236
|
+
height: 100,
|
|
237
|
+
margin: s(size[key]),
|
|
238
|
+
})
|
|
239
|
+
: isPadding
|
|
240
|
+
? Js({ minWith: 20 })
|
|
241
|
+
: Js({ width: s(size[key]), height: s(size[key]) })
|
|
242
|
+
}
|
|
243
|
+
/>
|
|
244
|
+
</div>
|
|
245
|
+
</span>
|
|
246
|
+
</div>
|
|
247
|
+
);
|
|
248
|
+
})}
|
|
249
|
+
</div>
|
|
250
|
+
);
|
|
251
|
+
};
|
|
252
|
+
|
|
253
|
+
const GapList: React.FC<{}> = () => {
|
|
254
|
+
const { Js, Uno } = useThemeMatch();
|
|
255
|
+
|
|
256
|
+
return (
|
|
257
|
+
<div className="flex-box flex-wrap items-start">
|
|
258
|
+
<div className="color-black font-500 rounded-lg shadow-2xl flex-col m-2 bg-blue size-20 flex-box">
|
|
259
|
+
间距
|
|
260
|
+
</div>
|
|
261
|
+
<div>
|
|
262
|
+
{Object.keys(Size.MarginSize).map((key: any) => {
|
|
263
|
+
const gap = Size.MarginSize[key as keyof typeof Size.MarginSize];
|
|
264
|
+
return (
|
|
265
|
+
<div>
|
|
266
|
+
<Cls>{`.gap-q-${key}`}</Cls>
|
|
267
|
+
<span>
|
|
268
|
+
gap-
|
|
269
|
+
{gap}
|
|
270
|
+
px
|
|
271
|
+
</span>
|
|
272
|
+
<div
|
|
273
|
+
style={Js({ gap })}
|
|
274
|
+
className={classNames(
|
|
275
|
+
'flex p-q-xl border-q-solid-stroke',
|
|
276
|
+
Uno(`gap-q-${key}`)
|
|
277
|
+
)}
|
|
278
|
+
>
|
|
279
|
+
{Array.from({ length: 6 }).map(_ => {
|
|
280
|
+
return <div className="size-100px bg-#00000020" />;
|
|
281
|
+
})}
|
|
282
|
+
</div>
|
|
283
|
+
</div>
|
|
284
|
+
);
|
|
285
|
+
})}
|
|
286
|
+
</div>
|
|
287
|
+
</div>
|
|
288
|
+
);
|
|
289
|
+
};
|
|
290
|
+
|
|
291
|
+
const SizeDoc: React.FC = () => {
|
|
292
|
+
return (
|
|
293
|
+
<div className="m-10 border-solid border-3">
|
|
294
|
+
<SizeList key="base" name="基础尺寸" size={Size.BaseSize} />
|
|
295
|
+
{/* <SizeList key="component" name="组件尺寸" size={Size.ComponentSize} /> */}
|
|
296
|
+
{/* <SizeList key="margin" isMargin name="间距尺寸" size={Size.MarginSize} /> */}
|
|
297
|
+
{/* <SizeList key="padding" isPadding name="内边距" size={Size.MarginSize} /> */}
|
|
298
|
+
<GapList />
|
|
299
|
+
{/* <SizeList size={Size.ResponsiveScreenSize} name="断点尺寸"></SizeList> */}
|
|
300
|
+
</div>
|
|
301
|
+
);
|
|
302
|
+
};
|
|
303
|
+
|
|
304
|
+
// 'rd-q-normal rd-q-small rd-q-large'
|
|
305
|
+
// 'border-q-solid-stroke border-q-solid-normal border-q-solid-bold border-q-dashed-stroke border-q-dashed-normal border-q-dashed-bold'
|
|
306
|
+
// 'shadow-q-level1 shadow-q-level2 shadow-q-level3'
|
|
307
|
+
const StyleList: React.FC<{
|
|
308
|
+
style: any;
|
|
309
|
+
name: string;
|
|
310
|
+
prefix: string;
|
|
311
|
+
jsPrefix: string;
|
|
312
|
+
className?: string;
|
|
313
|
+
}> = ({ style, name, prefix, className = '', jsPrefix }) => {
|
|
314
|
+
const keys = Object.keys(style);
|
|
315
|
+
const { Js, Uno } = useThemeMatch();
|
|
316
|
+
return (
|
|
317
|
+
<div className="flex flex-row flex-wrap color-grey-2 color-grey-2">
|
|
318
|
+
<div className="color-black font-500 rounded-lg shadow-2xl flex-col m-2 bg-blue size-20 flex-box">
|
|
319
|
+
{name}
|
|
320
|
+
</div>
|
|
321
|
+
{keys.map(key => {
|
|
322
|
+
const cls = `${prefix}q-${toLine(key)}`;
|
|
323
|
+
return (
|
|
324
|
+
<div
|
|
325
|
+
key={key}
|
|
326
|
+
className={classNames('m-2 w-100 h-30 p-5 ', Uno(cls), className)}
|
|
327
|
+
style={Js(style[key])}
|
|
328
|
+
>
|
|
329
|
+
<Cls js={`Theme.${jsPrefix}.${key}`}>
|
|
330
|
+
{' '}
|
|
331
|
+
<span className="text-q-primary">{`.${cls}`}</span>
|
|
332
|
+
</Cls>
|
|
333
|
+
{key}
|
|
334
|
+
<div>{JSON.stringify(style[key], null, 2)}</div>
|
|
335
|
+
</div>
|
|
336
|
+
);
|
|
337
|
+
})}
|
|
338
|
+
</div>
|
|
339
|
+
);
|
|
340
|
+
};
|
|
341
|
+
|
|
342
|
+
const StyleDoc: React.FC = () => {
|
|
343
|
+
const boxShadowToCss = () => {
|
|
344
|
+
return Object.keys(Style.Shadow).reduce<any>((map, key) => {
|
|
345
|
+
const shadow = (Style.Shadow as any)[key];
|
|
346
|
+
map[key] = {
|
|
347
|
+
boxShadow: `${shadow.offsetX}px ${shadow.offsetY}px ${shadow.blurRadius}px ${shadow.spreadRadius}px ${shadow.color}`,
|
|
348
|
+
border: 'none',
|
|
349
|
+
};
|
|
350
|
+
return map;
|
|
351
|
+
}, {});
|
|
352
|
+
};
|
|
353
|
+
|
|
354
|
+
return (
|
|
355
|
+
<div className="m-10 border-solid border-3">
|
|
356
|
+
<StyleList
|
|
357
|
+
key="rd"
|
|
358
|
+
className="border-1 border-solid "
|
|
359
|
+
jsPrefix="Style.BorderRadius"
|
|
360
|
+
name="圆角样式"
|
|
361
|
+
prefix="rd-"
|
|
362
|
+
style={Style.BorderRadius}
|
|
363
|
+
/>
|
|
364
|
+
<StyleList
|
|
365
|
+
key="border"
|
|
366
|
+
jsPrefix="Style.Border"
|
|
367
|
+
name="边框样式"
|
|
368
|
+
prefix="border-"
|
|
369
|
+
style={Style.Border}
|
|
370
|
+
/>
|
|
371
|
+
<StyleList
|
|
372
|
+
key="shadow"
|
|
373
|
+
jsPrefix="Style.Shadow"
|
|
374
|
+
name="阴影样式"
|
|
375
|
+
prefix="shadow-"
|
|
376
|
+
style={boxShadowToCss()}
|
|
377
|
+
/>
|
|
378
|
+
</div>
|
|
379
|
+
);
|
|
380
|
+
};
|
|
381
|
+
|
|
382
|
+
const Mode: React.FC<{
|
|
383
|
+
change(mode: 'js' | 'uno'): void;
|
|
384
|
+
mode: 'js' | 'uno';
|
|
385
|
+
}> = ({ change, mode }) => {
|
|
386
|
+
const { set, color } = useThemePrimaryColor();
|
|
387
|
+
return (
|
|
388
|
+
<div className=" right-10px fixed flex-row m-t-2 flex items-center gap-10px bg-q-cyan-6 rd-q-normal">
|
|
389
|
+
<Button
|
|
390
|
+
key="xx"
|
|
391
|
+
type={mode === 'uno' ? 'primary' : 'default'}
|
|
392
|
+
onClick={change.bind(null, 'uno')}
|
|
393
|
+
>
|
|
394
|
+
unocss
|
|
395
|
+
</Button>
|
|
396
|
+
<Button
|
|
397
|
+
key="yy"
|
|
398
|
+
type={mode === 'js' ? 'primary' : 'default'}
|
|
399
|
+
onClick={change.bind(null, 'js')}
|
|
400
|
+
>
|
|
401
|
+
js
|
|
402
|
+
</Button>
|
|
403
|
+
|
|
404
|
+
{/* <Popover
|
|
405
|
+
content={
|
|
406
|
+
<SketchPicker
|
|
407
|
+
color={color}
|
|
408
|
+
onChange={(color) => {
|
|
409
|
+
set(color);
|
|
410
|
+
}}
|
|
411
|
+
/>
|
|
412
|
+
}
|
|
413
|
+
>
|
|
414
|
+
<Button type="primary">
|
|
415
|
+
修改主题色
|
|
416
|
+
</Button>
|
|
417
|
+
</Popover> */}
|
|
418
|
+
</div>
|
|
419
|
+
);
|
|
420
|
+
};
|
|
421
|
+
|
|
422
|
+
const ThemeDoc = ThemeHOC(() => {
|
|
423
|
+
const [mode, setMode] = useState<'js' | 'uno'>('uno');
|
|
424
|
+
return (
|
|
425
|
+
<ThemeContext.Provider value={{ mode }}>
|
|
426
|
+
<div className="">
|
|
427
|
+
{/* <div className="p-lr-q-s">test</div> */}
|
|
428
|
+
<Mode change={setMode} mode={mode} />
|
|
429
|
+
<ColorDoc />
|
|
430
|
+
<FontDoc />
|
|
431
|
+
{/* <SizeDoc /> */}
|
|
432
|
+
<StyleDoc />
|
|
433
|
+
</div>
|
|
434
|
+
</ThemeContext.Provider>
|
|
435
|
+
);
|
|
436
|
+
});
|
|
437
|
+
|
|
438
|
+
export default ThemeDoc;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Color } from '../define';
|
|
2
|
+
|
|
3
|
+
export const setPrimaryColor = (color: string) => {
|
|
4
|
+
Color.updateBrandColor(color);
|
|
5
|
+
document.documentElement.style.setProperty(
|
|
6
|
+
Color.generateVar('primary'),
|
|
7
|
+
Color.PrimaryColor
|
|
8
|
+
);
|
|
9
|
+
// Object.keys(Color.BrandColor).forEach(key => {
|
|
10
|
+
// document.documentElement.style.setProperty(
|
|
11
|
+
// Color.generateVar(key),
|
|
12
|
+
// Color.BrandColor[key]
|
|
13
|
+
// );
|
|
14
|
+
// });
|
|
15
|
+
};
|