Skip to content
Open
Show file tree
Hide file tree
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
28 changes: 27 additions & 1 deletion packages/components/color-picker/components/panel/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ import {
GradientColorPoint,
initColorFormat,
TD_COLOR_USED_COLORS_MAX_SIZE,
useDropper,
} from '@tdesign/common-js/color-picker/index';
import { useCommonClassName, useConfig, useDefaultValue, useVModel } from '@tdesign/shared-hooks';
import { useCommonClassName, useConfig, useDefaultValue, useGlobalIcon, useVModel } from '@tdesign/shared-hooks';
import { FocusIcon as TdFocusIcon } from 'tdesign-icons-vue-next';
import props from '../../color-picker-panel-props';
import { useBaseClassName } from '../../hooks';
import type { ColorPickerChangeTrigger, TdColorPickerProps } from '../../type';
Expand Down Expand Up @@ -86,6 +88,20 @@ export default defineComponent({
setInnerRecentColors(colors);
};

const { FocusIcon } = useGlobalIcon({ FocusIcon: TdFocusIcon });

const { support, open } = useDropper();

/** 屏幕取色 */
const handleDroppper = async () => {
if (props.disabled) {
return;
}
open().then(({ sRGBHex }) => {
color.value.update(sRGBHex);
});
};

/**
* onChange
* @param trigger
Expand Down Expand Up @@ -317,6 +333,16 @@ export default defineComponent({
/>
</div>
) : null}

{support && (
<span
role="button"
class={[`${baseClassName.value}__icon`, `${baseClassName.value}__dropper`]}
onClick={handleDroppper}
>
<FocusIcon />
</span>
)}
</div>

<FormatPanel {...props} color={color.value} format={formatModel.value} onInputChange={handleInputChange} />
Expand Down
Loading