import { useState } from 'react' import { Light as SyntaxHighlighter } from 'react-syntax-highlighter' import js from 'react-syntax-highlighter/dist/cjs/languages/hljs/javascript' import CopyToClipboard from 'react-copy-to-clipboard' import { createUserExample, subscribeExample, readExample, createExample, updateExample, ExampleProps, } from 'data/CodeExamples' import monokaiCustomTheme from 'data/CodeEditorTheme' import { Button, IconCopy, Space, Tabs } from '@supabase/ui' SyntaxHighlighter.registerLanguage('javascript', js) const ClipboardIcon = () => ( ) const CopiedIcon = () => ( ) const CodeExamples = () => { const [example, setExample] = useState('createUserExample') const [copied, setCopied] = useState(false) type exampleListProps = { [key: string]: ExampleProps } const exampleList: exampleListProps = { createUserExample, subscribeExample, readExample, createExample, updateExample, } const lang = 'javascript' function handleClick(key: string) { setExample(key) setCopied(false) } const Buttons = () => ( {Object.values(exampleList).map((x, i) => { const length: number = Object.values(exampleList).length - 1 // const radiusStyles = { // borderBottomRightRadius: i !== length ? '0' : undefined, // borderBottomLeftRadius: i !== length ? '0' : undefined, // borderTopLeftRadius: i !== length + 1 && i !== 0 ? '0' : undefined, // borderTopRightRadius: i !== length + 1 && i !== 0 ? '0' : undefined, // } return ( ) })} ) const TabNav = () => ( handleClick(id)} activeId={example} type="underlined" > {Object.values(exampleList).map((x) => { return ( ) })} ) return (
{}

{exampleList[example].description}

setCopied(true)} >
{exampleList[example].code[lang]}
{}
) } export default CodeExamples