mirror of
https://github.com/SteamDeckHomebrew/decky-loader.git
synced 2026-06-17 00:37:49 +00:00
fix(motd): run prettier
This commit is contained in:
@@ -1,36 +1,37 @@
|
||||
import {useEffect, useMemo, useState} from 'react'
|
||||
import { getMotd, Motd } from '../store';
|
||||
import { useSetting } from '../utils/hooks/useSetting';
|
||||
import { DialogButton, Focusable, PanelSection } from '@decky/ui';
|
||||
import { useEffect, useMemo, useState } from 'react';
|
||||
import { FaTimes } from 'react-icons/fa';
|
||||
|
||||
import { Motd, getMotd } from '../store';
|
||||
import { useSetting } from '../utils/hooks/useSetting';
|
||||
|
||||
const SEVERITIES = {
|
||||
High: {
|
||||
color: "#bb1414",
|
||||
text: "#fff",
|
||||
color: '#bb1414',
|
||||
text: '#fff',
|
||||
},
|
||||
Medium: {
|
||||
color: "#bbbb14",
|
||||
text: "#fff",
|
||||
color: '#bbbb14',
|
||||
text: '#fff',
|
||||
},
|
||||
Low: {
|
||||
color: "#1488bb",
|
||||
text: "#fff",
|
||||
color: '#1488bb',
|
||||
text: '#fff',
|
||||
},
|
||||
};
|
||||
|
||||
const welcomeMotd: Motd = {
|
||||
id: "welcomeMotd",
|
||||
name: "Welcome to Decky!",
|
||||
id: 'welcomeMotd',
|
||||
name: 'Welcome to Decky!',
|
||||
date: Date.now().toString(),
|
||||
description: "We hope you enjoy using Decky! If you have any questions or feedback, please let us know.",
|
||||
severity: "Low",
|
||||
}
|
||||
description: 'We hope you enjoy using Decky! If you have any questions or feedback, please let us know.',
|
||||
severity: 'Low',
|
||||
};
|
||||
|
||||
export function MotdDisplay() {
|
||||
const [motd, setMotd] = useState<Motd | null>(null);
|
||||
// showWelcome will display a welcome motd, the welcome motd has an id of "welcome" and once that is saved to hiddenMotdId, it will not show again
|
||||
const [hiddenMotdId, setHiddenMotdId] = useSetting("hiddenMotdId", "showWelcome")
|
||||
const [hiddenMotdId, setHiddenMotdId] = useSetting('hiddenMotdId', 'showWelcome');
|
||||
|
||||
async function fetchMotd() {
|
||||
const motd = await getMotd();
|
||||
@@ -38,14 +39,14 @@ export function MotdDisplay() {
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
void fetchMotd();
|
||||
}, [])
|
||||
void fetchMotd();
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
if (hiddenMotdId === 'showWelcome') {
|
||||
setMotd(welcomeMotd);
|
||||
}
|
||||
}, [hiddenMotdId])
|
||||
}, [hiddenMotdId]);
|
||||
|
||||
function hideMotd() {
|
||||
if (motd) {
|
||||
@@ -62,7 +63,7 @@ export function MotdDisplay() {
|
||||
return null;
|
||||
}
|
||||
|
||||
const severity = SEVERITIES[motd?.severity || "Low"];
|
||||
const severity = SEVERITIES[motd?.severity || 'Low'];
|
||||
|
||||
return (
|
||||
<PanelSection>
|
||||
@@ -72,41 +73,40 @@ export function MotdDisplay() {
|
||||
backgroundColor: `${severity.color}33`,
|
||||
color: severity.text,
|
||||
borderColor: severity.color,
|
||||
borderWidth: "2px",
|
||||
borderStyle: "solid",
|
||||
padding: "0.7rem",
|
||||
display: "flex",
|
||||
flexDirection: "column",
|
||||
position: "relative",
|
||||
borderWidth: '2px',
|
||||
borderStyle: 'solid',
|
||||
padding: '0.7rem',
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
position: 'relative',
|
||||
}}
|
||||
>
|
||||
<div style={{ display: "flex", justifyContent: "space-between" }}>
|
||||
<span style={{ fontWeight: "bold" }}>{motd?.name}</span>
|
||||
<div style={{ display: 'flex', justifyContent: 'space-between' }}>
|
||||
<span style={{ fontWeight: 'bold' }}>{motd?.name}</span>
|
||||
<DialogButton
|
||||
style={{
|
||||
width: "1rem",
|
||||
minWidth: "1rem",
|
||||
height: "1rem",
|
||||
padding: "0",
|
||||
display: "flex",
|
||||
alignItems: "center",
|
||||
justifyContent: "center",
|
||||
position: "absolute",
|
||||
top: ".75rem",
|
||||
right: ".75rem",
|
||||
width: '1rem',
|
||||
minWidth: '1rem',
|
||||
height: '1rem',
|
||||
padding: '0',
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
justifyContent: 'center',
|
||||
position: 'absolute',
|
||||
top: '.75rem',
|
||||
right: '.75rem',
|
||||
}}
|
||||
onClick={hideMotd}
|
||||
>
|
||||
<FaTimes
|
||||
style={{
|
||||
height: ".75rem",
|
||||
height: '.75rem',
|
||||
}}
|
||||
/>
|
||||
</DialogButton>
|
||||
</div>
|
||||
<span style={{ fontSize: "0.75rem", whiteSpace: "pre-line" }}>{motd?.description}</span>
|
||||
<span style={{ fontSize: '0.75rem', whiteSpace: 'pre-line' }}>{motd?.description}</span>
|
||||
</Focusable>
|
||||
</PanelSection>
|
||||
)
|
||||
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@@ -5,10 +5,10 @@ import { FaEyeSlash } from 'react-icons/fa';
|
||||
|
||||
import { Plugin } from '../plugin';
|
||||
import { useDeckyState } from './DeckyState';
|
||||
import { MotdDisplay } from './MotdDisplay';
|
||||
import NotificationBadge from './NotificationBadge';
|
||||
import { useQuickAccessVisible } from './QuickAccessVisibleState';
|
||||
import TitleView from './TitleView';
|
||||
import { MotdDisplay } from './MotdDisplay';
|
||||
|
||||
const PluginView: FC = () => {
|
||||
const { hiddenPlugins } = useDeckyState();
|
||||
|
||||
@@ -45,7 +45,7 @@ export interface Motd {
|
||||
name: string;
|
||||
description: string;
|
||||
date: string;
|
||||
severity: "High" | "Medium" | "Low";
|
||||
severity: 'High' | 'Medium' | 'Low';
|
||||
}
|
||||
|
||||
// name: version
|
||||
|
||||
Reference in New Issue
Block a user