提交 | 用户 | age
|
ed41e5
|
1 |
<template> |
V |
2 |
<div :class="prefixCls"> |
|
3 |
<template v-for="color in colorList || []" :key="color"> |
|
4 |
<span |
|
5 |
@click="handleClick(color)" |
|
6 |
:class="[ |
|
7 |
`${prefixCls}__item`, |
|
8 |
{ |
|
9 |
[`${prefixCls}__item--active`]: def === color, |
|
10 |
}, |
|
11 |
]" |
|
12 |
:style="{ background: color }" |
|
13 |
> |
|
14 |
<CheckOutlined /> |
|
15 |
</span> |
|
16 |
</template> |
|
17 |
</div> |
|
18 |
</template> |
|
19 |
<script lang="ts"> |
|
20 |
import { defineComponent, PropType } from 'vue'; |
|
21 |
import { CheckOutlined } from '@ant-design/icons-vue'; |
|
22 |
|
|
23 |
import { useDesign } from '/@/hooks/web/useDesign'; |
|
24 |
|
|
25 |
import { baseHandler } from '../handler'; |
|
26 |
import { HandlerEnum } from '../enum'; |
|
27 |
|
|
28 |
export default defineComponent({ |
5b8eb4
|
29 |
name: 'ThemeColorPicker', |
ed41e5
|
30 |
components: { CheckOutlined }, |
V |
31 |
props: { |
|
32 |
colorList: { |
|
33 |
type: Array as PropType<string[]>, |
|
34 |
defualt: [], |
|
35 |
}, |
|
36 |
event: { |
|
37 |
type: Number as PropType<HandlerEnum>, |
|
38 |
default: () => {}, |
|
39 |
}, |
|
40 |
def: { |
|
41 |
type: String, |
|
42 |
}, |
|
43 |
}, |
|
44 |
setup(props) { |
|
45 |
const { prefixCls } = useDesign('setting-theme-picker'); |
|
46 |
|
|
47 |
function handleClick(color: string) { |
|
48 |
props.event && baseHandler(props.event, color); |
|
49 |
} |
|
50 |
return { |
|
51 |
prefixCls, |
|
52 |
handleClick, |
|
53 |
}; |
|
54 |
}, |
|
55 |
}); |
|
56 |
</script> |
|
57 |
<style lang="less"> |
|
58 |
@prefix-cls: ~'@{namespace}-setting-theme-picker'; |
|
59 |
|
|
60 |
.@{prefix-cls} { |
|
61 |
display: flex; |
|
62 |
flex-wrap: wrap; |
|
63 |
margin: 16px 0; |
|
64 |
justify-content: space-around; |
|
65 |
|
|
66 |
&__item { |
|
67 |
width: 20px; |
|
68 |
height: 20px; |
|
69 |
cursor: pointer; |
|
70 |
border: 1px solid #ddd; |
|
71 |
border-radius: 2px; |
|
72 |
|
|
73 |
svg { |
|
74 |
display: none; |
|
75 |
} |
|
76 |
|
|
77 |
&--active { |
|
78 |
border: 1px solid lighten(@primary-color, 10%); |
|
79 |
|
|
80 |
svg { |
|
81 |
display: inline-block; |
|
82 |
margin: 0 0 3px 3px; |
|
83 |
font-size: 12px; |
|
84 |
fill: @white !important; |
|
85 |
} |
|
86 |
} |
|
87 |
} |
|
88 |
} |
|
89 |
</style> |