@moi952/decky-ui-kit 0.2.0 → 0.4.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 +174 -0
- 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 +1 -0
- package/dist/CollapsibleSection.js +2 -1
- package/dist/FieldTextInput.d.ts +5 -1
- package/dist/FieldTextInput.js +52 -5
- package/dist/InfoTable.d.ts +17 -0
- package/dist/InfoTable.js +34 -0
- package/dist/InlineConfirm.d.ts +12 -0
- package/dist/InlineConfirm.js +44 -0
- package/dist/MediaRow.d.ts +27 -0
- package/dist/MediaRow.js +153 -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 +45 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +6 -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/package.json +1 -1
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import type { GamepadEvent } from "@decky/ui";
|
|
3
|
+
export interface MediaRowProps {
|
|
4
|
+
media?: React.ReactNode;
|
|
5
|
+
mediaWidth?: number;
|
|
6
|
+
mediaLayout?: "fixed" | "stretch";
|
|
7
|
+
mediaHeight?: number;
|
|
8
|
+
title: React.ReactNode;
|
|
9
|
+
titleLines?: number;
|
|
10
|
+
details?: React.ReactNode;
|
|
11
|
+
onPress?: () => void;
|
|
12
|
+
actions?: React.ReactNode;
|
|
13
|
+
collapsedByDefault?: boolean;
|
|
14
|
+
color: "light" | "dark" | "transparent" | "success" | "danger" | "info" | "warning";
|
|
15
|
+
accentBorderColor?: string;
|
|
16
|
+
accentBorderWidth?: number;
|
|
17
|
+
accentBackground?: string;
|
|
18
|
+
highlightOnFocus?: boolean;
|
|
19
|
+
borderOnFocus?: boolean;
|
|
20
|
+
highlightColor?: string;
|
|
21
|
+
highlightBackground?: string;
|
|
22
|
+
spacing?: number;
|
|
23
|
+
bottomSeparator?: boolean;
|
|
24
|
+
onSecondaryButton?: (evt: GamepadEvent) => void;
|
|
25
|
+
onSecondaryActionDescription?: React.ReactNode;
|
|
26
|
+
}
|
|
27
|
+
export declare const MediaRow: React.FC<MediaRowProps>;
|
package/dist/MediaRow.js
ADDED
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from "react";
|
|
3
|
+
import { DialogButton, Focusable } from "@decky/ui";
|
|
4
|
+
import { useFocusHighlightClass } from "./internal/focusHighlight";
|
|
5
|
+
import { Separator } from "./internal/Separator";
|
|
6
|
+
import { ACCENT_DANGER, ACCENT_INFO, ACCENT_SUCCESS, ACCENT_WARNING, DEFAULT_HIGHLIGHT_BACKGROUND, DEFAULT_HIGHLIGHT_COLOR, DEFAULT_PANEL_BACKGROUND, DEFAULT_ROUNDNESS, } from "./internal/theme";
|
|
7
|
+
const COLOR_STYLES = {
|
|
8
|
+
// The plain default look — reserves the same border width as every
|
|
9
|
+
// accented color below (an invisible border, not an absent one) so a
|
|
10
|
+
// row's size never shifts when it becomes accented.
|
|
11
|
+
light: { border: "transparent", background: DEFAULT_PANEL_BACKGROUND },
|
|
12
|
+
dark: { border: "transparent", background: "#202225" },
|
|
13
|
+
// Fully invisible — for a row inside a continuous divided list
|
|
14
|
+
// (bottomSeparator), which must show no card look of its own.
|
|
15
|
+
transparent: { border: "transparent", background: "transparent" },
|
|
16
|
+
success: { border: ACCENT_SUCCESS, background: "#0d1f0d" },
|
|
17
|
+
danger: { border: ACCENT_DANGER, background: "#2a0d0d" },
|
|
18
|
+
info: { border: ACCENT_INFO, background: "#0d1a2a" },
|
|
19
|
+
warning: { border: ACCENT_WARNING, background: "#2a1f0d" },
|
|
20
|
+
};
|
|
21
|
+
// A focusable media+title(+details)(+actions) row — the shape shared by
|
|
22
|
+
// "a list of apps, each with a status stack and inline action buttons"
|
|
23
|
+
// and "a grid of game capsules, each just a cover and a title" alike.
|
|
24
|
+
// Which of those two a given instance looks like follows entirely from
|
|
25
|
+
// which props are passed: `actions` opts into the header+actions-row
|
|
26
|
+
// split (with its own show/hide), `mediaLayout="stretch"` opts into a
|
|
27
|
+
// cover-image box instead of a centered icon. Neither look is "the
|
|
28
|
+
// special case" — both are just points on the same prop surface.
|
|
29
|
+
export const MediaRow = ({ media, mediaWidth = 32, mediaLayout = "fixed", mediaHeight = 32, title, titleLines = 1, details, onPress, actions, collapsedByDefault = false, color, accentBorderColor, accentBorderWidth = 2, accentBackground, highlightOnFocus = true, borderOnFocus = true, highlightColor = DEFAULT_HIGHLIGHT_COLOR, highlightBackground = DEFAULT_HIGHLIGHT_BACKGROUND, spacing = 0, bottomSeparator = false, onSecondaryButton, onSecondaryActionDescription, }) => {
|
|
30
|
+
const { cls, styleTag } = useFocusHighlightClass("dck-media-row", {
|
|
31
|
+
highlightOnFocus,
|
|
32
|
+
borderOnFocus,
|
|
33
|
+
highlightColor,
|
|
34
|
+
highlightBackground,
|
|
35
|
+
borderWidth: accentBorderWidth,
|
|
36
|
+
hasBottomDivider: bottomSeparator,
|
|
37
|
+
});
|
|
38
|
+
const hasActions = !!actions;
|
|
39
|
+
// `collapsedByDefault` always governs the initial state, `onPress` or
|
|
40
|
+
// not — a caller with both `onPress` and `actions` (the header presses
|
|
41
|
+
// through to `onPress`, so there's no in-place toggle for those rows)
|
|
42
|
+
// is expected to pick `collapsedByDefault` per row from its own data
|
|
43
|
+
// (e.g. only expanding the ones that actually need attention), not
|
|
44
|
+
// rely on this component to always force it open.
|
|
45
|
+
const [expanded, setExpanded] = useState(!collapsedByDefault || !hasActions);
|
|
46
|
+
const stretch = mediaLayout === "stretch";
|
|
47
|
+
const resolvedBorderColor = accentBorderColor ?? COLOR_STYLES[color].border;
|
|
48
|
+
const resolvedBackground = accentBackground ?? COLOR_STYLES[color].background;
|
|
49
|
+
// The card's own outer look — applied directly to whichever element
|
|
50
|
+
// ends up on the outside: the header button itself when there's no
|
|
51
|
+
// actions row (nothing else to wrap), or a containing div when there
|
|
52
|
+
// is (the actions row is that div's other child). `background`/
|
|
53
|
+
// `border` are always resolved to a real value (never omitted) — an
|
|
54
|
+
// inline style key present with value `undefined` still wins the
|
|
55
|
+
// object-spread merge against whatever default the element underneath
|
|
56
|
+
// set for that same property, so leaving either one unset would risk
|
|
57
|
+
// the browser's own native DialogButton chrome bleeding through
|
|
58
|
+
// instead of this card's own look.
|
|
59
|
+
// bottomSeparator rows use an inset box-shadow (see focusHighlight.ts)
|
|
60
|
+
// for their focus frame instead of a border-color swap, so they carry
|
|
61
|
+
// no border of their own to begin with (always "transparent" anyway,
|
|
62
|
+
// per this prop's own convention) — reserving one here regardless
|
|
63
|
+
// would push that box-shadow the same width further inward, leaving a
|
|
64
|
+
// ring of this row's own background visible between its true edge and
|
|
65
|
+
// the highlight frame.
|
|
66
|
+
const cardStyle = {
|
|
67
|
+
// Always the full shared roundness, all 4 corners, bottomSeparator
|
|
68
|
+
// row or not — the divider itself is a separate element (see
|
|
69
|
+
// Separator below), not this row's own border, so there's nothing
|
|
70
|
+
// here for a radius to clip or curve.
|
|
71
|
+
borderRadius: DEFAULT_ROUNDNESS,
|
|
72
|
+
overflow: "hidden",
|
|
73
|
+
background: resolvedBackground,
|
|
74
|
+
border: `${bottomSeparator ? 0 : accentBorderWidth}px solid ${resolvedBorderColor}`,
|
|
75
|
+
...(spacing ? { marginBottom: spacing } : {}),
|
|
76
|
+
};
|
|
77
|
+
const highlightStyle = styleTag ? _jsx("style", { children: styleTag }) : null;
|
|
78
|
+
const titleNode = (_jsx("div", { style: {
|
|
79
|
+
fontSize: 13,
|
|
80
|
+
fontWeight: 600,
|
|
81
|
+
color: "#fff",
|
|
82
|
+
...(titleLines > 1
|
|
83
|
+
? {
|
|
84
|
+
overflow: "hidden",
|
|
85
|
+
display: "-webkit-box",
|
|
86
|
+
WebkitLineClamp: titleLines,
|
|
87
|
+
WebkitBoxOrient: "vertical",
|
|
88
|
+
}
|
|
89
|
+
: {
|
|
90
|
+
overflow: "hidden",
|
|
91
|
+
textOverflow: "ellipsis",
|
|
92
|
+
whiteSpace: "nowrap",
|
|
93
|
+
}),
|
|
94
|
+
}, children: title }));
|
|
95
|
+
const mediaBox = (_jsx("div", { style: stretch
|
|
96
|
+
? {
|
|
97
|
+
position: "relative",
|
|
98
|
+
height: mediaHeight,
|
|
99
|
+
flexShrink: 0,
|
|
100
|
+
overflow: "hidden",
|
|
101
|
+
}
|
|
102
|
+
: {
|
|
103
|
+
width: mediaWidth,
|
|
104
|
+
height: mediaHeight,
|
|
105
|
+
flexShrink: 0,
|
|
106
|
+
display: "flex",
|
|
107
|
+
alignItems: "center",
|
|
108
|
+
justifyContent: "center",
|
|
109
|
+
}, children: media }));
|
|
110
|
+
const textBox = (_jsxs("div", { style: {
|
|
111
|
+
flex: 1,
|
|
112
|
+
minWidth: 0,
|
|
113
|
+
textAlign: "left",
|
|
114
|
+
...(stretch ? { display: "flex", alignItems: "center" } : {}),
|
|
115
|
+
}, children: [titleNode, details] }));
|
|
116
|
+
const handleClick = () => {
|
|
117
|
+
if (onPress)
|
|
118
|
+
onPress();
|
|
119
|
+
else if (hasActions)
|
|
120
|
+
setExpanded((v) => !v);
|
|
121
|
+
};
|
|
122
|
+
// No actions row: the header button IS the whole card — no wrapper
|
|
123
|
+
// element at all, the exact single-element structure a plain "press to
|
|
124
|
+
// open" capsule (e.g. a game cover) had before this became a shared
|
|
125
|
+
// component. Only an actions row (below) needs something to wrap.
|
|
126
|
+
if (!hasActions) {
|
|
127
|
+
return (_jsxs(_Fragment, { children: [highlightStyle, _jsxs(DialogButton, { className: cls, onClick: handleClick, onSecondaryButton: onSecondaryButton, onSecondaryActionDescription: onSecondaryActionDescription, style: {
|
|
128
|
+
...cardStyle,
|
|
129
|
+
width: "100%",
|
|
130
|
+
boxSizing: "border-box",
|
|
131
|
+
display: "flex",
|
|
132
|
+
alignItems: stretch ? "stretch" : "center",
|
|
133
|
+
gap: 10,
|
|
134
|
+
padding: stretch ? 0 : "4px 8px",
|
|
135
|
+
}, children: [mediaBox, textBox] }), bottomSeparator && _jsx(Separator, { marginTop: 1 })] }));
|
|
136
|
+
}
|
|
137
|
+
return (_jsxs(_Fragment, { children: [_jsxs("div", { className: cls, style: { width: "100%", boxSizing: "border-box", ...cardStyle }, children: [highlightStyle, _jsxs(DialogButton, { onClick: handleClick, onSecondaryButton: onSecondaryButton, onSecondaryActionDescription: onSecondaryActionDescription, style: {
|
|
138
|
+
width: "100%",
|
|
139
|
+
boxSizing: "border-box",
|
|
140
|
+
display: "flex",
|
|
141
|
+
alignItems: stretch ? "stretch" : "center",
|
|
142
|
+
gap: 10,
|
|
143
|
+
padding: stretch ? 0 : "4px 8px",
|
|
144
|
+
background: "transparent",
|
|
145
|
+
border: "none",
|
|
146
|
+
}, children: [mediaBox, textBox] }), expanded && (_jsx(Focusable, { style: {
|
|
147
|
+
display: "flex",
|
|
148
|
+
gap: 8,
|
|
149
|
+
width: "100%",
|
|
150
|
+
boxSizing: "border-box",
|
|
151
|
+
padding: "0 8px 6px",
|
|
152
|
+
}, "flow-children": "horizontal", children: actions }))] }), bottomSeparator && _jsx(Separator, { marginTop: 1 })] }));
|
|
153
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
export interface ScreenshotCarouselProps {
|
|
3
|
+
screenshots: string[];
|
|
4
|
+
height?: number;
|
|
5
|
+
bottomSeparator?: boolean;
|
|
6
|
+
highlightOnFocus?: boolean;
|
|
7
|
+
borderOnFocus?: boolean;
|
|
8
|
+
highlightColor?: string;
|
|
9
|
+
highlightBackground?: string;
|
|
10
|
+
prevActionDescription?: React.ReactNode;
|
|
11
|
+
nextActionDescription?: React.ReactNode;
|
|
12
|
+
zoomEnabled?: boolean;
|
|
13
|
+
}
|
|
14
|
+
export declare const ScreenshotCarousel: React.FC<ScreenshotCarouselProps>;
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useRef, useState } from "react";
|
|
3
|
+
import { DialogButton, Focusable, GamepadButton } from "@decky/ui";
|
|
4
|
+
import { DEFAULT_HIGHLIGHT_BACKGROUND, useFocusHighlightClass } from "./internal/focusHighlight";
|
|
5
|
+
import { Separator } from "./internal/Separator";
|
|
6
|
+
import { DEFAULT_ROUNDNESS } from "./internal/theme";
|
|
7
|
+
// A single screenshot "stage" (app store/catalog "photos", not the
|
|
8
|
+
// small square icon MediaRow already covers) — reads as one pressable
|
|
9
|
+
// card, exactly like a MediaRow instance (same rounded corners, same
|
|
10
|
+
// bottomSeparator/focus-border conventions), not a bare image. Moved
|
|
11
|
+
// with DIR_LEFT/DIR_RIGHT or LB/RB (advertised in Steam's own bottom
|
|
12
|
+
// action-legend bar) — no on-screen prev/next buttons here, those only
|
|
13
|
+
// belong in the full-screen zoom this opens on press. Steam's own focus
|
|
14
|
+
// engine navigates by on-screen geometry, not by "next in this list",
|
|
15
|
+
// so DIR_LEFT/DIR_RIGHT are handled by hand here — the same technique
|
|
16
|
+
// AnchoredDropdown's own option list uses for DIR_UP/DIR_DOWN.
|
|
17
|
+
//
|
|
18
|
+
// The zoom is an in-place overlay (a local `zoomed` boolean), NOT a real
|
|
19
|
+
// Decky modal (showModal/ModalRoot). A real modal was tried — twice,
|
|
20
|
+
// across two different pages this got embedded in, including a
|
|
21
|
+
// bHideCloseIcon + onCancel-only variant meant to rule out a suspected
|
|
22
|
+
// GenericDialog double-dismiss — and on real-device testing B still
|
|
23
|
+
// sometimes popped straight past it to the plugin's own home page, and
|
|
24
|
+
// once even left the underlying page's own B handling unresponsive
|
|
25
|
+
// afterward. A React portal onto document.body was also tried, to
|
|
26
|
+
// escape the QAM panel's own bounds — that broke gamepad navigation
|
|
27
|
+
// outright (Steam's own focus-nav system walks the real DOM, not
|
|
28
|
+
// React's, so a portaled node loses its place in the panel's own
|
|
29
|
+
// recognized nav tree). This in-place version is the one confirmed
|
|
30
|
+
// reliable on real hardware: B always closes the zoom and returns to
|
|
31
|
+
// this exact page, via the same `onCancelButton` prop every other "go
|
|
32
|
+
// back" in this library/its consuming apps already uses, and nothing
|
|
33
|
+
// else in the tree is in a position to misinterpret it, since it never
|
|
34
|
+
// leaves this component's own place in the real DOM. The trade-off is
|
|
35
|
+
// real: the zoom stays sized to the QAM panel, not the physical screen.
|
|
36
|
+
export const ScreenshotCarousel = ({ screenshots, height = 120, bottomSeparator = false, highlightOnFocus = true, borderOnFocus = true, highlightColor, highlightBackground = DEFAULT_HIGHLIGHT_BACKGROUND, prevActionDescription = "Previous", nextActionDescription = "Next", zoomEnabled = true, }) => {
|
|
37
|
+
const [index, setIndex] = useState(0);
|
|
38
|
+
const [zoomed, setZoomed] = useState(false);
|
|
39
|
+
// A public community feed (AppImageHub's) can point at a screenshot
|
|
40
|
+
// that's since been moved/deleted upstream — this is what makes
|
|
41
|
+
// "only ever show real images" actually true, rather than just
|
|
42
|
+
// "an empty array counts as none". Shared between the inline stage
|
|
43
|
+
// and the zoom overlay — both ever show the same URL for a given
|
|
44
|
+
// index, so there's nothing to track twice.
|
|
45
|
+
const [brokenUrls, setBrokenUrls] = useState(new Set());
|
|
46
|
+
const stageRef = useRef(null);
|
|
47
|
+
const zoomRef = useRef(null);
|
|
48
|
+
const { cls, styleTag, reserveBorder } = useFocusHighlightClass("dck-screenshot-stage", {
|
|
49
|
+
highlightOnFocus,
|
|
50
|
+
borderOnFocus,
|
|
51
|
+
highlightColor,
|
|
52
|
+
highlightBackground,
|
|
53
|
+
hasBottomDivider: bottomSeparator,
|
|
54
|
+
});
|
|
55
|
+
useEffect(() => {
|
|
56
|
+
if (zoomed)
|
|
57
|
+
zoomRef.current?.focus();
|
|
58
|
+
}, [zoomed]);
|
|
59
|
+
const visible = screenshots.filter((url) => !brokenUrls.has(url));
|
|
60
|
+
if (visible.length === 0)
|
|
61
|
+
return null;
|
|
62
|
+
const safeIndex = Math.min(index, visible.length - 1);
|
|
63
|
+
const goPrev = () => setIndex((i) => (i - 1 + visible.length) % visible.length);
|
|
64
|
+
const goNext = () => setIndex((i) => (i + 1) % visible.length);
|
|
65
|
+
const handleButtonDown = (evt) => {
|
|
66
|
+
if (evt.detail.button === GamepadButton.DIR_LEFT ||
|
|
67
|
+
evt.detail.button === GamepadButton.BUMPER_LEFT) {
|
|
68
|
+
evt.stopPropagation();
|
|
69
|
+
goPrev();
|
|
70
|
+
}
|
|
71
|
+
else if (evt.detail.button === GamepadButton.DIR_RIGHT ||
|
|
72
|
+
evt.detail.button === GamepadButton.BUMPER_RIGHT) {
|
|
73
|
+
evt.stopPropagation();
|
|
74
|
+
goNext();
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
const markBroken = () => setBrokenUrls((prev) => new Set(prev).add(visible[safeIndex]));
|
|
78
|
+
const closeZoom = () => {
|
|
79
|
+
setZoomed(false);
|
|
80
|
+
stageRef.current?.focus();
|
|
81
|
+
};
|
|
82
|
+
return (_jsxs(_Fragment, { children: [styleTag && _jsx("style", { children: styleTag }), _jsx(Focusable, { style: { width: "100%", boxSizing: "border-box" }, onButtonDown: handleButtonDown, actionDescriptionMap: visible.length > 1
|
|
83
|
+
? {
|
|
84
|
+
[GamepadButton.BUMPER_LEFT]: prevActionDescription,
|
|
85
|
+
[GamepadButton.BUMPER_RIGHT]: nextActionDescription,
|
|
86
|
+
}
|
|
87
|
+
: undefined, children: _jsx(DialogButton, { ref: stageRef, className: cls, onClick: zoomEnabled ? () => setZoomed(true) : undefined, style: {
|
|
88
|
+
width: "100%",
|
|
89
|
+
padding: 0,
|
|
90
|
+
height,
|
|
91
|
+
overflow: "hidden",
|
|
92
|
+
// Always the full shared roundness — the divider (below,
|
|
93
|
+
// rendered only when bottomSeparator) is its own separate
|
|
94
|
+
// element now, not this stage's own border, so there's
|
|
95
|
+
// nothing here for a radius to clip or curve.
|
|
96
|
+
borderRadius: DEFAULT_ROUNDNESS,
|
|
97
|
+
background: "rgba(255, 255, 255, 0.03)",
|
|
98
|
+
display: "flex",
|
|
99
|
+
alignItems: "center",
|
|
100
|
+
justifyContent: "center",
|
|
101
|
+
...reserveBorder,
|
|
102
|
+
}, children: _jsx("img", { src: visible[safeIndex], alt: "", onError: markBroken, style: {
|
|
103
|
+
height: "100%",
|
|
104
|
+
width: "auto",
|
|
105
|
+
maxWidth: "100%",
|
|
106
|
+
objectFit: "contain",
|
|
107
|
+
display: "block",
|
|
108
|
+
} }) }) }), visible.length > 1 && (_jsx("div", { style: { display: "flex", justifyContent: "center", gap: 4, marginTop: 6 }, children: visible.map((_, i) => (_jsx("div", { style: {
|
|
109
|
+
width: 5,
|
|
110
|
+
height: 5,
|
|
111
|
+
borderRadius: "50%",
|
|
112
|
+
background: i === safeIndex ? "#fff" : "rgba(255, 255, 255, 0.3)",
|
|
113
|
+
} }, i))) })), bottomSeparator && _jsx(Separator, { marginTop: 1 }), zoomEnabled && zoomed && (_jsx(Focusable, { ref: zoomRef, style: {
|
|
114
|
+
position: "fixed",
|
|
115
|
+
top: 0,
|
|
116
|
+
left: 0,
|
|
117
|
+
// vw/vh, not `inset: 0` — a plugin panel's own ancestor
|
|
118
|
+
// chrome likely applies a transform (for its slide in/out
|
|
119
|
+
// animation), which becomes the containing block a `fixed`
|
|
120
|
+
// element's `inset`/percentage sizing resolves against
|
|
121
|
+
// instead of the real viewport — on real-device testing this
|
|
122
|
+
// rendered far larger than the actual visible screen,
|
|
123
|
+
// spilling off the right edge. Viewport units read the true
|
|
124
|
+
// window size directly, regardless of any transformed
|
|
125
|
+
// ancestor in between.
|
|
126
|
+
width: "100vw",
|
|
127
|
+
height: "100vh",
|
|
128
|
+
boxSizing: "border-box",
|
|
129
|
+
overflow: "hidden",
|
|
130
|
+
zIndex: 1000,
|
|
131
|
+
background: "rgba(0, 0, 0, 0.92)",
|
|
132
|
+
display: "flex",
|
|
133
|
+
alignItems: "center",
|
|
134
|
+
justifyContent: "center",
|
|
135
|
+
}, "flow-children": "horizontal", onCancelButton: closeZoom, onButtonDown: handleButtonDown, actionDescriptionMap: visible.length > 1
|
|
136
|
+
? {
|
|
137
|
+
[GamepadButton.BUMPER_LEFT]: prevActionDescription,
|
|
138
|
+
[GamepadButton.BUMPER_RIGHT]: nextActionDescription,
|
|
139
|
+
}
|
|
140
|
+
: undefined, children: _jsx("img", { src: visible[safeIndex], alt: "", onError: markBroken,
|
|
141
|
+
// Full overlay width, capped at 90% of its height — bounded
|
|
142
|
+
// against the overlay's own known fixed size (not a vague
|
|
143
|
+
// percentage of an ambiguous flex box), so a screenshot never
|
|
144
|
+
// renders past the overlay's own edges regardless of its own
|
|
145
|
+
// aspect ratio. LB/RB (and D-pad) still move between shots —
|
|
146
|
+
// no on-screen arrows here, same call already made for the
|
|
147
|
+
// inline stage above.
|
|
148
|
+
style: { width: "100%", maxHeight: "90%", objectFit: "contain" } }) }))] }));
|
|
149
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
export interface StatusCardProps {
|
|
3
|
+
variant?: "success" | "error";
|
|
4
|
+
title: React.ReactNode;
|
|
5
|
+
description?: React.ReactNode;
|
|
6
|
+
icon?: React.ReactNode;
|
|
7
|
+
children?: React.ReactNode;
|
|
8
|
+
}
|
|
9
|
+
export declare const StatusCard: React.FC<StatusCardProps>;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { FaCheckCircle, FaTimesCircle } from "react-icons/fa";
|
|
3
|
+
import { DEFAULT_ROUNDNESS } from "./internal/theme";
|
|
4
|
+
const VARIANT_COLORS = {
|
|
5
|
+
success: {
|
|
6
|
+
fg: "#5fdb6a",
|
|
7
|
+
bg: "rgba(95, 219, 106, 0.12)",
|
|
8
|
+
border: "rgba(95, 219, 106, 0.35)",
|
|
9
|
+
},
|
|
10
|
+
error: {
|
|
11
|
+
fg: "#ff6b6b",
|
|
12
|
+
bg: "rgba(255, 107, 107, 0.12)",
|
|
13
|
+
border: "rgba(255, 107, 107, 0.35)",
|
|
14
|
+
},
|
|
15
|
+
};
|
|
16
|
+
// A finished-state card — "done, here's what happened" — for after an
|
|
17
|
+
// update/install/check completes. Colors and layout match the
|
|
18
|
+
// hand-rolled success/error cards several Decky plugins (e.g.
|
|
19
|
+
// decky-nvidia-update) already converged on independently; this gives
|
|
20
|
+
// that same look as one reusable component instead of copy-pasted CSS.
|
|
21
|
+
export const StatusCard = ({ variant = "success", title, description, icon, children, }) => {
|
|
22
|
+
const colors = VARIANT_COLORS[variant];
|
|
23
|
+
return (_jsxs("div", { style: {
|
|
24
|
+
display: "flex",
|
|
25
|
+
flexDirection: "column",
|
|
26
|
+
alignItems: "center",
|
|
27
|
+
textAlign: "center",
|
|
28
|
+
padding: "18px 10px 14px",
|
|
29
|
+
borderRadius: DEFAULT_ROUNDNESS,
|
|
30
|
+
background: colors.bg,
|
|
31
|
+
border: `1px solid ${colors.border}`,
|
|
32
|
+
}, children: [_jsx("div", { style: { fontSize: 42, color: colors.fg, marginBottom: 8 }, children: icon ?? (variant === "success" ? _jsx(FaCheckCircle, {}) : _jsx(FaTimesCircle, {})) }), _jsx("div", { style: {
|
|
33
|
+
fontSize: 15,
|
|
34
|
+
fontWeight: 700,
|
|
35
|
+
// No description: the title sits directly above `children`, so it
|
|
36
|
+
// needs the same breathing room the description would otherwise
|
|
37
|
+
// provide (see its own marginBottom below) — not the tighter gap
|
|
38
|
+
// meant for a title/description pair.
|
|
39
|
+
marginBottom: description ? 4 : children ? 14 : 0,
|
|
40
|
+
}, children: title }), description && (_jsx("div", { style: {
|
|
41
|
+
fontSize: 11,
|
|
42
|
+
opacity: 0.75,
|
|
43
|
+
marginBottom: children ? 14 : 0,
|
|
44
|
+
}, children: description })), children] }));
|
|
45
|
+
};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,18 @@
|
|
|
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";
|
|
11
|
+
export { InlineConfirm } from "./InlineConfirm";
|
|
12
|
+
export type { InlineConfirmProps } from "./InlineConfirm";
|
|
13
|
+
export { MediaRow } from "./MediaRow";
|
|
14
|
+
export type { MediaRowProps } from "./MediaRow";
|
|
15
|
+
export { ScreenshotCarousel } from "./ScreenshotCarousel";
|
|
16
|
+
export type { ScreenshotCarouselProps } from "./ScreenshotCarousel";
|
|
17
|
+
export { StatusCard } from "./StatusCard";
|
|
18
|
+
export type { StatusCardProps } from "./StatusCard";
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
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";
|
|
6
|
+
export { InlineConfirm } from "./InlineConfirm";
|
|
7
|
+
export { MediaRow } from "./MediaRow";
|
|
8
|
+
export { ScreenshotCarousel } from "./ScreenshotCarousel";
|
|
9
|
+
export { StatusCard } from "./StatusCard";
|
|
@@ -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
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moi952/decky-ui-kit",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.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",
|