diff --git a/components/ExportModalTabs.jsx b/components/ExportModalTabs.jsx index 9221ac9..ce1c732 100644 --- a/components/ExportModalTabs.jsx +++ b/components/ExportModalTabs.jsx @@ -1,4 +1,5 @@ import { useState } from 'react' +import { CopyToClipboard } from 'react-copy-to-clipboard' import { Prism as SyntaxHighlighter } from 'react-syntax-highlighter' import { oneDark } from 'react-syntax-highlighter/dist/cjs/styles/prism' @@ -7,6 +8,25 @@ import { useAppContext } from '@contexts/AppContext' import styles from '@styles/ExportModalTabs.module.scss' import generateColorVariables from '@functions/generateColorVariables' +const CopyButton = ({ code }) => { + const [isFlashing, setIsFlashing] = useState(false) + const toggleIsFlashing = () => { + setIsFlashing(true) + setTimeout(() => setIsFlashing(false), 300) + } + + return ( + toggleIsFlashing()} + > + + + ) +} + export default () => { const { state } = useAppContext() const { colors } = state @@ -41,17 +61,21 @@ export default () => { tabs.map((tab, key) => { if (key !== activeButtonKey) return null + const code = colorVariables[tab.id] + return (
+ + - {colorVariables[tab.id]} + {code}
) diff --git a/styles/ExportModalTabs.module.scss b/styles/ExportModalTabs.module.scss index 46066d9..e7c4b53 100644 --- a/styles/ExportModalTabs.module.scss +++ b/styles/ExportModalTabs.module.scss @@ -28,6 +28,30 @@ .content { max-height: 250px; + position: relative; + + .copyButton { + top: 10px; + right: 10px; + display: flex; + font-weight: 600; + padding: 5px 10px; + position: absolute; + border-radius: 5px; + align-items: center; + transition: all 150ms; + background-color: #fff; + justify-content: center; + &:hover { + background-color: darken(#fff, 10%); + } + &:active { + background-color: darken(#fff, 20%); + } + &.flashing { + background-color: #2ecc71; + } + } .syntaxHighlighter { max-height: 250px;