@@ -3,7 +3,6 @@ import { html, svg } from 'lit-html';
3
3
// eslint-disable-next-line -- // @typescript-eslint/ban-ts-comment // @ts-ignore
4
4
import customProperties from '../custom-properties.module.js' ; // eslint-disable-line
5
5
// @ts -ignore-end
6
-
7
6
const properties = Object . keys ( customProperties . customProperties ) . map (
8
7
// @ts -ignore
9
8
key => ( { key : key , value : customProperties . customProperties [ key ] } )
@@ -17,22 +16,24 @@ export default {
17
16
title : 'Design/Custom properties' ,
18
17
} ;
19
18
20
- const copyToClipboard = ( text : string ) => {
21
- navigator . clipboard . writeText ( text ) ;
19
+ const copyToClipboard = ( e : Event ) => {
20
+ const button = e . target as any ;
21
+ const text = button . dataset . copyToClipboard ;
22
+ if ( text ) {
23
+ navigator . clipboard . writeText ( text ) ;
24
+ button . state = 'success' ;
25
+ }
22
26
} ;
23
27
24
28
const propertyColorTemplate = ( property : any ) => html ` < uui-table-row >
25
29
< uui-table-cell
26
30
> < div
27
31
style ="display: flex; justify-content: space-between; align-items: center; ">
28
32
${ property . key } < uui-button
29
- title ="Copy to clipboard "
33
+ data-copy-to-clipboard =${ property . key }
34
+ title ="Copy custom property to clipboard"
35
+ label="Copy custom property to clipboard"
30
36
compact
31
- @click =${ ( e : MouseEvent ) => {
32
- copyToClipboard ( property . key ) ;
33
- const button = e . target as any ;
34
- button . state = 'success' ;
35
- } }
36
37
> ${ copyIcon } </ uui-button
37
38
>
38
39
</ div > </ uui-table-cell
@@ -42,13 +43,10 @@ const propertyColorTemplate = (property: any) => html` <uui-table-row>
42
43
style ="display: flex; justify-content: space-between; align-items: center; ">
43
44
< code > ${ property . value } </ code
44
45
> < uui-button
45
- title ="Copy to clipboard "
46
+ data-copy-to-clipboard =${ property . value }
47
+ title ="Copy color value to clipboard"
48
+ label="Copy color value to clipboard"
46
49
compact
47
- @click =${ ( e : MouseEvent ) => {
48
- copyToClipboard ( property . value ) ;
49
- const button = e . target as any ;
50
- button . state = 'success' ;
51
- } }
52
50
> ${ copyIcon } </ uui-button
53
51
>
54
52
</ div >
@@ -64,13 +62,10 @@ const propertySizeTemplate = (property: any) => html` <uui-table-row>
64
62
> < div
65
63
style ="display: flex; justify-content: space-between; align-items: center; ">
66
64
${ property . key } < uui-button
67
- title ="Copy to clipboard "
65
+ data-copy-to-clipboard =${ property . key }
66
+ title ="Copy custom property to clipboard"
67
+ label="Copy custom property to clipboard"
68
68
compact
69
- @click =${ ( e : MouseEvent ) => {
70
- copyToClipboard ( property . key ) ;
71
- const button = e . target as any ;
72
- button . state = 'success' ;
73
- } }
74
69
> ${ copyIcon } </ uui-button
75
70
>
76
71
</ div > </ uui-table-cell
@@ -80,13 +75,10 @@ const propertySizeTemplate = (property: any) => html` <uui-table-row>
80
75
style ="display: flex; justify-content: space-between; align-items: center; ">
81
76
< code > ${ property . value } </ code
82
77
> < uui-button
83
- title ="Copy to clipboard "
78
+ data-copy-to-clipboard =${ property . value }
79
+ title ="Copy size value to clipboard"
80
+ label="Copy size value to clipboard"
84
81
compact
85
- @click =${ ( e : MouseEvent ) => {
86
- copyToClipboard ( property . value ) ;
87
- const button = e . target as any ;
88
- button . state = 'success' ;
89
- } }
90
82
> ${ copyIcon } </ uui-button
91
83
>
92
84
</ div >
@@ -100,7 +92,7 @@ export const Looks = () => html` <h2>Looks</h2>
100
92
</ p >
101
93
102
94
< h3 > Primary Look</ h3 >
103
- < uui-table >
95
+ < uui-table @click = ${ copyToClipboard } >
104
96
< uui-table-head >
105
97
< uui-table-head-cell > Custom property name</ uui-table-head-cell >
106
98
< uui-table-head-cell > Value</ uui-table-head-cell >
@@ -190,7 +182,7 @@ export const InterfaceColors = () => html`
190
182
properties. The fallback values are inserted automatically during build.
191
183
</ p >
192
184
193
- < uui-table >
185
+ < uui-table @click = ${ copyToClipboard } >
194
186
< uui-table-head >
195
187
< uui-table-head-cell > Custom property name</ uui-table-head-cell >
196
188
< uui-table-head-cell > Value</ uui-table-head-cell >
@@ -209,7 +201,7 @@ export const BrandColors = () => html`<h2>Colors</h2>
209
201
interface color properties. Here is an overview of colors:
210
202
</ p >
211
203
212
- < uui-table >
204
+ < uui-table @click = ${ copyToClipboard } >
213
205
< uui-table-head >
214
206
< uui-table-head-cell > Custom property name</ uui-table-head-cell >
215
207
< uui-table-head-cell > Value</ uui-table-head-cell >
@@ -223,7 +215,7 @@ export const BrandColors = () => html`<h2>Colors</h2>
223
215
export const Sizing = ( ) => html `
224
216
< h2 > Sizing</ h2 >
225
217
226
- < uui-table >
218
+ < uui-table @click = ${ copyToClipboard } >
227
219
< uui-table-head >
228
220
< uui-table-head-cell > Custom property name</ uui-table-head-cell >
229
221
< uui-table-head-cell > Value</ uui-table-head-cell >
0 commit comments