Skip to content

Commit a21a1ca

Browse files
authoredJan 5, 2025··
docs: theme editor
1 parent 4a37016 commit a21a1ca

File tree

1 file changed

+29
-9
lines changed

1 file changed

+29
-9
lines changed
 

‎site/src/components/antdv-token-previewer/ColorPanel.tsx

+29-9
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@ import type { InputProps } from 'ant-design-vue';
22
import { ConfigProvider, Input, InputNumber, Select, theme } from 'ant-design-vue';
33
import classNames from 'ant-design-vue/es/_util/classNames';
44
import type { PropType } from 'vue';
5-
import { defineComponent, watchEffect, watch, computed, toRefs, ref } from 'vue';
5+
import { defineComponent, watchEffect, computed, toRefs, ref } from 'vue';
66
import { HexColorPicker, RgbaColorPicker } from '../vue-colorful';
77
import tinycolor from 'tinycolor2';
88
import makeStyle from './utils/makeStyle';
9+
import type { ValueType } from 'ant-design-vue/es/input-number/src/utils/MiniDecimal';
910

1011
const { useToken } = theme;
1112

@@ -168,24 +169,42 @@ const RgbColorInput = defineComponent({
168169
setup(props) {
169170
const { value, alpha } = toRefs(props);
170171

171-
watch(value, val => {
172-
props.onChange(val);
173-
});
174-
172+
const handleChange = (val: ValueType, key: 'r' | 'g' | 'b' | 'a') => {
173+
value.value[key] = val;
174+
props.onChange(value.value);
175+
};
175176
return () => {
176177
return (
177178
<div class="color-panel-rgba-input">
178179
<ConfigProvider theme={{ components: { InputNumber: { handleWidth: 12 } } }}>
179180
<div class="color-panel-rgba-input-part">
180-
<InputNumber min={0} max={255} size="small" v-model={[value.value.r, 'value']} />
181+
<InputNumber
182+
min={0}
183+
max={255}
184+
size="small"
185+
value={value.value.r}
186+
onChange={val => handleChange(val, 'r')}
187+
/>
181188
<div class="color-panel-mode-title">R</div>
182189
</div>
183190
<div class="color-panel-rgba-input-part">
184-
<InputNumber min={0} max={255} size="small" v-model={[value.value.g, 'value']} />
191+
<InputNumber
192+
min={0}
193+
max={255}
194+
size="small"
195+
value={value.value.g}
196+
onChange={val => handleChange(val, 'g')}
197+
/>
185198
<div class="color-panel-mode-title">G</div>
186199
</div>
187200
<div class="color-panel-rgba-input-part">
188-
<InputNumber min={0} max={255} size="small" v-model={[value.value.b, 'value']} />
201+
<InputNumber
202+
min={0}
203+
max={255}
204+
size="small"
205+
value={value.value.b}
206+
onChange={val => handleChange(val, 'b')}
207+
/>
189208
<div class="color-panel-mode-title">B</div>
190209
</div>
191210
{alpha.value && (
@@ -195,7 +214,8 @@ const RgbColorInput = defineComponent({
195214
max={1}
196215
step={0.01}
197216
size="small"
198-
v-model={[value.value.a, 'value']}
217+
value={value.value.a}
218+
onChange={val => handleChange(val, 'a')}
199219
/>
200220
<div class="color-panel-mode-title">A</div>
201221
</div>

0 commit comments

Comments
 (0)
Please sign in to comment.