|
1 | 1 | import { useState } from 'react'; |
2 | 2 | import { Playground } from './playground/Playground'; |
3 | 3 | import { NativeEditors } from './nativeEditors/NativeEditors'; |
| 4 | +import { SaveRequiredEditor } from './saveRequiredEditor/SaveRequiredEditor'; |
4 | 5 |
|
5 | | -const pathKey = 'swdReactPath'; |
6 | | -type AppPath = 'playground' | 'nativeEditors'; |
| 6 | +const TABS = [ |
| 7 | + { |
| 8 | + label: '🍭 Playground', |
| 9 | + path: 'playground' |
| 10 | + }, |
| 11 | + { |
| 12 | + label: '🔌 Native Editors', |
| 13 | + path: 'native-editors' |
| 14 | + }, |
| 15 | + { |
| 16 | + label: '🔴 Save Required Editor', |
| 17 | + path: 'save-required-editor' |
| 18 | + } |
| 19 | +]; |
7 | 20 |
|
8 | 21 | export function App() { |
9 | | - const [path, setPath] = useState<AppPath>((localStorage[pathKey] as AppPath) || 'playground'); |
| 22 | + const [path, setPath] = useState<string>(window.location.hash?.substring(1) || 'playground'); |
10 | 23 |
|
11 | | - function changePath(path: AppPath) { |
12 | | - localStorage[pathKey] = path; |
| 24 | + function changePath(path: string) { |
| 25 | + window.location.hash = path; |
13 | 26 | setPath(path); |
14 | 27 | } |
15 | 28 |
|
16 | 29 | return ( |
17 | 30 | <> |
18 | | - <nav> |
19 | | - <h1>SWD for React Demo</h1> |
20 | | - <button onClick={() => changePath('playground')} className={path === 'playground' ? 'selected' : ''}> |
21 | | - Playground |
22 | | - </button> |
23 | | - <button onClick={() => changePath('nativeEditors')} className={path === 'nativeEditors' ? 'selected' : ''}> |
24 | | - Native editors |
25 | | - </button> |
26 | | - <a href="https://github.com/nocode-js/sequential-workflow-designer/tree/main/react" className="github"> |
27 | | - GitHub |
28 | | - </a> |
| 31 | + <nav className="title-bar"> |
| 32 | + <div className="column demo"> |
| 33 | + Select Demo:{' '} |
| 34 | + <select defaultValue={path}> |
| 35 | + {TABS.map(t => ( |
| 36 | + <option key={t.path} value={t.path} onClick={() => changePath(t.path)}> |
| 37 | + {t.label} |
| 38 | + </option> |
| 39 | + ))} |
| 40 | + </select> |
| 41 | + </div> |
| 42 | + <div className="column link"> |
| 43 | + <a href="https://github.com/nocode-js/sequential-workflow-designer/tree/main/react" className="github"> |
| 44 | + SWD for React |
| 45 | + </a> |
| 46 | + </div> |
29 | 47 | </nav> |
30 | 48 | {path === 'playground' && <Playground />} |
31 | | - {path === 'nativeEditors' && <NativeEditors />} |
| 49 | + {path === 'native-editors' && <NativeEditors />} |
| 50 | + {path === 'save-required-editor' && <SaveRequiredEditor />} |
32 | 51 | </> |
33 | 52 | ); |
34 | 53 | } |
0 commit comments