Skip to content

fix: 修复主题编辑器中的颜色编辑器rgb模式无效#7969 #7975

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 5, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 29 additions & 9 deletions site/src/components/antdv-token-previewer/ColorPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ import type { InputProps } from 'ant-design-vue';
import { ConfigProvider, Input, InputNumber, Select, theme } from 'ant-design-vue';
import classNames from 'ant-design-vue/es/_util/classNames';
import type { PropType } from 'vue';
import { defineComponent, watchEffect, watch, computed, toRefs, ref } from 'vue';
import { defineComponent, watchEffect, computed, toRefs, ref } from 'vue';
import { HexColorPicker, RgbaColorPicker } from '../vue-colorful';
import tinycolor from 'tinycolor2';
import makeStyle from './utils/makeStyle';
import type { ValueType } from 'ant-design-vue/es/input-number/src/utils/MiniDecimal';

const { useToken } = theme;

Expand Down Expand Up @@ -168,24 +169,42 @@ const RgbColorInput = defineComponent({
setup(props) {
const { value, alpha } = toRefs(props);

watch(value, val => {
props.onChange(val);
});

const handleChange = (val: ValueType, key: 'r' | 'g' | 'b' | 'a') => {
value.value[key] = val;
props.onChange(value.value);
};
return () => {
return (
<div class="color-panel-rgba-input">
<ConfigProvider theme={{ components: { InputNumber: { handleWidth: 12 } } }}>
<div class="color-panel-rgba-input-part">
<InputNumber min={0} max={255} size="small" v-model={[value.value.r, 'value']} />
<InputNumber
min={0}
max={255}
size="small"
value={value.value.r}
onChange={val => handleChange(val, 'r')}
/>
<div class="color-panel-mode-title">R</div>
</div>
<div class="color-panel-rgba-input-part">
<InputNumber min={0} max={255} size="small" v-model={[value.value.g, 'value']} />
<InputNumber
min={0}
max={255}
size="small"
value={value.value.g}
onChange={val => handleChange(val, 'g')}
/>
<div class="color-panel-mode-title">G</div>
</div>
<div class="color-panel-rgba-input-part">
<InputNumber min={0} max={255} size="small" v-model={[value.value.b, 'value']} />
<InputNumber
min={0}
max={255}
size="small"
value={value.value.b}
onChange={val => handleChange(val, 'b')}
/>
<div class="color-panel-mode-title">B</div>
</div>
{alpha.value && (
Expand All @@ -195,7 +214,8 @@ const RgbColorInput = defineComponent({
max={1}
step={0.01}
size="small"
v-model={[value.value.a, 'value']}
value={value.value.a}
onChange={val => handleChange(val, 'a')}
/>
<div class="color-panel-mode-title">A</div>
</div>
Expand Down