summaryrefslogtreecommitdiff
path: root/frontend/src/components
diff options
context:
space:
mode:
Diffstat (limited to 'frontend/src/components')
-rw-r--r--frontend/src/components/PluginView.tsx26
-rw-r--r--frontend/src/components/TitleView.tsx53
-rw-r--r--frontend/src/components/settings/index.tsx19
-rw-r--r--frontend/src/components/settings/pages/GeneralSettings.tsx30
-rw-r--r--frontend/src/components/store/PluginCard.tsx23
-rw-r--r--frontend/src/components/store/Store.tsx20
6 files changed, 127 insertions, 44 deletions
diff --git a/frontend/src/components/PluginView.tsx b/frontend/src/components/PluginView.tsx
index 92650fec..953abd25 100644
--- a/frontend/src/components/PluginView.tsx
+++ b/frontend/src/components/PluginView.tsx
@@ -1,37 +1,17 @@
-import { ButtonItem, DialogButton, PanelSection, PanelSectionRow, Router } from 'decky-frontend-lib';
+import { ButtonItem, PanelSection, PanelSectionRow } from 'decky-frontend-lib';
import { VFC } from 'react';
-import { FaArrowLeft, FaStore } from 'react-icons/fa';
import { useDeckyState } from './DeckyState';
const PluginView: VFC = () => {
- const { plugins, activePlugin, setActivePlugin, closeActivePlugin } = useDeckyState();
-
- const onStoreClick = () => {
- Router.CloseSideMenus();
- Router.Navigate('/decky/store');
- };
+ const { plugins, activePlugin, setActivePlugin } = useDeckyState();
if (activePlugin) {
- return (
- <div style={{ height: '100%' }}>
- <div style={{ position: 'absolute', top: '3px', left: '16px', zIndex: 20 }}>
- <DialogButton style={{ minWidth: 0, padding: '10px 12px' }} onClick={closeActivePlugin}>
- <FaArrowLeft style={{ display: 'block' }} />
- </DialogButton>
- </div>
- {activePlugin.content}
- </div>
- );
+ return <div style={{ height: '100%' }}>{activePlugin.content}</div>;
}
return (
<PanelSection>
- <div style={{ position: 'absolute', top: '3px', right: '16px', zIndex: 20 }}>
- <DialogButton style={{ minWidth: 0, padding: '10px 12px' }} onClick={onStoreClick}>
- <FaStore style={{ display: 'block' }} />
- </DialogButton>
- </div>
{plugins.map(({ name, icon }) => (
<PanelSectionRow key={name}>
<ButtonItem layout="below" onClick={() => setActivePlugin(name)}>
diff --git a/frontend/src/components/TitleView.tsx b/frontend/src/components/TitleView.tsx
index 4b4a6825..babcd316 100644
--- a/frontend/src/components/TitleView.tsx
+++ b/frontend/src/components/TitleView.tsx
@@ -1,18 +1,59 @@
-import { staticClasses } from 'decky-frontend-lib';
-import { VFC } from 'react';
+import { DialogButton, Focusable, Router, staticClasses } from 'decky-frontend-lib';
+import { CSSProperties, VFC } from 'react';
+import { FaArrowLeft, FaCog, FaStore } from 'react-icons/fa';
import { useDeckyState } from './DeckyState';
+const titleStyles: CSSProperties = {
+ display: 'flex',
+ paddingTop: '3px',
+ paddingBottom: '14px',
+ paddingRight: '16px',
+ boxShadow: 'unset',
+};
+
const TitleView: VFC = () => {
- const { activePlugin } = useDeckyState();
+ const { activePlugin, closeActivePlugin } = useDeckyState();
+
+ const onSettingsClick = () => {
+ Router.CloseSideMenus();
+ Router.Navigate('/decky/settings');
+ };
+
+ const onStoreClick = () => {
+ Router.CloseSideMenus();
+ Router.Navigate('/decky/store');
+ };
if (activePlugin === null) {
- return <div className={staticClasses.Title}>Decky</div>;
+ return (
+ <Focusable style={titleStyles} className={staticClasses.Title}>
+ <DialogButton
+ style={{ height: '28px', width: '40px', minWidth: 0, padding: '10px 12px' }}
+ onClick={onSettingsClick}
+ >
+ <FaCog style={{ marginTop: '-4px', display: 'block' }} />
+ </DialogButton>
+ <div style={{ marginRight: 'auto', flex: 0.9 }}>Decky</div>
+ <DialogButton
+ style={{ height: '28px', width: '40px', minWidth: 0, padding: '10px 12px' }}
+ onClick={onStoreClick}
+ >
+ <FaStore style={{ marginTop: '-4px', display: 'block' }} />
+ </DialogButton>
+ </Focusable>
+ );
}
return (
- <div className={staticClasses.Title} style={{ paddingLeft: '60px' }}>
- {activePlugin.name}
+ <div className={staticClasses.Title} style={titleStyles}>
+ <DialogButton
+ style={{ height: '28px', width: '40px', minWidth: 0, padding: '10px 12px' }}
+ onClick={closeActivePlugin}
+ >
+ <FaArrowLeft style={{ marginTop: '-4px', display: 'block' }} />
+ </DialogButton>
+ <div style={{ flex: 0.9 }}>{activePlugin.name}</div>
</div>
);
};
diff --git a/frontend/src/components/settings/index.tsx b/frontend/src/components/settings/index.tsx
new file mode 100644
index 00000000..d4799fa9
--- /dev/null
+++ b/frontend/src/components/settings/index.tsx
@@ -0,0 +1,19 @@
+import { SidebarNavigation } from 'decky-frontend-lib';
+
+import GeneralSettings from './pages/GeneralSettings';
+
+export default function SettingsPage() {
+ return (
+ <SidebarNavigation
+ title="Decky Settings"
+ showTitle
+ pages={[
+ {
+ title: 'General',
+ content: <GeneralSettings />,
+ route: '/decky/settings/general',
+ },
+ ]}
+ />
+ );
+}
diff --git a/frontend/src/components/settings/pages/GeneralSettings.tsx b/frontend/src/components/settings/pages/GeneralSettings.tsx
new file mode 100644
index 00000000..1cc8076d
--- /dev/null
+++ b/frontend/src/components/settings/pages/GeneralSettings.tsx
@@ -0,0 +1,30 @@
+import { DialogButton, Field, TextField } from 'decky-frontend-lib';
+import { useState } from 'react';
+import { FaShapes } from 'react-icons/fa';
+
+import { installFromURL } from '../../store/Store';
+
+export default function GeneralSettings() {
+ const [pluginURL, setPluginURL] = useState('');
+ // const [checked, setChecked] = useState(false); // store these in some kind of State instead
+ return (
+ <div>
+ {/* <Field
+ label="A Toggle with an icon"
+ icon={<FaShapes style={{ display: 'block' }} />}
+ >
+ <Toggle
+ value={checked}
+ onChange={(e) => setChecked(e)}
+ />
+ </Field> */}
+ <Field
+ label="Manual plugin install"
+ description={<TextField label={'URL'} value={pluginURL} onChange={(e) => setPluginURL(e?.target.value)} />}
+ icon={<FaShapes style={{ display: 'block' }} />}
+ >
+ <DialogButton onClick={() => installFromURL(pluginURL)}>Install</DialogButton>
+ </Field>
+ </div>
+ );
+}
diff --git a/frontend/src/components/store/PluginCard.tsx b/frontend/src/components/store/PluginCard.tsx
index 7816d1bb..28989a88 100644
--- a/frontend/src/components/store/PluginCard.tsx
+++ b/frontend/src/components/store/PluginCard.tsx
@@ -2,6 +2,7 @@ import {
DialogButton,
Dropdown,
Focusable,
+ QuickAccessTab,
Router,
SingleDropdownOption,
SuspensefulImage,
@@ -9,7 +10,7 @@ import {
} from 'decky-frontend-lib';
import { FC, useRef, useState } from 'react';
-import { StorePlugin } from './Store';
+import { StorePlugin, requestPluginInstall } from './Store';
interface PluginCardProps {
plugin: StorePlugin;
@@ -19,17 +20,6 @@ const classNames = (...classes: string[]) => {
return classes.join(' ');
};
-async function requestPluginInstall(plugin: StorePlugin, selectedVer: string) {
- const formData = new FormData();
- formData.append('artifact', plugin.artifact);
- formData.append('version', selectedVer);
- formData.append('hash', plugin.versions[selectedVer]);
- await fetch('http://localhost:1337/browser/install_plugin', {
- method: 'POST',
- body: formData,
- });
-}
-
const PluginCard: FC<PluginCardProps> = ({ plugin }) => {
const [selectedOption, setSelectedOption] = useState<number>(0);
const buttonRef = useRef<HTMLDivElement>(null);
@@ -50,9 +40,12 @@ const PluginCard: FC<PluginCardProps> = ({ plugin }) => {
buttonRef.current!.focus();
}}
onCancel={(e: CustomEvent) => {
- containerRef.current!.querySelectorAll('* :focus').length === 0
- ? Router.NavigateBackOrOpenMenu()
- : containerRef.current!.focus();
+ if (containerRef.current!.querySelectorAll('* :focus').length === 0) {
+ Router.NavigateBackOrOpenMenu();
+ setTimeout(() => Router.OpenQuickAccessMenu(QuickAccessTab.Decky), 1000);
+ } else {
+ containerRef.current!.focus();
+ }
}}
style={{
display: 'flex',
diff --git a/frontend/src/components/store/Store.tsx b/frontend/src/components/store/Store.tsx
index ebb2bb8e..0e99a3c2 100644
--- a/frontend/src/components/store/Store.tsx
+++ b/frontend/src/components/store/Store.tsx
@@ -13,6 +13,26 @@ export interface StorePlugin {
tags: string[];
}
+export async function installFromURL(url: string) {
+ const formData = new FormData();
+ formData.append('artifact', url);
+ await fetch('http://localhost:1337/browser/install_plugin', {
+ method: 'POST',
+ body: formData,
+ });
+}
+
+export async function requestPluginInstall(plugin: StorePlugin, selectedVer: string) {
+ const formData = new FormData();
+ formData.append('artifact', `https://github.com/${plugin.artifact}/archive/refs/tags/${selectedVer}.zip`);
+ formData.append('version', selectedVer);
+ formData.append('hash', plugin.versions[selectedVer]);
+ await fetch('http://localhost:1337/browser/install_plugin', {
+ method: 'POST',
+ body: formData,
+ });
+}
+
const StorePage: FC<{}> = () => {
const [data, setData] = useState<StorePlugin[] | null>(null);