({
theme,
children,
}: {
theme: Record<string, any>;
children: ReactNode | undefined;
})
| 141 | }; |
| 142 | |
| 143 | const CodePreview = ({ |
| 144 | theme, |
| 145 | children, |
| 146 | }: { |
| 147 | theme: Record<string, any>; |
| 148 | children: ReactNode | undefined; |
| 149 | }) => { |
| 150 | const [copied, setCopied] = useState(false); |
| 151 | |
| 152 | const getColorScheme = () => { |
| 153 | return JSON.stringify( |
| 154 | { |
| 155 | colors: theme, |
| 156 | }, |
| 157 | null, |
| 158 | 2 |
| 159 | ); |
| 160 | }; |
| 161 | |
| 162 | const onCopy = () => { |
| 163 | navigator.clipboard.writeText(getColorScheme()); |
| 164 | setCopied(true); |
| 165 | |
| 166 | setTimeout(() => setCopied(false), 1000); |
| 167 | }; |
| 168 | |
| 169 | return ( |
| 170 | <div> |
| 171 | <div className="color-picker-schema-copy-header"> |
| 172 | <h4>{children}</h4> |
| 173 | <button onClick={onCopy} className="color-picker-action-button"> |
| 174 | {copied ? 'copied' : 'copy'} |
| 175 | </button> |
| 176 | </div> |
| 177 | <pre> |
| 178 | <code className="language-json">{getColorScheme()}</code> |
| 179 | </pre> |
| 180 | </div> |
| 181 | ); |
| 182 | }; |
| 183 | |
| 184 | let uniqColorKey = 0; |
| 185 |
nothing calls this directly
no test coverage detected
searching dependent graphs…