@canlooks/can-ui 0.0.89 → 0.0.90
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/dist/cjs/components/calendar/calendar.d.ts +5 -2
- package/dist/cjs/components/calendar/calendar.js +3 -1
- package/dist/cjs/components/calendar/calendar.style.js +124 -124
- package/dist/cjs/components/calendar/panelDates.d.ts +1 -1
- package/dist/cjs/components/calendar/panelDates.js +5 -2
- package/dist/cjs/components/clickAway/clickAway.d.ts +1 -1
- package/dist/cjs/components/dateTimePicker/dateTimePicker.js +2 -2
- package/dist/cjs/components/dateTimePicker/timer.d.ts +1 -1
- package/dist/cjs/components/dateTimePicker/timer.js +15 -4
- package/dist/cjs/components/popper/popper.js +0 -1
- package/dist/cjs/components/status/status.d.ts +6 -6
- package/dist/cjs/extensions/reactiveForm/reactiveFormItem.js +1 -0
- package/dist/esm/components/calendar/calendar.d.ts +5 -2
- package/dist/esm/components/calendar/calendar.js +3 -1
- package/dist/esm/components/calendar/calendar.style.js +124 -124
- package/dist/esm/components/calendar/panelDates.d.ts +1 -1
- package/dist/esm/components/calendar/panelDates.js +5 -2
- package/dist/esm/components/clickAway/clickAway.d.ts +1 -1
- package/dist/esm/components/dateTimePicker/dateTimePicker.js +2 -2
- package/dist/esm/components/dateTimePicker/timer.d.ts +1 -1
- package/dist/esm/components/dateTimePicker/timer.js +14 -4
- package/dist/esm/components/popper/popper.js +0 -1
- package/dist/esm/components/status/status.d.ts +6 -6
- package/dist/esm/extensions/reactiveForm/reactiveFormItem.js +1 -0
- package/extensions/curd.cjs +5 -5
- package/extensions/documentViewer.cjs +5 -5
- package/extensions/textFormatter.cjs +5 -5
- package/package.json +1 -1
- package/documentation/dist/assets/index-DvrKS6Tv.js +0 -7747
- package/documentation/dist/atom-one-dark.min.css +0 -1
- package/documentation/dist/components/accordion.md +0 -38
- package/documentation/dist/components/actionSheet.md +0 -49
- package/documentation/dist/components/alert.md +0 -38
- package/documentation/dist/components/anchorList.md +0 -36
- package/documentation/dist/components/autocomplete.md +0 -68
- package/documentation/dist/components/avatar.md +0 -79
- package/documentation/dist/components/badge.md +0 -33
- package/documentation/dist/components/bottomNavigation.md +0 -39
- package/documentation/dist/components/breadcrumb.md +0 -28
- package/documentation/dist/components/bubbleConfirm.md +0 -34
- package/documentation/dist/components/button.md +0 -62
- package/documentation/dist/components/card.md +0 -30
- package/documentation/dist/components/cascade.md +0 -48
- package/documentation/dist/components/checkbox.md +0 -36
- package/documentation/dist/components/colorPicker.md +0 -27
- package/documentation/dist/components/contextMenu.md +0 -27
- package/documentation/dist/components/counter.md +0 -29
- package/documentation/dist/components/dataGrid.md +0 -112
- package/documentation/dist/components/dateTimePicker.md +0 -35
- package/documentation/dist/components/dateTimeRangePicker.md +0 -36
- package/documentation/dist/components/descriptions.md +0 -35
- package/documentation/dist/components/dialog.md +0 -56
- package/documentation/dist/components/divider.md +0 -26
- package/documentation/dist/components/drawer.md +0 -40
- package/documentation/dist/components/flex.md +0 -20
- package/documentation/dist/components/form.md +0 -131
- package/documentation/dist/components/formDialog.md +0 -36
- package/documentation/dist/components/grid.md +0 -34
- package/documentation/dist/components/highlight.md +0 -26
- package/documentation/dist/components/image.md +0 -90
- package/documentation/dist/components/input.md +0 -39
- package/documentation/dist/components/loading.md +0 -46
- package/documentation/dist/components/menu.md +0 -85
- package/documentation/dist/components/pagination.md +0 -38
- package/documentation/dist/components/pickerDialog.md +0 -56
- package/documentation/dist/components/placeholder.md +0 -30
- package/documentation/dist/components/progress.md +0 -43
- package/documentation/dist/components/radio.md +0 -37
- package/documentation/dist/components/rating.md +0 -35
- package/documentation/dist/components/resizable.md +0 -41
- package/documentation/dist/components/scrollbar.md +0 -31
- package/documentation/dist/components/segmented.md +0 -57
- package/documentation/dist/components/select.md +0 -30
- package/documentation/dist/components/skeleton.md +0 -26
- package/documentation/dist/components/slidableActions.md +0 -53
- package/documentation/dist/guide/appComponent.md +0 -30
- package/documentation/dist/guide/globalMethods.md +0 -238
- package/documentation/dist/guide/icon.md +0 -57
- package/documentation/dist/guide/introduction.md +0 -2
- package/documentation/dist/guide/overrideProps.md +0 -0
- package/documentation/dist/guide/startup.md +0 -23
- package/documentation/dist/guide/theme.md +0 -249
- package/documentation/dist/index.html +0 -13
- package/documentation/dist/logo.png +0 -0
|
@@ -1,249 +0,0 @@
|
|
|
1
|
-
# 自定义主题
|
|
2
|
-
|
|
3
|
-
## <ThemeProvider\/>
|
|
4
|
-
|
|
5
|
-
如果你使用了[<App\/>](appComponent)(入口组件),则入口组件也包含了themeProvider的功能:
|
|
6
|
-
|
|
7
|
-
```tsx no-preview
|
|
8
|
-
import {App, ThemeDefinition} from '@canlooks/can-ui'
|
|
9
|
-
|
|
10
|
-
export default function Index() {
|
|
11
|
-
const theme: ThemeDefinition = {
|
|
12
|
-
colors: {
|
|
13
|
-
primary: '#1E71EC'
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
return (
|
|
18
|
-
<App theme={theme}>
|
|
19
|
-
{/* ... */}
|
|
20
|
-
</App>
|
|
21
|
-
)
|
|
22
|
-
}
|
|
23
|
-
```
|
|
24
|
-
|
|
25
|
-
## ThemeDefinition
|
|
26
|
-
|
|
27
|
-
| 属性 | 类型 |
|
|
28
|
-
|--------------|----------------------------|
|
|
29
|
-
| mode | 'light' \| 'dark' |
|
|
30
|
-
| fontSize | number |
|
|
31
|
-
| fontFamily | string |
|
|
32
|
-
| size | string |
|
|
33
|
-
| borderRadius | number |
|
|
34
|
-
| spacing | number[] |
|
|
35
|
-
| gap | number[] |
|
|
36
|
-
| gray | (amount: number) => string |
|
|
37
|
-
| divider | string |
|
|
38
|
-
| colors | Object |
|
|
39
|
-
| text | Object |
|
|
40
|
-
| background | Object |
|
|
41
|
-
| easing | Object |
|
|
42
|
-
| breakpoints | Object |
|
|
43
|
-
| boxShadow | string[] |
|
|
44
|
-
| zoom | number |
|
|
45
|
-
|
|
46
|
-
## 默认主题定义
|
|
47
|
-
|
|
48
|
-
### light
|
|
49
|
-
|
|
50
|
-
```tsx no-preview
|
|
51
|
-
const defaultLightTheme: ThemeDefinition = {
|
|
52
|
-
mode: 'light',
|
|
53
|
-
fontSize: 14,
|
|
54
|
-
fontFamily: defaultFontFamily,
|
|
55
|
-
size: 'medium',
|
|
56
|
-
borderRadius: 6,
|
|
57
|
-
spacing: defaultSpacing,
|
|
58
|
-
gap: defaultSpacing[6],
|
|
59
|
-
gray,
|
|
60
|
-
/* divider: gray(.1), */
|
|
61
|
-
divider: '#e6e6e6',
|
|
62
|
-
colors: {
|
|
63
|
-
primary: '#1E71EC',
|
|
64
|
-
secondary: '#925CC1',
|
|
65
|
-
success: '#13C13C',
|
|
66
|
-
warning: '#ED9121',
|
|
67
|
-
error: '#DD3F3F',
|
|
68
|
-
info: '#52AEDF',
|
|
69
|
-
},
|
|
70
|
-
text: {
|
|
71
|
-
/* primary: gray(.9), */
|
|
72
|
-
primary: '#191919',
|
|
73
|
-
/* secondary: gray(.6), */
|
|
74
|
-
secondary: '#666666',
|
|
75
|
-
/* disabled: gray(.4), */
|
|
76
|
-
disabled: '#999999',
|
|
77
|
-
/* placeholder: gray(.3), */
|
|
78
|
-
placeholder: '#b3b3b3',
|
|
79
|
-
/* inverse: gray(0) */
|
|
80
|
-
inverse: '#ffffff'
|
|
81
|
-
},
|
|
82
|
-
background: {
|
|
83
|
-
content: '#ffffff',
|
|
84
|
-
/* body: gray(.04), */
|
|
85
|
-
body: '#f5f5f5',
|
|
86
|
-
fixed: 'rgba(0, 0, 0, .02)'
|
|
87
|
-
},
|
|
88
|
-
boxShadow: [
|
|
89
|
-
/* 通常用于弹框,气泡等 */
|
|
90
|
-
'3px 6px 18px rgba(0, 0, 0, .2)',
|
|
91
|
-
/* 通常用于抽屉等 */
|
|
92
|
-
'0 0 24px rgba(0, 0, 0, .2)',
|
|
93
|
-
'1px 2px 3px rgba(0, 0, 0, .2)',
|
|
94
|
-
'2px 4px 6px rgba(0, 0, 0, .2)',
|
|
95
|
-
'3px 6px 9px rgba(0, 0, 0, .2)',
|
|
96
|
-
'3px 6px 18px rgba(0, 0, 0, .2)',
|
|
97
|
-
'4px 8px 24px rgba(0, 0, 0, .2)'
|
|
98
|
-
],
|
|
99
|
-
easing: {
|
|
100
|
-
linear: 'linear',
|
|
101
|
-
ease: 'ease',
|
|
102
|
-
easeIn: 'cubic-bezier(.3, 0, .6, 0)',
|
|
103
|
-
easeOut: 'cubic-bezier(.4, 1, .7, 1)',
|
|
104
|
-
easeInOut: 'cubic-bezier(.65, 0, .35, 1)',
|
|
105
|
-
bounce: 'cubic-bezier(.5, 2, .5, .7)',
|
|
106
|
-
swing: 'cubic-bezier(.5, 3, .5, .1)'
|
|
107
|
-
},
|
|
108
|
-
breakpoints: defaultBreakpoints,
|
|
109
|
-
zoom: 1
|
|
110
|
-
}
|
|
111
|
-
```
|
|
112
|
-
|
|
113
|
-
### dark
|
|
114
|
-
|
|
115
|
-
`dark`模式定义对象除以下属性外,其余属性继承于`light`模式
|
|
116
|
-
|
|
117
|
-
```tsx no-preview
|
|
118
|
-
const defaultDarkTheme: ThemeDefinition = {
|
|
119
|
-
mode: 'dark',
|
|
120
|
-
background: {
|
|
121
|
-
content: '#333333',
|
|
122
|
-
body: '#252525',
|
|
123
|
-
fixed: 'rgba(255, 255, 255, .06)'
|
|
124
|
-
},
|
|
125
|
-
gray: rGray,
|
|
126
|
-
divider: '#5c5c5c',
|
|
127
|
-
colors: {
|
|
128
|
-
primary: '#3780EE',
|
|
129
|
-
secondary: '#9A68C6',
|
|
130
|
-
success: '#14CD40',
|
|
131
|
-
warning: '#EE9830',
|
|
132
|
-
error: '#E04D4D',
|
|
133
|
-
info: '#5AB2E0'
|
|
134
|
-
},
|
|
135
|
-
text: {
|
|
136
|
-
primary: '#e6e6e6',
|
|
137
|
-
secondary: '#b3b3b3',
|
|
138
|
-
disabled: '#808080',
|
|
139
|
-
placeholder: '#737373',
|
|
140
|
-
inverse: '#000000'
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
```
|
|
144
|
-
|
|
145
|
-
## 使用主题
|
|
146
|
-
|
|
147
|
-
### useTheme()
|
|
148
|
-
|
|
149
|
-
CanUI提供`useTheme()`hook,获取当前主题对象,
|
|
150
|
-
|
|
151
|
-
**注意:使用时的`colors`对象与定义时不同**
|
|
152
|
-
|
|
153
|
-
### Theme.Colors
|
|
154
|
-
|
|
155
|
-
使用时,`colors`对象中的每个属性均支持数字`0-10`的索引,也支持`light`、`main`、`dark`3种预设:
|
|
156
|
-
|
|
157
|
-
```tsx
|
|
158
|
-
import {Flex, useTheme} from '@canlooks/can-ui'
|
|
159
|
-
|
|
160
|
-
const height = 40
|
|
161
|
-
const color = '#fff'
|
|
162
|
-
|
|
163
|
-
export default function Index() {
|
|
164
|
-
const {colors: {primary}} = useTheme()
|
|
165
|
-
|
|
166
|
-
return (
|
|
167
|
-
<Flex width="100%" direction="column" gap={12}>
|
|
168
|
-
<Flex gap={12}>
|
|
169
|
-
<Flex flex={1} style={{background: primary.light, height}}>light</Flex>
|
|
170
|
-
<Flex flex={1} style={{background: primary.main, height, color}}>main</Flex>
|
|
171
|
-
<Flex flex={1} style={{background: primary.dark, height, color}}>dark</Flex>
|
|
172
|
-
</Flex>
|
|
173
|
-
<Flex>
|
|
174
|
-
<Flex flex={1} style={{background: primary[0], height}}>[0]</Flex>
|
|
175
|
-
<Flex flex={1} style={{background: primary[1], height}}>[1]</Flex>
|
|
176
|
-
<Flex flex={1} style={{background: primary[2], height}}>[2]</Flex>
|
|
177
|
-
<Flex flex={1} style={{background: primary[3], height}}>[3]</Flex>
|
|
178
|
-
<Flex flex={1} style={{background: primary[4], height}}>[4]</Flex>
|
|
179
|
-
<Flex flex={1} style={{background: primary[5], height, color}}>[5]</Flex>
|
|
180
|
-
<Flex flex={1} style={{background: primary[6], height, color}}>[6]</Flex>
|
|
181
|
-
<Flex flex={1} style={{background: primary[7], height, color}}>[7]</Flex>
|
|
182
|
-
<Flex flex={1} style={{background: primary[8], height, color}}>[8]</Flex>
|
|
183
|
-
<Flex flex={1} style={{background: primary[9], height, color}}>[9]</Flex>
|
|
184
|
-
<Flex flex={1} style={{background: primary[10], height, color}}>[10]</Flex>
|
|
185
|
-
</Flex>
|
|
186
|
-
</Flex>
|
|
187
|
-
)
|
|
188
|
-
}
|
|
189
|
-
```
|
|
190
|
-
|
|
191
|
-
## 动态更改主题
|
|
192
|
-
|
|
193
|
-
### 使用useState()
|
|
194
|
-
|
|
195
|
-
将[ThemeDefinition](#ThemeDefinition)使用`useState`控制即可
|
|
196
|
-
|
|
197
|
-
```tsx
|
|
198
|
-
import {Button, Card, ThemeDefinition, ThemeProvider} from '@canlooks/can-ui'
|
|
199
|
-
|
|
200
|
-
const lightTheme = {
|
|
201
|
-
mode: 'light',
|
|
202
|
-
colors: {
|
|
203
|
-
primary: '#1E71EC'
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
const darkTheme = {
|
|
208
|
-
mode: 'dark',
|
|
209
|
-
colors: {
|
|
210
|
-
primary: '#9A68C6'
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
export default function Index() {
|
|
215
|
-
const [theme, setTheme] = React.useState<ThemeDefinition>(lightTheme)
|
|
216
|
-
|
|
217
|
-
const toggleHandler = () => {
|
|
218
|
-
setTheme(theme.mode === 'light' ? darkTheme : lightTheme)
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
return (
|
|
222
|
-
<ThemeProvider theme={theme}>
|
|
223
|
-
<Card elevation={5}>
|
|
224
|
-
<Button onClick={toggleHandler}>Toggle</Button>
|
|
225
|
-
</Card>
|
|
226
|
-
</ThemeProvider>
|
|
227
|
-
)
|
|
228
|
-
}
|
|
229
|
-
```
|
|
230
|
-
|
|
231
|
-
### 使用theme.update()
|
|
232
|
-
|
|
233
|
-
`theme`对象内置`update()`方法
|
|
234
|
-
|
|
235
|
-
```tsx no-preview
|
|
236
|
-
export default function Index() {
|
|
237
|
-
const {update} = useTheme()
|
|
238
|
-
|
|
239
|
-
const changeTheme = () => {
|
|
240
|
-
update({
|
|
241
|
-
colors: {
|
|
242
|
-
primary: '#9A68C6'
|
|
243
|
-
}
|
|
244
|
-
})
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
// ...
|
|
248
|
-
}
|
|
249
|
-
```
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="utf-8">
|
|
5
|
-
<link rel="shortcut icon" href="/logo.png">
|
|
6
|
-
<meta name="viewport" content="width=device-width,initial-scale=1.0">
|
|
7
|
-
<title>Canlooks UI</title>
|
|
8
|
-
<script type="module" crossorigin src="/assets/index-DvrKS6Tv.js"></script>
|
|
9
|
-
</head>
|
|
10
|
-
<body>
|
|
11
|
-
<div id="app"></div>
|
|
12
|
-
</body>
|
|
13
|
-
</html>
|
|
Binary file
|