Skip to content

Commit

Permalink
add components for version section
Browse files Browse the repository at this point in the history
  • Loading branch information
aarron-lee committed Jan 5, 2024
1 parent cc28436 commit 8017340
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 3 deletions.
42 changes: 41 additions & 1 deletion src/components/HhdComponent.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
import { VFC } from "react";
import { SettingType, SettingsType } from "../redux-modules/hhdSlice";
import { PanelSection, ToggleField } from "decky-frontend-lib";
import {
ButtonItem,
Field,
PanelSection,
PanelSectionRow,
ToggleField,
} from "decky-frontend-lib";
import HhdSlider from "./HhdSlider";
import { get } from "lodash";
import HhdDropdown from "./HhdDropdown";
Expand Down Expand Up @@ -175,6 +181,40 @@ const HhdComponent: VFC<HhdComponentType> = ({
);
}

if (type === "display" && title) {
// show info, shouldn't be interactive
const value = get(state, `${statePath}`);

if (!value) {
return null;
}

return (
<Field disabled label={title}>
{value}
</Field>
);
}

if (type === "action" && title) {
return (
<PanelSectionRow>
<ButtonItem
onClick={() => updateState(`${statePath}`, true)}
style={{
width: "100%",
display: "flex",
justifyContent: "center",
alignItems: "center",
}}
layout={"below"}
>
{title}
</ButtonItem>
</PanelSectionRow>
);
}

return null;
};

Expand Down
5 changes: 4 additions & 1 deletion src/components/HhdState.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,15 @@ const HhdState = () => {
return (
<div>
{Object.entries(settings).map(([topLevelStr, plugins], topIdx) => {
if (topLevelStr === "version" || topLevelStr === "hhd") {
if (topLevelStr === "version") {
return null;
}
return (
<div key={topIdx}>
{Object.keys(plugins).map((pluginName, idx) => {
if (topLevelStr === "hhd" && pluginName === "http") {
return null;
}
const plugin = plugins[pluginName] as SettingsType;
const statePath = `${topLevelStr}.${pluginName}`;

Expand Down
4 changes: 3 additions & 1 deletion src/redux-modules/hhdSlice.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ export type SettingType =
| "mode"
| "discrete"
| "multiple"
| "int";
| "int"
| "display"
| "action";

export type SettingsType = {
type: SettingType;
Expand Down

0 comments on commit 8017340

Please sign in to comment.