Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: replaced a whole lot of old code and improved state management #913

Merged
merged 7 commits into from
Oct 23, 2024
Merged
2 changes: 0 additions & 2 deletions src/main/managers/Store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ const schema: Schema<StorageType> = {
darkMode: { type: "string" },
hideBluetoothExperimental: { type: "boolean" },
showDefaults: { type: "boolean" },
isStandardView: { type: "boolean" },
autoUpdate: { type: "boolean" },
},
default: {
Expand All @@ -24,7 +23,6 @@ const schema: Schema<StorageType> = {
darkMode: "system",
hideBluetoothExperimental: false,
showDefaults: false,
isStandardView: true,
autoUpdate: undefined,
},
required: [],
Expand Down
5 changes: 1 addition & 4 deletions src/renderer/component/Button/SuperkeyPicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,6 @@ function SuperkeyPicker(props: SuperkeyPickerProps) {
index,
icon,
title,
description,
isStandardViewSuperkeys,
elementActive,
superkeys,
macros,
Expand Down Expand Up @@ -230,13 +228,12 @@ function SuperkeyPicker(props: SuperkeyPickerProps) {
return (
<Style>
<div className={`superkeyAction ${elementActive ? "active" : ""} ${variant === "subtle" ? "!py-2" : ""}`}>
<div className={`superkeyTitle ${isStandardViewSuperkeys ? "standard" : "single"}`}>
<div className="superkeyTitle single">
{variant === "regular" && icon}
<Heading headingLevel={5} renderAs="h5" className={`${variant === "subtle" ? "my-0 !text-2xxs" : ""}`}>
{title}
</Heading>
</div>
{isStandardViewSuperkeys && <div className="description">{description}</div>}
<div className="superkeyButtonWrapper">
{controlDeleteButton && variant === "regular" && (
// TODO: Div with click should not exist, use Button instead!!
Expand Down
57 changes: 2 additions & 55 deletions src/renderer/modules/KeyPickerKeyboard/DualFunctionPicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,13 @@ import React, { useMemo } from "react";

// Local components
import Heading from "@Renderer/components/atoms/Heading";
import { i18n } from "@Renderer/i18n";
import { Button } from "@Renderer/components/atoms/Button";
import { Select, SelectContent, SelectItem, SelectTrigger, SelectFixedValue } from "@Renderer/components/atoms/Select";
import OSKey from "@Renderer/components/molecules/KeyTags/OSKey";

interface DualFunctionPickerProps {
keyCode: { base: number; modified: number };
onKeySelect: (value: number) => void;
activeTab: string;
isStandardView: boolean;
}

interface ModKey {
Expand All @@ -21,7 +18,7 @@ interface ModKey {
}

const DualFunctionPicker = (props: DualFunctionPickerProps) => {
const { keyCode, onKeySelect, activeTab, isStandardView } = props;
const { keyCode, onKeySelect, activeTab } = props;
const modKey: ModKey[] = useMemo(
() => [
{ name: "None ", keynum: 0 },
Expand Down Expand Up @@ -146,57 +143,7 @@ const DualFunctionPicker = (props: DualFunctionPickerProps) => {
</div>
);

const layersStdView = (
<div className="dualFuntionWrapper flex flex-wrap gap-6">
<div className="layersButtons">
<Heading headingLevel={5} renderAs="h5" className="text-ssm">
{i18n.general.layer}
</Heading>
<div className="p-1 inline-flex flex-nowrap gap-1 mt-2 w-auto rounded-md bg-white dark:bg-gray-900/20">
{layerKey.map((item: any, index: number) => (
<Button
variant="config"
size="sm"
// eslint-disable-next-line
key={`itemDualFunctionLayerSelectStd-${index}`}
onClick={() => onKeySelect(item.keynum + keyCode.base)}
selected={!!(keyCode.modified > 0 && item.keynum === keyCode.modified)}
disabled={disabled || activeTab === "super"}
className={`w-[40px] ${index === 0 ? "hidden" : ""}`}
>
{item.nameStd ? item.nameStd : item.keynum}
</Button>
))}
</div>
</div>
<div className="modButtons">
<Heading headingLevel={5} renderAs="h5" className="text-ssm">
{i18n.general.modifier}
</Heading>
<div className="p-1 inline-flex flex-nowrap gap-1 mt-2 w-auto rounded-md bg-white dark:bg-gray-900/20">
{modKey.map((item, index) => (
<Button
variant="config"
size="sm"
// eslint-disable-next-line
key={`itemDualFunctionModifierSelectStd-${index}`}
onClick={() => onKeySelect(item.keynum + keyCode.base)}
selected={!!(keyCode.modified > 0 && item.keynum === keyCode.modified)}
disabled={disabled || activeTab === "super"}
className={`w-[60px] ${index === 0 ? "hidden" : ""}`}
>
<OSKey
renderKey={item.nameStd ? item.nameStd : "shift"}
size={item.nameStd === "control" || item.nameStd === "altGr" ? "sm" : "md"}
/>
</Button>
))}
</div>
</div>
</div>
);

return <div>{isStandardView ? layersStdView : layers}</div>;
return <div>{layers}</div>;
};

export default DualFunctionPicker;
15 changes: 4 additions & 11 deletions src/renderer/modules/KeyPickerKeyboard/Key.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
/* eslint-disable eqeqeq */
/* eslint-disable react/jsx-filename-extension */
// @ts-nocheck
import React from "react";
import Styled, { withTheme } from "styled-components";
import { SegmentedKeyType } from "@Renderer/types/layout";
import { SelectGenericKeys } from "@Renderer/components/molecules/CustomSelect";
import OSKey from "@Renderer/components/molecules/KeyTags/OSKey";

const Style = Styled.g`
.keycap {
Expand Down Expand Up @@ -364,9 +362,10 @@ interface KeyProps {
third: string;
fourth: string;
};
idArray: string;
idArray: string | number[];
disabled: boolean;
platform: string;
theme?: any;
}

interface KeyLabelProps {
Expand Down Expand Up @@ -495,12 +494,9 @@ function Key(props: KeyProps) {
>
<div xmlns="http://www.w3.org/1999/xhtml">
<SelectGenericKeys
x={x + ksl[content.type].outb.dx}
y={y + ksl[content.type].outb.dy}
onSelect={onKeyPress}
selected={selected}
value={id}
listElements={idArray}
listElements={idArray as number[]}
content={content}
keyCode={keyCode}
label="F13+"
Expand All @@ -520,12 +516,9 @@ function Key(props: KeyProps) {
>
<div xmlns="http://www.w3.org/1999/xhtml">
<SelectGenericKeys
x={x + ksl[content.type].outb.dx}
y={y + ksl[content.type].outb.dy}
onSelect={onKeyPress}
selected={selected}
value={id}
listElements={idArray}
listElements={idArray as number[]}
content={content}
keyCode={keyCode}
label={content.first}
Expand Down
Loading
Loading