Skip to content

Commit

Permalink
Make frameworks a list
Browse files Browse the repository at this point in the history
  • Loading branch information
vanpelt authored Apr 3, 2024
1 parent 094509c commit 0282ec0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 35 deletions.
46 changes: 11 additions & 35 deletions frontend/src/components/CodeViewer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
convertFrameworkAtom,
historyAtomFamily,
selectedFrameworkAtom,
FRAMEWORKS,
type Framework
} from 'state'
import { downloadStringAsFile } from '../lib/utils'
Expand Down Expand Up @@ -146,41 +147,16 @@ export default function CodeViewer({ id, code, shared }: ViewerProps) {
<DropdownMenuContent side='top'>
<DropdownMenuLabel>Convert to</DropdownMenuLabel>
<DropdownMenuSeparator />
<DropdownMenuItem
onClick={() => {
setConvertFramework('web component')
}}
>
Web Component
</DropdownMenuItem>
<DropdownMenuItem
onClick={() => {
setConvertFramework('react')
}}
>
React
</DropdownMenuItem>
<DropdownMenuItem
onClick={() => {
setConvertFramework('preact')
}}
>
Preact
</DropdownMenuItem>
<DropdownMenuItem
onClick={() => {
setConvertFramework('svelte')
}}
>
Svelte
</DropdownMenuItem>
<DropdownMenuItem
onClick={() => {
setConvertFramework('vue')
}}
>
Vue
</DropdownMenuItem>
{FRAMEWORKS.map(f => (
<DropdownMenuItem
key={f}
onClick={() => {
setConvertFramework(f)
}}
>
{f.toLocaleUpperCase()}
</DropdownMenuItem>
))}
</DropdownMenuContent>
</DropdownMenu>
</li>
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/state/atoms/history.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ export type Framework =
| 'vue'
| 'web component'

export const FRAMEWORKS: Framework[] = ['preact', 'react', 'svelte', 'vue', 'web component'];

export type FrameworkMap = {
[K in Framework]?: string
}
Expand Down

0 comments on commit 0282ec0

Please sign in to comment.