1
- import React , { useRef , useState } from 'react' ;
1
+ import React from 'react' ;
2
2
import { isUndefined } from 'lodash' ;
3
3
import { darken , lighten , readableColor , transparentize } from 'polished' ;
4
4
5
5
import { css , cx } from '@leafygreen-ui/emotion' ;
6
6
import { HTMLElementProps , StoryMetaType } from '@leafygreen-ui/lib' ;
7
- import {
8
- focusRing ,
9
- hoverRing ,
10
- transitionDuration ,
11
- typeScales ,
12
- } from '@leafygreen-ui/tokens' ;
13
- import Tooltip from '@leafygreen-ui/tooltip' ;
14
7
15
8
import palette from './palette' ;
16
9
@@ -30,31 +23,20 @@ const colorBlock = css`
30
23
padding-bottom : 100% ;
31
24
border-radius : 8px ;
32
25
cursor : pointer;
33
- transition : box-shadow ease-in-out ${ transitionDuration . default } ms;
34
- & : hover {
35
- box-shadow : ${ hoverRing . light . gray } ;
36
- }
37
- & : focus {
38
- box-shadow : ${ focusRing . light . default } ;
39
- }
40
26
` ;
41
27
42
28
const hexLabelStyle = css `
43
29
width : calc (100% - 1em );
44
30
position : absolute;
45
31
left : 50% ;
46
32
margin : auto;
47
- font-size : ${ typeScales . body1 . fontSize } px;
48
- line-height : ${ typeScales . body1 . lineHeight } px;
49
33
text-align : center;
50
34
padding : 3px 0.3rem ;
51
35
border-radius : 4px ;
52
36
transform : translate (-50% , -125% );
53
37
` ;
54
38
55
39
const nameLabelStyle = css `
56
- font-size : ${ typeScales . body1 . fontSize } px;
57
- line-height : ${ typeScales . body1 . lineHeight } px;
58
40
text-align : center;
59
41
color : ${ palette . gray . dark1 } ;
60
42
margin : auto;
@@ -82,8 +64,6 @@ interface ColorBlockProps extends HTMLElementProps<'div'> {
82
64
}
83
65
84
66
function ColorBlock ( { hue, shade, ...rest } : ColorBlockProps ) {
85
- const [ copied , setCopied ] = useState ( false ) ;
86
- const colorBlockRef = useRef < HTMLButtonElement > ( null ) ;
87
67
const name = `${ hue } ${ shade ?? '' } ` ;
88
68
89
69
let color : string ;
@@ -109,29 +89,11 @@ function ColorBlock({ hue, shade, ...rest }: ColorBlockProps) {
109
89
background-color : ${ lighten ( 0.2 , color ) } ;
110
90
` ;
111
91
112
- const copyHex = ( ) => {
113
- navigator . clipboard . writeText ( color ) ;
114
-
115
- setCopied ( true ) ;
116
-
117
- setTimeout ( ( ) => {
118
- setCopied ( false ) ;
119
- } , 1500 ) ;
120
- } ;
121
-
122
92
return (
123
93
< div className = { cx ( colorBlockWrapper , colorBlockWrapperDynamic ) } { ...rest } >
124
- < button className = { cx ( colorBlock , colorBlockColor ) } onClick = { copyHex } />
94
+ < button className = { cx ( colorBlock , colorBlockColor ) } />
125
95
< div className = { cx ( hexLabelStyle , hexLabelColor ) } > { color } </ div >
126
96
< div className = { nameLabelStyle } > { name } </ div >
127
- < Tooltip
128
- open = { copied }
129
- refEl = { colorBlockRef }
130
- usePortal = { false }
131
- spacing = { 0 }
132
- >
133
- Copied { color }
134
- </ Tooltip >
135
97
</ div >
136
98
) ;
137
99
}
@@ -162,7 +124,13 @@ export function AllColors() {
162
124
163
125
return (
164
126
< div >
165
- < ColorBlock hue = "white" name = "white" style = { { marginRight : '24px' } } />
127
+ < ColorBlock
128
+ hue = "white"
129
+ name = "white"
130
+ className = { css `
131
+ marginright : '24px' ;
132
+ ` }
133
+ />
166
134
< ColorBlock hue = "black" name = "black" />
167
135
{ hues . map ( hue => {
168
136
const hueValues = palette [ hue ] ;
0 commit comments