Skip to content

Commit

Permalink
Feature/color picker (#738)
Browse files Browse the repository at this point in the history
* feat(color-picker): 新增渐变预览, 新增最近使用颜色添加操作

* feat(color-picker): 新增渐变预览, 改进增加最近使用色交互

* style(color-picker): 抽离公共逻辑文件

* fix(color-picker): color-picker, 子目录增加style相关代码

* fix(color-picker): fix: #634

fix #634

* style(color-picker): 删除demo文件中测试demo

* test(color-picker): update test files
  • Loading branch information
S-mohan authored May 10, 2022
1 parent 78aa994 commit 53e8402
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 19 deletions.
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

0 comments on commit 53e8402

Please sign in to comment.