@moi952/decky-ui-kit 0.3.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +237 -4
- package/dist/ActionButton.d.ts +22 -0
- package/dist/ActionButton.js +77 -0
- package/dist/AnchoredDropdown.d.ts +3 -1
- package/dist/AnchoredDropdown.js +34 -14
- package/dist/CollapsibleSection.d.ts +7 -1
- package/dist/CollapsibleSection.js +39 -3
- package/dist/FieldTextInput.d.ts +2 -1
- package/dist/FieldTextInput.js +19 -5
- package/dist/InfoTable.d.ts +17 -0
- package/dist/InfoTable.js +34 -0
- package/dist/InlineConfirm.d.ts +2 -1
- package/dist/InlineConfirm.js +28 -28
- package/dist/MediaRow.d.ts +28 -0
- package/dist/MediaRow.js +175 -0
- package/dist/QrCodeButton.d.ts +12 -0
- package/dist/QrCodeButton.js +36 -0
- package/dist/ScreenshotCarousel.d.ts +14 -0
- package/dist/ScreenshotCarousel.js +149 -0
- package/dist/StatusCard.d.ts +9 -0
- package/dist/StatusCard.js +63 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.js +7 -0
- package/dist/internal/Separator.d.ts +7 -0
- package/dist/internal/Separator.js +15 -0
- package/dist/internal/focusHighlight.d.ts +16 -0
- package/dist/internal/focusHighlight.js +57 -0
- package/dist/internal/theme.d.ts +23 -0
- package/dist/internal/theme.js +73 -0
- package/dist/useRemoteJson.d.ts +6 -0
- package/dist/useRemoteJson.js +49 -0
- package/package.json +5 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,22 @@
|
|
|
1
|
+
export { ActionButton } from "./ActionButton";
|
|
2
|
+
export type { ActionButtonProps } from "./ActionButton";
|
|
1
3
|
export { AnchoredDropdown } from "./AnchoredDropdown";
|
|
2
4
|
export type { AnchoredDropdownProps } from "./AnchoredDropdown";
|
|
3
5
|
export { CollapsibleSection } from "./CollapsibleSection";
|
|
4
6
|
export type { CollapsibleSectionProps } from "./CollapsibleSection";
|
|
5
7
|
export { FieldTextInput } from "./FieldTextInput";
|
|
6
8
|
export type { FieldTextInputProps } from "./FieldTextInput";
|
|
9
|
+
export { InfoTable } from "./InfoTable";
|
|
10
|
+
export type { InfoTableProps, InfoTableRow } from "./InfoTable";
|
|
7
11
|
export { InlineConfirm } from "./InlineConfirm";
|
|
8
12
|
export type { InlineConfirmProps } from "./InlineConfirm";
|
|
13
|
+
export { MediaRow } from "./MediaRow";
|
|
14
|
+
export type { MediaRowProps } from "./MediaRow";
|
|
15
|
+
export { QrCodeButton } from "./QrCodeButton";
|
|
16
|
+
export type { QrCodeButtonProps } from "./QrCodeButton";
|
|
17
|
+
export { ScreenshotCarousel } from "./ScreenshotCarousel";
|
|
18
|
+
export type { ScreenshotCarouselProps } from "./ScreenshotCarousel";
|
|
19
|
+
export { StatusCard } from "./StatusCard";
|
|
20
|
+
export type { StatusCardProps } from "./StatusCard";
|
|
21
|
+
export { useRemoteJson } from "./useRemoteJson";
|
|
22
|
+
export type { UseRemoteJsonResult } from "./useRemoteJson";
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
1
|
+
export { ActionButton } from "./ActionButton";
|
|
1
2
|
export { AnchoredDropdown } from "./AnchoredDropdown";
|
|
2
3
|
export { CollapsibleSection } from "./CollapsibleSection";
|
|
3
4
|
export { FieldTextInput } from "./FieldTextInput";
|
|
5
|
+
export { InfoTable } from "./InfoTable";
|
|
4
6
|
export { InlineConfirm } from "./InlineConfirm";
|
|
7
|
+
export { MediaRow } from "./MediaRow";
|
|
8
|
+
export { QrCodeButton } from "./QrCodeButton";
|
|
9
|
+
export { ScreenshotCarousel } from "./ScreenshotCarousel";
|
|
10
|
+
export { StatusCard } from "./StatusCard";
|
|
11
|
+
export { useRemoteJson } from "./useRemoteJson";
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
// A continuous list's own row divider — a real, independent element, not
|
|
3
|
+
// a row's own `border-bottom`. A border always follows its own box's
|
|
4
|
+
// border-radius (curving in right at each corner it meets), so drawing
|
|
5
|
+
// the divider that way forced every bottomSeparator row to keep its own
|
|
6
|
+
// bottom corners perfectly square just to keep this line straight. A
|
|
7
|
+
// separate sibling element instead is flat no matter what radius the
|
|
8
|
+
// row itself uses.
|
|
9
|
+
export const DIVIDER_COLOR = "rgba(255, 255, 255, 0.08)";
|
|
10
|
+
export const Separator = ({ marginTop = 0, marginBottom = 0 }) => (_jsx("div", { style: {
|
|
11
|
+
height: 1,
|
|
12
|
+
marginTop,
|
|
13
|
+
marginBottom,
|
|
14
|
+
background: DIVIDER_COLOR,
|
|
15
|
+
} }));
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { CSSProperties } from "react";
|
|
2
|
+
import { DEFAULT_HIGHLIGHT_BACKGROUND, DEFAULT_HIGHLIGHT_COLOR } from "./theme";
|
|
3
|
+
export { DEFAULT_HIGHLIGHT_COLOR, DEFAULT_HIGHLIGHT_BACKGROUND };
|
|
4
|
+
export interface FocusHighlightConfig {
|
|
5
|
+
highlightOnFocus?: boolean;
|
|
6
|
+
borderOnFocus?: boolean;
|
|
7
|
+
highlightColor?: string;
|
|
8
|
+
highlightBackground?: string;
|
|
9
|
+
borderWidth?: number;
|
|
10
|
+
hasBottomDivider?: boolean;
|
|
11
|
+
}
|
|
12
|
+
export declare function useFocusHighlightClass(prefix: string, { highlightOnFocus, borderOnFocus, highlightColor, highlightBackground, borderWidth, hasBottomDivider, }: FocusHighlightConfig): {
|
|
13
|
+
cls: string;
|
|
14
|
+
styleTag: string | null;
|
|
15
|
+
reserveBorder: CSSProperties;
|
|
16
|
+
};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { useId } from "react";
|
|
2
|
+
import { DEFAULT_HIGHLIGHT_BACKGROUND, DEFAULT_HIGHLIGHT_COLOR } from "./theme";
|
|
3
|
+
// Re-exported so existing imports of these two from this module (they
|
|
4
|
+
// used to be defined here) keep working — the values themselves now
|
|
5
|
+
// live in theme.ts, this library's one shared palette.
|
|
6
|
+
export { DEFAULT_HIGHLIGHT_COLOR, DEFAULT_HIGHLIGHT_BACKGROUND };
|
|
7
|
+
// `prefix` becomes part of the generated class name — keep it short and
|
|
8
|
+
// component-specific (e.g. "dck-media-row") so two instances' scoped
|
|
9
|
+
// styles never collide.
|
|
10
|
+
//
|
|
11
|
+
// `reserveBorder`: a real border must already be present in the
|
|
12
|
+
// element's own base style (with box-sizing: border-box, so reserving
|
|
13
|
+
// it doesn't grow the box) for `border-color` to have anything to
|
|
14
|
+
// override on focus/hover without shifting layout — MediaRow's own
|
|
15
|
+
// `color` system already reserves one (an accent border, or a
|
|
16
|
+
// transparent one at the same width otherwise), so it ignores this.
|
|
17
|
+
// A component with no border of its own (ScreenshotCarousel) spreads
|
|
18
|
+
// this into its base style instead. Always includes `boxSizing` (even
|
|
19
|
+
// when borderOnFocus is off) so spreading it never leaves a component
|
|
20
|
+
// without one.
|
|
21
|
+
export function useFocusHighlightClass(prefix, { highlightOnFocus = true, borderOnFocus = true, highlightColor = DEFAULT_HIGHLIGHT_COLOR, highlightBackground, borderWidth = 2, hasBottomDivider = false, }) {
|
|
22
|
+
const cls = `${prefix}${useId().replace(/[^a-zA-Z0-9]/g, "")}`;
|
|
23
|
+
const declarations = [
|
|
24
|
+
// !important on both — the underlying native button/div this class
|
|
25
|
+
// targets may set its own `border`/`background` inline (a real
|
|
26
|
+
// DialogButton's own base styling does), and an inline style always
|
|
27
|
+
// wins over a plain external rule regardless of selector, `!important`
|
|
28
|
+
// is the only thing that reliably overrides it either way.
|
|
29
|
+
borderOnFocus
|
|
30
|
+
? hasBottomDivider
|
|
31
|
+
? `box-shadow: inset 0 0 0 ${borderWidth}px ${highlightColor} !important;`
|
|
32
|
+
: `border-color: ${highlightColor} !important;`
|
|
33
|
+
: "",
|
|
34
|
+
highlightOnFocus && highlightBackground ? `background: ${highlightBackground} !important;` : "",
|
|
35
|
+
]
|
|
36
|
+
.filter(Boolean)
|
|
37
|
+
.join("\n ");
|
|
38
|
+
const styleTag = declarations
|
|
39
|
+
? `
|
|
40
|
+
.${cls}:focus, .${cls}:focus-within, .${cls}:hover {
|
|
41
|
+
${declarations}
|
|
42
|
+
}
|
|
43
|
+
`
|
|
44
|
+
: null;
|
|
45
|
+
const reserveBorder = {
|
|
46
|
+
boxSizing: "border-box",
|
|
47
|
+
// Not reserved at all when hasBottomDivider — that focus frame is an
|
|
48
|
+
// inset box-shadow (see above), which paints from the padding-box
|
|
49
|
+
// edge inward. Reserving a real (transparent) border here as well
|
|
50
|
+
// would push the box-shadow that same border-width further in,
|
|
51
|
+
// leaving a ring of bare background visible between the element's
|
|
52
|
+
// true outer edge and the highlight frame — exactly the "too far
|
|
53
|
+
// inside" look this avoids.
|
|
54
|
+
...(borderOnFocus && !hasBottomDivider ? { border: `${borderWidth}px solid transparent` } : {}),
|
|
55
|
+
};
|
|
56
|
+
return { cls, styleTag, reserveBorder };
|
|
57
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export declare const DEFAULT_HIGHLIGHT_COLOR = "#dcdedf";
|
|
2
|
+
export declare const DEFAULT_HIGHLIGHT_BACKGROUND = "#2a3a4a";
|
|
3
|
+
export declare const DEFAULT_PANEL_BACKGROUND = "#35373c";
|
|
4
|
+
export declare const ACCENT_SUCCESS = "#4caf50";
|
|
5
|
+
export declare const ACCENT_DANGER = "#ef4444";
|
|
6
|
+
export declare const ACCENT_INFO = "#4b9cf7";
|
|
7
|
+
export declare const ACCENT_WARNING = "#f5a623";
|
|
8
|
+
export declare const DEFAULT_ROUNDNESS = "var(--round-radius-size, 4px)";
|
|
9
|
+
export declare const SIZE_STYLE: {
|
|
10
|
+
readonly small: {
|
|
11
|
+
readonly fontSize: 12;
|
|
12
|
+
readonly minHeight: 33;
|
|
13
|
+
};
|
|
14
|
+
readonly medium: {
|
|
15
|
+
readonly fontSize: 14;
|
|
16
|
+
readonly minHeight: 37;
|
|
17
|
+
};
|
|
18
|
+
readonly large: {
|
|
19
|
+
readonly fontSize: 16;
|
|
20
|
+
readonly minHeight: 41;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
export type ComponentSize = keyof typeof SIZE_STYLE;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
// Shared default values across every component in this library — this
|
|
2
|
+
// package is a theme as much as a component set, so a color used as the
|
|
3
|
+
// default in more than one place lives here once instead of as N
|
|
4
|
+
// separately-hand-typed hex literals that could drift apart by accident.
|
|
5
|
+
//
|
|
6
|
+
// Only genuinely identical values get consolidated here — a component
|
|
7
|
+
// whose own default already differs on purpose (e.g. StatusCard's own
|
|
8
|
+
// success/error greens/reds, chosen independently to match several
|
|
9
|
+
// existing Decky plugins) keeps its own constant untouched.
|
|
10
|
+
// Focus/hover — MediaRow and ScreenshotCarousel's own borderOnFocus/
|
|
11
|
+
// highlightOnFocus defaults.
|
|
12
|
+
export const DEFAULT_HIGHLIGHT_COLOR = "#dcdedf";
|
|
13
|
+
export const DEFAULT_HIGHLIGHT_BACKGROUND = "#2a3a4a";
|
|
14
|
+
// The plain "card"/trigger background — AnchoredDropdown's own default
|
|
15
|
+
// trigger fill and MediaRow's color="light" already matched this value
|
|
16
|
+
// independently before either one referenced the other.
|
|
17
|
+
export const DEFAULT_PANEL_BACKGROUND = "#35373c";
|
|
18
|
+
// The four accent/state colors — MediaRow's own color="success"/
|
|
19
|
+
// "danger"/"info"/"warning" border, and (for danger/info specifically)
|
|
20
|
+
// the exact same values InlineConfirm's own variant="danger"/"primary"
|
|
21
|
+
// already used independently before either one referenced the other.
|
|
22
|
+
export const ACCENT_SUCCESS = "#4caf50";
|
|
23
|
+
export const ACCENT_DANGER = "#ef4444";
|
|
24
|
+
export const ACCENT_INFO = "#4b9cf7";
|
|
25
|
+
export const ACCENT_WARNING = "#f5a623";
|
|
26
|
+
// Corner radius for every plain "card"/row-shaped element (MediaRow,
|
|
27
|
+
// ScreenshotCarousel's stage, InfoTable — not StatusCard's own bigger,
|
|
28
|
+
// independently-chosen 8px). `--round-radius-size` is a real CSSLoader
|
|
29
|
+
// theme hook (a "round corners" theme sets it; confirmed working
|
|
30
|
+
// end-to-end — this library's own use of it just reads whatever value
|
|
31
|
+
// such a theme provides), and 4px is the fallback for when no such theme
|
|
32
|
+
// is installed — InfoTable's own value from before this got a shared
|
|
33
|
+
// name, restored here after a fully-reverted attempt at this same thing
|
|
34
|
+
// on MediaRow/ScreenshotCarousel earlier broke their own bottomSeparator
|
|
35
|
+
// divider (see the `hasBottomDivider`/`bottomSeparator` conditional
|
|
36
|
+
// everywhere this constant is actually used — a nonzero radius clips a
|
|
37
|
+
// divider row's own straight-across `overflow:hidden` bottom border into
|
|
38
|
+
// a curve at each corner, so a divider row must ALWAYS use 0 instead,
|
|
39
|
+
// never this constant, regardless of what a theme sets).
|
|
40
|
+
export const DEFAULT_ROUNDNESS = "var(--round-radius-size, 4px)";
|
|
41
|
+
// One size scale, shared by every input-like/pressable control in this
|
|
42
|
+
// library (ActionButton, InlineConfirm's own Confirm+Cancel pair,
|
|
43
|
+
// FieldTextInput, AnchoredDropdown's own trigger) — "small"/"medium"/
|
|
44
|
+
// "large" everywhere, not "default" on some and "small"/"medium"/"large"
|
|
45
|
+
// on others. `minHeight` — a real `min-height`, NOT a fixed `height` (an
|
|
46
|
+
// earlier version of this used a fixed height instead: it guaranteed
|
|
47
|
+
// alignment for one-line content, but a button/dropdown whose label
|
|
48
|
+
// wraps to 2, 3, 4 lines had nowhere to grow into and got clipped
|
|
49
|
+
// outright, which is worse than the misalignment this was meant to
|
|
50
|
+
// fix). `min-height` avoids that: it only ever adds height when the
|
|
51
|
+
// natural content is shorter than this table's own number, and never
|
|
52
|
+
// caps it when content genuinely needs more room.
|
|
53
|
+
// For that to actually guarantee alignment across every consumer for
|
|
54
|
+
// the common one-line case, though, this table's own numbers have to be
|
|
55
|
+
// AT LEAST each consumer's own one-line natural height (padding+font-
|
|
56
|
+
// line-height+border) — smaller doesn't work, since then min-height
|
|
57
|
+
// does nothing and each consumer just renders its own different natural
|
|
58
|
+
// size again (which is exactly what happened with the previous, too-
|
|
59
|
+
// small 28/32/36 guesses). "small"'s 33px comes from real measurements
|
|
60
|
+
// (not a guess): at that size, AnchoredDropdown's own trigger needs 19px
|
|
61
|
+
// (content) + 12px (padding) + 2px (border) = 33px just to fit without
|
|
62
|
+
// squeezing its own content — the tallest of the three consumers
|
|
63
|
+
// measured, so it's the real floor for all of them (ActionButton/
|
|
64
|
+
// FieldTextInput both fit
|
|
65
|
+
// inside 33px with room to spare, not squeezed). medium/large are
|
|
66
|
+
// this same table's own 4px-per-step spacing shifted up by that same
|
|
67
|
+
// +5px correction, NOT independently measured yet — recheck them on
|
|
68
|
+
// real hardware before trusting these two specifically.
|
|
69
|
+
export const SIZE_STYLE = {
|
|
70
|
+
small: { fontSize: 12, minHeight: 33 },
|
|
71
|
+
medium: { fontSize: 14, minHeight: 37 },
|
|
72
|
+
large: { fontSize: 16, minHeight: 41 },
|
|
73
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { useEffect, useState } from "react";
|
|
2
|
+
// Module-level — shared by every component calling this hook with the
|
|
3
|
+
// same `url` in the same session, so only the first one actually fetches.
|
|
4
|
+
const cache = new Map();
|
|
5
|
+
// Fetches and JSON-parses `url` once, keeping the result in memory for
|
|
6
|
+
// `ttlMs` (default 12h) so every consumer mounting during that window
|
|
7
|
+
// reuses the same result instead of re-fetching. Never throws into the
|
|
8
|
+
// caller — a failed fetch (offline, CDN hiccup, ...) just leaves `data`
|
|
9
|
+
// null and `error` true, so a banner/list built on this can simply render
|
|
10
|
+
// nothing rather than break the page it's on.
|
|
11
|
+
export function useRemoteJson(url, ttlMs = 12 * 60 * 60 * 1000) {
|
|
12
|
+
const cached = cache.get(url);
|
|
13
|
+
const isFresh = !!cached && Date.now() - cached.fetchedAt < ttlMs;
|
|
14
|
+
const [data, setData] = useState(isFresh ? cached.data : null);
|
|
15
|
+
const [loading, setLoading] = useState(!isFresh);
|
|
16
|
+
const [error, setError] = useState(false);
|
|
17
|
+
useEffect(() => {
|
|
18
|
+
if (isFresh)
|
|
19
|
+
return;
|
|
20
|
+
let cancelled = false;
|
|
21
|
+
setLoading(true);
|
|
22
|
+
setError(false);
|
|
23
|
+
fetch(url)
|
|
24
|
+
.then((res) => {
|
|
25
|
+
if (!res.ok)
|
|
26
|
+
throw new Error(`HTTP ${res.status}`);
|
|
27
|
+
return res.json();
|
|
28
|
+
})
|
|
29
|
+
.then((json) => {
|
|
30
|
+
if (cancelled)
|
|
31
|
+
return;
|
|
32
|
+
cache.set(url, { data: json, fetchedAt: Date.now() });
|
|
33
|
+
setData(json);
|
|
34
|
+
})
|
|
35
|
+
.catch(() => {
|
|
36
|
+
if (!cancelled)
|
|
37
|
+
setError(true);
|
|
38
|
+
})
|
|
39
|
+
.finally(() => {
|
|
40
|
+
if (!cancelled)
|
|
41
|
+
setLoading(false);
|
|
42
|
+
});
|
|
43
|
+
return () => {
|
|
44
|
+
cancelled = true;
|
|
45
|
+
};
|
|
46
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
47
|
+
}, [url]);
|
|
48
|
+
return { data, loading, error };
|
|
49
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moi952/decky-ui-kit",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "Reusable UI components for Decky Loader plugins that need popups/dropdowns without triggering the native panel-remount bug",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -43,5 +43,8 @@
|
|
|
43
43
|
"steam-deck",
|
|
44
44
|
"ui",
|
|
45
45
|
"dropdown"
|
|
46
|
-
]
|
|
46
|
+
],
|
|
47
|
+
"dependencies": {
|
|
48
|
+
"qrcode.react": "^4.2.0"
|
|
49
|
+
}
|
|
47
50
|
}
|