diff --git a/web-app/app/routes/layout-editor.tsx b/web-app/app/routes/layout-editor.tsx index 0110bc3..d1c5759 100644 --- a/web-app/app/routes/layout-editor.tsx +++ b/web-app/app/routes/layout-editor.tsx @@ -11,8 +11,8 @@ import KLElayout from '../layout.json' type Key = { id: number - amux?: number - amuxSelect?: number + adcChannel?: number + amuxChannel?: number width: number height: number x: number @@ -263,7 +263,9 @@ function selectRangeOfKeys(state: State, clickedKey: Key): State { function addToKeySelection(state: State, clickedKey: Key): State { return addToHistory({ ...state, - selectedKeys: new Set([...state.selectedKeys, clickedKey.id]), + selectedKeys: state.selectedKeys.has(clickedKey.id) + ? new Set([...state.selectedKeys].filter((id) => clickedKey.id !== id)) + : new Set([...state.selectedKeys, clickedKey.id]), }) } @@ -465,146 +467,165 @@ export default function Index() { return (
-
-
- {state.layout.length === 0 && ( -
- setState((state) => addFirstKey(state))} - /> -
- )} - {state.layout.map((key) => ( -
- {canAdd(state, key, 'top') && ( +
+
+
+ {state.layout.length === 0 && ( +
+ setState((state) => addFirstKey(state))} + /> +
+ )} + {state.layout.map((key) => ( +
+ {canAdd(state, key, 'top') && ( +
+ setState((state) => addKey(state, key, 'top'))} + style={{ borderRadius: scaleFactor * 0.15 }} + /> +
+ )} + + {canAdd(state, key, 'right') && ( +
+ setState((state) => addKey(state, key, 'right'))} + style={{ borderRadius: scaleFactor * 0.15 }} + /> +
+ )} + + {canAdd(state, key, 'bottom') && ( +
+ setState((state) => addKey(state, key, 'bottom'))} + style={{ borderRadius: scaleFactor * 0.15 }} + /> +
+ )} + + {canAdd(state, key, 'left') && ( +
+ setState((state) => addKey(state, key, 'left'))} + style={{ borderRadius: scaleFactor * 0.15 }} + /> +
+ )} +
+ setState((state) => { + if (isCmdPressed) { + return addToKeySelection(state, key) + } + if (isShiftPressed) { + return selectRangeOfKeys(state, key) + } + return selectKey(state, key) + }) + } > - setState((state) => addKey(state, key, 'top'))} - style={{ borderRadius: scaleFactor * 0.15 }} - /> + {key.width > 1 && ( +
+ {key.width}u +
+ )}
- )} - {canAdd(state, key, 'right') && (
{ + event.stopPropagation() + setState((state) => resizeKey(state, key, 'y', true)) + }} > - setState((state) => addKey(state, key, 'right'))} - style={{ borderRadius: scaleFactor * 0.15 }} - /> +
-
- )} - {canAdd(state, key, 'bottom') && (
{ + event.stopPropagation() + setState((state) => resizeKey(state, key, 'x')) + }} > - setState((state) => addKey(state, key, 'bottom'))} - style={{ borderRadius: scaleFactor * 0.15 }} - /> +
+
- )} - {canAdd(state, key, 'left') && (
{ + event.stopPropagation() + setState((state) => resizeKey(state, key, 'y')) + }} > - setState((state) => addKey(state, key, 'left'))} - style={{ borderRadius: scaleFactor * 0.15 }} - /> +
+
- )} - -
- setState((state) => { - if (isCmdPressed) { - return addToKeySelection(state, key) - } - if (isShiftPressed) { - return selectRangeOfKeys(state, key) - } - return selectKey(state, key) - }) - } - > - {key.width > 1 &&
{key.width}u
} -
-
{ - event.stopPropagation() - setState((state) => resizeKey(state, key, 'y', true)) - }} - > -
-
-
- -
{ - event.stopPropagation() - setState((state) => resizeKey(state, key, 'x')) - }} - > -
+
-
- -
{ - event.stopPropagation() - setState((state) => resizeKey(state, key, 'y')) - }} - > -
+
+
{ + event.stopPropagation() + setState((state) => resizeKey(state, key, 'x', true)) + }} + > +
-
+
+ ))} +
+
-
{ - event.stopPropagation() - setState((state) => resizeKey(state, key, 'x', true)) - }} - > -
-
-
+
+
+ {state.layout.length} key{state.layout.length > 1 ? 's' : ''} +
+ {state.selectedKeys.size > 0 && ( +
+ {state.selectedKeys.size} key{state.selectedKeys.size > 1 ? 's' : ''} selected
- ))} + )} +
+ {Math.ceil(state.layout.length / 16)} analog demutiplexer + {Math.ceil(state.layout.length / 16) > 1 ? 's' : ''} +
- -
- {state.selectedKeys.size > 0 &&
{state.selectedKeys.size} keys selected
} -
) } @@ -614,7 +635,7 @@ function AddKey({ children, ...props }: AddKeyProps) { return (
+
diff --git a/web-app/package.json b/web-app/package.json index 013210c..efac04a 100644 --- a/web-app/package.json +++ b/web-app/package.json @@ -5,6 +5,7 @@ "version": "0.0.0", "scripts": { "build": "cross-env NODE_ENV=production react-router build", + "preview": "react-router preview", "dev": "react-router dev", "start": "cross-env NODE_ENV=production react-router-serve ./build/server/index.js", "typecheck": "react-router typegen && tsc && && eslint . && prettier --check .", diff --git a/web-app/react-router.config.ts b/web-app/react-router.config.ts index 0641032..a6ab277 100644 --- a/web-app/react-router.config.ts +++ b/web-app/react-router.config.ts @@ -2,5 +2,8 @@ import type { Config } from '@react-router/dev/config' export default { ssr: false, - basename: '/macrolev', + basename: '/macrolev/', + future: { + unstable_optimizeDeps: true, + }, } satisfies Config diff --git a/web-app/vite.config.ts b/web-app/vite.config.ts index c4e733f..cdeae59 100644 --- a/web-app/vite.config.ts +++ b/web-app/vite.config.ts @@ -8,6 +8,7 @@ export default defineConfig({ server: { port: 3000, }, + base: '/macrolev/', css: { postcss: { plugins: [tailwindcss, autoprefixer],