From 77df33a13967830648ce82211112df662cbd8a38 Mon Sep 17 00:00:00 2001 From: Chandan Kumar Date: Thu, 21 Jan 2021 23:49:24 +0530 Subject: [PATCH] On-hover will show hexcode --- src/components/ColorBox/ColorBox.js | 14 +++++++++----- src/index.css | 25 +++++++++++++++++++++++-- 2 files changed, 32 insertions(+), 7 deletions(-) diff --git a/src/components/ColorBox/ColorBox.js b/src/components/ColorBox/ColorBox.js index 7d481c4..f607983 100644 --- a/src/components/ColorBox/ColorBox.js +++ b/src/components/ColorBox/ColorBox.js @@ -1,23 +1,27 @@ -import React, { useState } from "react"; -import Clipboard from "react-clipboard.js"; +import React, { useState } from 'react'; +import Clipboard from 'react-clipboard.js'; const ColorBox = ({ hexCode, colorName }) => { const [status, setStatus] = useState(colorName); + const [activeClass, setActiveClass] = useState('div-colorbox'); const setCopySuccess = () => { - setStatus("Copied"); + setStatus('Copied'); + setActiveClass('copied'); setTimeout(() => { setStatus(colorName); + setActiveClass('div-colorbox'); }, 1000); }; return (
diff --git a/src/index.css b/src/index.css index 7094682..8b8808a 100644 --- a/src/index.css +++ b/src/index.css @@ -2,7 +2,7 @@ html, body { padding: 0; margin: 0; - font-family: "Cinzel", serif; + font-family: 'Cinzel', serif; } .div-header { @@ -31,7 +31,8 @@ body { background: white; } -.div-colorbox { +.div-colorbox, +.copied { width: 250px; height: 180px; display: flex; @@ -49,6 +50,20 @@ body { transition: transform 0.1s; transform: scale(1.1); box-shadow: 0px 0px 10px gray; + font-size: 0; +} + +.copied:hover { + cursor: pointer; + transition: transform 0.1s; + transform: scale(1.1); + box-shadow: 0px 0px 10px gray; + font-size: 20px; +} + +.div-colorbox:hover:before { + font-size: 20px; + content: attr(data-hover); } .div-color-container { @@ -71,3 +86,9 @@ body { button:focus { outline: none; } + +.color-box { + background: 'none'; + border: 'none'; + font-family: 'inherit'; +}