@@ -31,6 +31,7 @@ export default function HtmlSymbols() {
3131 const lsType = useLocalStorage ( { key : '@omatsuri/html-symbols/type' , delay : 200 } ) ;
3232 const [ query , setQuery ] = useState ( lsQuery . retrieve ( ) || '' ) ;
3333 const [ type , setType ] = useState ( lsType . retrieve ( ) || 'Most used' ) ;
34+ const [ copiedValue , setCopiedValue ] = useState ( null ) ;
3435
3536 const handleQueryChange = ( event ) => {
3637 setQuery ( event . target . value ) ;
@@ -42,31 +43,38 @@ export default function HtmlSymbols() {
4243 lsType . save ( value ) ;
4344 } ;
4445
46+ const handleCopy = ( value ) => {
47+ setCopiedValue ( value ) ;
48+ clipboard . copy ( value )
49+ }
50+
4551 const results = searchSymbols ( query , type ) . map ( ( item ) => (
4652 < tr className = { classes . item } key = { item . entity } >
4753 < td className = { classes . name } > { item . name } </ td >
4854 < td >
4955 < button
50- className = { cx ( classes . control , classes . symbol ) }
56+ className = { cx ( classes . control , classes . symbol , { [ classes . copied ] : item . symbol === copiedValue && clipboard . copied } ) }
5157 type = "button"
52- onClick = { ( ) => clipboard . copy ( item . symbol ) }
58+ onClick = { ( ) => handleCopy ( item . symbol ) }
5359 >
5460 { item . symbol }
5561 </ button >
5662 </ td >
5763
5864 < td >
5965 < button
60- className = { classes . control }
66+ className = { cx ( classes . control , { [ classes . copied ] : item . entity === copiedValue && clipboard . copied } ) }
6167 type = "button"
62- onClick = { ( ) => clipboard . copy ( item . entity ) }
68+ onClick = { ( ) => handleCopy ( item . entity ) }
6369 >
6470 { item . entity }
6571 </ button >
6672 </ td >
6773
6874 < td >
69- < button className = { classes . control } type = "button" onClick = { ( ) => clipboard . copy ( item . css ) } >
75+ < button className = { cx ( classes . control , { [ classes . copied ] : item . css === copiedValue && clipboard . copied } ) }
76+ type = "button"
77+ onClick = { ( ) => handleCopy ( item . css ) } >
7078 { item . css }
7179 </ button >
7280 </ td >
@@ -85,7 +93,7 @@ export default function HtmlSymbols() {
8593 placeholder = "Search symbols..."
8694 />
8795 </ div >
88- < table className = { cx ( classes . results , { [ classes . copied ] : clipboard . copied } ) } >
96+ < table className = { classes . results } >
8997 < thead >
9098 < tr >
9199 < th > Name</ th >
0 commit comments