Skip to content
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

Feature/color picker #738

Merged
merged 10 commits into from
May 10, 2022
20 changes: 2 additions & 18 deletions src/color-picker/color-picker-panel.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { defineComponent, toRefs } from 'vue';
import useVModel from '../hooks/useVModel';
import { defineComponent } from 'vue';
import props from './props';
import ColorPanel from './panel';
import { TdColorContext } from './interfaces';
import { usePrefixClass } from '../hooks/useConfig';

export default defineComponent({
Expand All @@ -15,24 +13,10 @@ export default defineComponent({
...props,
},

setup(props) {
setup() {
const prefix = usePrefixClass();
const { value, modelValue } = toRefs(props);
const [innerValue, setInnerValue] = useVModel(value, modelValue, props.defaultValue, props.onChange);

const handleChange = (value: string, context: TdColorContext) => {
setInnerValue(value, context);
};

const handlePaletteChange = (context: TdColorContext) => {
props.onPaletteBarChange(context);
};

return {
innerValue,
prefix,
handleChange,
handlePaletteChange,
};
},
render() {
Expand Down
4 changes: 3 additions & 1 deletion src/color-picker/color-picker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,11 @@ export default defineComponent({
if (props.disabled) {
return null;
}
const newProps = { ...props };
delete newProps.onChange;
return (
<ColorPanel
{...props}
{...newProps}
disabled={props.disabled}
value={innerValue.value}
togglePopup={setVisible}
Expand Down