Skip to content

Commit

Permalink
✨ feat: 支持预区点击复制 hex
Browse files Browse the repository at this point in the history
  • Loading branch information
arvinxx committed Apr 6, 2022
1 parent e078276 commit f7a2fd4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions packages/color-picker/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"dependencies": {
"chroma-js": "^2.1.1",
"classnames": "^2.3.1",
"copy-to-clipboard": "^3.3.1",
"lodash": "^4.17.21",
"reactcss": "^1.2.3",
"rxjs": "^7.5.5",
Expand Down
10 changes: 9 additions & 1 deletion packages/color-picker/src/components/Previewer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import type { FC } from 'react';
import React, { memo } from 'react';
import reactCSS from 'reactcss';
import isEqual from 'lodash/isEqual';
import copy from 'copy-to-clipboard';

import { Checkboard } from '../common';

Expand All @@ -10,6 +11,7 @@ import type { ColorPickerProps } from '../../types';

export const Previewer: FC<ColorPickerProps> = memo(() => {
const rgba = useStore((s) => s.colorModel.rgba(), isEqual);
const hex = useStore((s) => s.colorModel.hex());

const styles: any = reactCSS({
default: {
Expand All @@ -21,6 +23,7 @@ export const Previewer: FC<ColorPickerProps> = memo(() => {
marginLeft: '4px',
borderRadius: 12,
overflow: 'hidden',
cursor: 'pointer',
},
activeColor: {
borderRadius: 12,
Expand All @@ -32,7 +35,12 @@ export const Previewer: FC<ColorPickerProps> = memo(() => {
});

return (
<div style={styles.color}>
<div
style={styles.color}
onClick={() => {
copy(hex);
}}
>
<Checkboard />
<div style={styles.activeColor} />
</div>
Expand Down

0 comments on commit f7a2fd4

Please sign in to comment.