Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
@cebby2420 has kindly made a desktop app that does so. This has no official affiliation with VIA, but you can find it at https://github.com/cebby2420/via-desktop.

## Useful commands
### `npm run start`
### `npm run dev`

Runs the app in the development mode.
Open http://localhost:8080 to view it in the browser.
Open http://localhost:5173 to view it in the browser.

The page will reload if you make edits.
You will also see any lint errors in the console.
Expand All @@ -23,10 +23,9 @@ Builds a static copy of your site to the `build/` folder.
Your app is ready to be deployed!


### `npm run test`
### `npm run format`

Launches the application test runner.
Run with the `--watch` flag (`npm test -- --watch`) to run in interactive watch mode.
Formats the code with prettier.

#

Expand Down
20 changes: 19 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{
"private": true,
"name": "via-app",
"license": "GPL-3.0",
"scripts": {
"dev": "node scripts/build-definitions.js && vite --force",
Expand Down Expand Up @@ -63,6 +65,7 @@
"@vitejs/plugin-react": "^3.1.0",
"concurrently": "^7.6.0",
"husky": "^8.0.3",
"prettier": "^3.3.3",
"typescript": "^5.6.2",
"vite": "^4.1.4",
"vite-plugin-html": "^3.2.0"
Expand Down
12 changes: 6 additions & 6 deletions src/Routes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@ export default () => {
const testContextState = useState({clearTestKeys: () => {}});
return (
<>
<TestContext.Provider value={testContextState}>
<GlobalStyle />
{hasHIDSupport && <UnconnectedGlobalMenu />}
<CanvasRouter />
<TestContext.Provider value={testContextState}>
<GlobalStyle />
{hasHIDSupport && <UnconnectedGlobalMenu />}
<CanvasRouter />

<Home hasHIDSupport={hasHIDSupport}>{RouteComponents}</Home>
</TestContext.Provider>
<Home hasHIDSupport={hasHIDSupport}>{RouteComponents}</Home>
</TestContext.Provider>
</>
);
};
8 changes: 4 additions & 4 deletions src/components/inputs/accent-select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ const customStyles = {
background: state.isSelected
? 'var(--color_accent)'
: state.isFocused
? 'var(--bg_control)'
: 'var(--bg_menu)',
? 'var(--bg_control)'
: 'var(--bg_menu)',
color: state.isSelected
? 'var(--color_inside-accent)'
: state.isFocused
? 'var(--color_accent)'
: 'var(--color_accent)',
? 'var(--color_accent)'
: 'var(--color_accent)',
};
},
container: (provided: any) => ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,10 @@ const VIACustomControl = (props: VIACustomControlProps) => {
const buttonOption: any[] = options || [1];
return (
<AccentButton
onClick={() =>
props.updateValue(name, ...command, buttonOption[0])
}
>Click</AccentButton>
onClick={() => props.updateValue(name, ...command, buttonOption[0])}
>
Click
</AccentButton>
);
}
case 'range': {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,9 @@ const MenuComponent = React.memo((props: any) => (
</>
));

const MenuBuilder = (elem: any) => (props: any) =>
<MenuComponent {...props} key={elem._id} elem={elem} />;
const MenuBuilder = (elem: any) => (props: any) => (
<MenuComponent {...props} key={elem._id} elem={elem} />
);

function submenuGenerator(
elem: TagWithId<VIASubmenu, VIASubmenuSlice>,
Expand Down
10 changes: 5 additions & 5 deletions src/components/panes/configure-panes/keycode.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,7 @@ import {
updateKey as updateKeyAction,
updateSelectedKey,
} from 'src/store/keymapSlice';
import {
getMacroCount,
} from 'src/store/macrosSlice';
import {getMacroCount} from 'src/store/macrosSlice';
import {
disableGlobalHotKeys,
enableGlobalHotKeys,
Expand Down Expand Up @@ -117,8 +115,10 @@ const KeycodeDesc = styled.div`
}
`;

const generateKeycodeCategories = (basicKeyToByte: Record<string, number>, numMacros: number = 16) =>
getKeycodes(numMacros).concat(getOtherMenu(basicKeyToByte));
const generateKeycodeCategories = (
basicKeyToByte: Record<string, number>,
numMacros: number = 16,
) => getKeycodes(numMacros).concat(getOtherMenu(basicKeyToByte));

const maybeFilter = <M extends Function>(maybe: boolean, filter: M) =>
maybe ? () => true : filter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,10 +184,10 @@ export const getSequenceItemComponent = (
action === RawKeycodeSequenceAction.Down
? KeycodeDownLabel
: action === RawKeycodeSequenceAction.Up
? KeycodeUpLabel
: action === RawKeycodeSequenceAction.CharacterStream
? CharacterStreamLabel
: KeycodePressLabel;
? KeycodeUpLabel
: action === RawKeycodeSequenceAction.CharacterStream
? CharacterStreamLabel
: KeycodePressLabel;

function capitalize(string: string) {
return string[0].toUpperCase() + string.slice(1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,8 @@ export const MacroEditControls: React.FC<{
{!isDelaySupported
? 'Upgrade firmware to use delays'
: !recordDelays
? 'Record Delays'
: 'Skip Recording Delays'}
? 'Record Delays'
: 'Skip Recording Delays'}
</IconButtonTooltip>
</IconToggleContainer>
</MacroControlGroupContainer>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,16 @@ const smartTransform = (
};

const componentJoin = (arr: (JSX.Element | null)[], separator: JSX.Element) => {
return arr.reduce((acc, next, idx) => {
if (idx) {
acc.push({...separator, key: idx});
}
acc.push(next);
return acc;
}, [] as (JSX.Element | null)[]);
return arr.reduce(
(acc, next, idx) => {
if (idx) {
acc.push({...separator, key: idx});
}
acc.push(next);
return acc;
},
[] as (JSX.Element | null)[],
);
};

const KeycodeMap = getKeycodes()
Expand Down Expand Up @@ -283,10 +286,10 @@ export const MacroRecorder: React.FC<{
</span>,
)
: Array.isArray(actionArg)
? actionArg
.map((k) => getSequenceLabel(KeycodeMap[k]) ?? k)
.join(' + ')
: getSequenceLabel(KeycodeMap[actionArg])}
? actionArg
.map((k) => getSequenceLabel(KeycodeMap[k]) ?? k)
.join(' + ')
: getSequenceLabel(KeycodeMap[actionArg])}
</Label>
) : (
<WaitInput
Expand Down
4 changes: 2 additions & 2 deletions src/components/panes/design.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,8 @@ function importDefinitions(
? res
: keyboardDefinitionV2ToVIADefinitionV2(res)
: isVIADefinitionV3(res)
? res
: keyboardDefinitionV3ToVIADefinitionV3(res);
? res
: keyboardDefinitionV3ToVIADefinitionV3(res);
return definition;
} else {
errors = (
Expand Down
6 changes: 1 addition & 5 deletions src/components/panes/errors.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,7 @@ const AppErrors: React.FC<{}> = ({}) => {
}) => (
<Container key={timestamp}>
{timestamp}
<ul>
{error?.split('\n').map((line) => (
<li>{line}</li>
))}
</ul>
<ul>{error?.split('\n').map((line) => <li>{line}</li>)}</ul>
<ul>
<li>Device: {productName}</li>
<li>Vid: {printId(vendorId)}</li>
Expand Down
4 changes: 2 additions & 2 deletions src/components/three-fiber/canvas-router.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,8 @@ export const NonSuspenseCanvasRouter = () => {
? !hideTerrainBG
? 'translateY(-500px)'
: !dimensions
? ''
: `translateY(${-300 + dimensions!.height / 2}px)`
? ''
: `translateY(${-300 + dimensions!.height / 2}px)`
: '',
position: hideCanvasScene && !hideTerrainBG ? 'absolute' : 'relative',
overflow: 'visible',
Expand Down
70 changes: 35 additions & 35 deletions src/components/three-fiber/unit-key/keycap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ const getMacroData = ({
label && label.length > 15
? label
: macroExpression && macroExpression.length
? macroExpression
: null;
? macroExpression
: null;

const paintEncoder = (
canvas: HTMLCanvasElement,
Expand Down Expand Up @@ -377,8 +377,8 @@ export const Keycap: React.FC<ThreeFiberKeycapProps> = React.memo((props) => {
? KeycapState.Pressed
: KeycapState.Unpressed
: hovered || selected
? KeycapState.Unpressed
: KeycapState.Pressed;
? KeycapState.Unpressed
: KeycapState.Pressed;
const [keycapZ, rotationZ] =
pressedState === KeycapState.Pressed
? [zDown, rotation[2]]
Expand All @@ -392,8 +392,8 @@ export const Keycap: React.FC<ThreeFiberKeycapProps> = React.memo((props) => {
: 'lightgrey'
: 'pink'
: pressedState === KeycapState.Unpressed
? 'lightgrey'
: 'lightgrey';
? 'lightgrey'
: 'lightgrey';

const {z, b, rotateZ, tooltipScale} = useSpring({
config: {duration: 100},
Expand All @@ -409,35 +409,35 @@ export const Keycap: React.FC<ThreeFiberKeycapProps> = React.memo((props) => {
return disabled
? [noop, noop, noop, noop]
: props.mode === DisplayMode.ConfigureColors
? [
noop,
(evt: ThreeEvent<MouseEvent>) => {
if (onPointerOver) {
onPointerOver(evt, idx);
}
},
noop,
(evt: ThreeEvent<MouseEvent>) => {
if (onPointerDown) {
onPointerDown(evt, idx);
}
},
]
: [
(evt: ThreeEvent<MouseEvent>) => onClick(evt, idx),
(evt: ThreeEvent<MouseEvent>) => {
if (onPointerOver) {
onPointerOver(evt, idx);
}
hover(true);
},
() => hover(false),
(evt: ThreeEvent<MouseEvent>) => {
if (onPointerDown) {
onPointerDown(evt, idx);
}
},
];
? [
noop,
(evt: ThreeEvent<MouseEvent>) => {
if (onPointerOver) {
onPointerOver(evt, idx);
}
},
noop,
(evt: ThreeEvent<MouseEvent>) => {
if (onPointerDown) {
onPointerDown(evt, idx);
}
},
]
: [
(evt: ThreeEvent<MouseEvent>) => onClick(evt, idx),
(evt: ThreeEvent<MouseEvent>) => {
if (onPointerOver) {
onPointerOver(evt, idx);
}
hover(true);
},
() => hover(false),
(evt: ThreeEvent<MouseEvent>) => {
if (onPointerDown) {
onPointerDown(evt, idx);
}
},
];
}, [disabled, onClick, onPointerDown, onPointerOver, hover, idx, mode]);

const AniMeshMaterial = animated.meshPhongMaterial as any;
Expand Down
4 changes: 2 additions & 2 deletions src/components/two-string/canvas-router.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ export const CanvasRouter = () => {
? !hideTerrainBG
? 'translateY(-500px)'
: !dimensions
? ''
: `translateY(${-300 + dimensions!.height / 2}px)`
? ''
: `translateY(${-300 + dimensions!.height / 2}px)`
: '',
position: hideCanvasScene && !hideTerrainBG ? 'absolute' : 'relative',
overflow: 'visible',
Expand Down
Loading