@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.
@@ -0,0 +1,17 @@
1
+ import React from "react";
2
+ export interface InfoTableRow {
3
+ icon: React.ReactNode;
4
+ label: React.ReactNode;
5
+ value: React.ReactNode;
6
+ accent?: string;
7
+ }
8
+ export interface InfoTableProps {
9
+ rows: InfoTableRow[];
10
+ labelWidth?: number;
11
+ labelColor?: string;
12
+ iconColor?: string;
13
+ valueColor?: string;
14
+ bgColor?: string;
15
+ borderColor?: string;
16
+ }
17
+ export declare const InfoTable: React.FC<InfoTableProps>;
@@ -0,0 +1,34 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { DEFAULT_ROUNDNESS } from "./internal/theme";
3
+ const DEFAULT_LABEL_WIDTH = 90;
4
+ const DEFAULT_LABEL_COLOR = "#9aa1a8";
5
+ const DEFAULT_ICON_COLOR = "#6b7076";
6
+ const DEFAULT_VALUE_COLOR = "#fff";
7
+ const DEFAULT_BG = "rgba(255, 255, 255, 0.03)";
8
+ const DEFAULT_BORDER = "rgba(255, 255, 255, 0.08)";
9
+ const InfoTableRowView = ({ icon, label, value, accent, last, labelWidth, labelColor, iconColor, valueColor }) => (_jsxs("div", { style: {
10
+ display: "flex",
11
+ alignItems: "center",
12
+ gap: 10,
13
+ padding: "8px 10px",
14
+ borderBottom: last ? "none" : "1px solid rgba(255, 255, 255, 0.06)",
15
+ }, children: [_jsx("span", { style: { color: accent ?? iconColor, flexShrink: 0, display: "flex" }, children: icon }), _jsx("span", { style: { fontSize: 11, color: labelColor, flexShrink: 0, width: labelWidth }, children: label }), _jsx("span", { style: {
16
+ fontSize: 12,
17
+ color: accent ?? valueColor,
18
+ marginLeft: "auto",
19
+ textAlign: "right",
20
+ overflowWrap: "anywhere",
21
+ wordBreak: "break-all",
22
+ }, children: value })] }));
23
+ // A bordered, rounded key/value table — icon, short label, value
24
+ // right-aligned. Purely presentational: what each row means (an app's
25
+ // version, a save file's size, a save slot's date, ...) is entirely up to
26
+ // the caller. Built for a "detail" screen sitting below its header, but
27
+ // nothing here assumes any particular kind of entity. Rows with an
28
+ // `accent` (e.g. an available update in green) stand out against the rest.
29
+ export const InfoTable = ({ rows, labelWidth = DEFAULT_LABEL_WIDTH, labelColor = DEFAULT_LABEL_COLOR, iconColor = DEFAULT_ICON_COLOR, valueColor = DEFAULT_VALUE_COLOR, bgColor = DEFAULT_BG, borderColor = DEFAULT_BORDER, }) => (_jsx("div", { style: {
30
+ background: bgColor,
31
+ border: `1px solid ${borderColor}`,
32
+ borderRadius: DEFAULT_ROUNDNESS,
33
+ overflow: "hidden",
34
+ }, children: rows.map((row, i) => (_jsx(InfoTableRowView, { ...row, last: i === rows.length - 1, labelWidth: labelWidth, labelColor: labelColor, iconColor: iconColor, valueColor: valueColor }, i))) }));
@@ -1,11 +1,12 @@
1
1
  import React from "react";
2
+ import { ComponentSize } from "./internal/theme";
2
3
  export interface InlineConfirmProps {
3
4
  description: React.ReactNode;
4
5
  onCancel: () => void;
5
6
  onConfirm: () => void;
6
7
  cancelLabel?: React.ReactNode;
7
8
  confirmLabel?: React.ReactNode;
8
- size?: "small" | "medium" | "large";
9
+ size?: ComponentSize;
9
10
  variant?: "danger" | "primary";
10
11
  }
11
12
  export declare const InlineConfirm: React.FC<InlineConfirmProps>;
@@ -1,44 +1,44 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useId } from "react";
3
3
  import { DialogButton, Focusable } from "@decky/ui";
4
- const SIZE_STYLE = {
5
- small: { padding: "4px 8px", fontSize: 12, minHeight: 28 },
6
- medium: { padding: "6px 12px", fontSize: 14, minHeight: 32 },
7
- large: { padding: "8px 16px", fontSize: 16, minHeight: 36 },
8
- };
9
- const VARIANT_COLOR = {
10
- danger: "#ef4444",
11
- primary: "#3b82f6",
12
- };
4
+ import { ActionButton } from "./ActionButton";
5
+ import { SIZE_STYLE } from "./internal/theme";
6
+ // Cancel (this file's own hand-styled button, its "always white" look
7
+ // has no ActionButton variant to match) and Confirm (ActionButton
8
+ // itself) need to line up at the same height regardless of size — same
9
+ // shared table ActionButton/FieldTextInput/AnchoredDropdown's own
10
+ // trigger all use, so this can never quietly drift from what Confirm
11
+ // itself actually renders at.
12
+ const PADDING_V = { small: 4, medium: 6, large: 8 };
13
+ const PADDING_H = { small: 8, medium: 12, large: 16 };
13
14
  // A confirmation shown inline, below whatever triggered it — not a modal.
14
15
  // Description line + an equal-width Cancel/Confirm pair.
15
16
  export const InlineConfirm = ({ description, onCancel, onConfirm, cancelLabel = "Cancel", confirmLabel = "Delete", size = "small", variant = "danger", }) => {
16
- const confirmCls = `dck-inline-confirm${useId().replace(/[^a-zA-Z0-9]/g, "")}`;
17
- const buttonStyle = SIZE_STYLE[size];
18
- const color = VARIANT_COLOR[variant];
17
+ const cancelCls = `dck-inline-cancel${useId().replace(/[^a-zA-Z0-9]/g, "")}`;
18
+ const { fontSize, minHeight } = SIZE_STYLE[size];
19
+ const buttonStyle = {
20
+ padding: `${PADDING_V[size]}px ${PADDING_H[size]}px`,
21
+ fontSize,
22
+ minHeight,
23
+ boxSizing: "border-box",
24
+ // Reserved even though Cancel never shows a visible border — Confirm
25
+ // (ActionButton itself, variant="danger"/"primary") reserves the
26
+ // same 1px on its own side now, precisely so a border some variants
27
+ // show and others don't never changes how much of the shared
28
+ // minHeight budget either one actually needs.
29
+ border: "1px solid transparent",
30
+ };
19
31
  return (_jsxs("div", { style: { display: "flex", flexDirection: "column", gap: 8, width: "100%" }, children: [_jsx("style", { children: `
20
- .${confirmCls} {
21
- background-color: ${color} !important;
22
- color: #fff !important;
23
- }
24
- .${confirmCls}:focus,
25
- .${confirmCls}:hover {
32
+ .${cancelCls} {
26
33
  background-color: #fff !important;
27
- color: ${color} !important;
34
+ color: #1a1a1a !important;
28
35
  }
29
- ` }), _jsx("span", { style: { fontSize: 11, color: "#aaa" }, children: description }), _jsxs(Focusable, { style: { display: "flex", gap: 8, width: "100%" }, "flow-children": "horizontal", children: [_jsx("div", { style: { flex: 1 }, children: _jsx(DialogButton, { onClick: onCancel, style: {
30
- ...buttonStyle,
31
- width: "100%",
32
- display: "flex",
33
- alignItems: "center",
34
- justifyContent: "center",
35
- minWidth: "unset",
36
- }, children: cancelLabel }) }), _jsx("div", { style: { flex: 1 }, children: _jsx(DialogButton, { className: confirmCls, onClick: onConfirm, style: {
36
+ ` }), _jsx("span", { style: { fontSize: 11, color: "#aaa" }, children: description }), _jsxs(Focusable, { style: { display: "flex", gap: 8, width: "100%" }, "flow-children": "horizontal", children: [_jsx("div", { style: { flex: 1 }, children: _jsx(DialogButton, { className: cancelCls, onClick: onCancel, style: {
37
37
  ...buttonStyle,
38
38
  width: "100%",
39
39
  display: "flex",
40
40
  alignItems: "center",
41
41
  justifyContent: "center",
42
42
  minWidth: "unset",
43
- }, children: confirmLabel }) })] })] }));
43
+ }, children: cancelLabel }) }), _jsx("div", { style: { flex: 1 }, children: _jsx(ActionButton, { variant: variant, size: size, width: "100%", onClick: onConfirm, children: confirmLabel }) })] })] }));
44
44
  };
@@ -0,0 +1,28 @@
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
+ mediaAlign?: "top" | "center" | "bottom";
9
+ title: React.ReactNode;
10
+ titleLines?: number;
11
+ details?: React.ReactNode;
12
+ onPress?: () => void;
13
+ actions?: React.ReactNode;
14
+ collapsedByDefault?: boolean;
15
+ color: "light" | "dark" | "transparent" | "success" | "danger" | "info" | "warning";
16
+ accentBorderColor?: string;
17
+ accentBorderWidth?: number;
18
+ accentBackground?: string;
19
+ highlightOnFocus?: boolean;
20
+ borderOnFocus?: boolean;
21
+ highlightColor?: string;
22
+ highlightBackground?: string;
23
+ spacing?: number;
24
+ bottomSeparator?: boolean;
25
+ onSecondaryButton?: (evt: GamepadEvent) => void;
26
+ onSecondaryActionDescription?: React.ReactNode;
27
+ }
28
+ export declare const MediaRow: React.FC<MediaRowProps>;
@@ -0,0 +1,175 @@
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 MEDIA_ALIGN = {
8
+ top: "flex-start",
9
+ center: "center",
10
+ bottom: "flex-end",
11
+ };
12
+ const COLOR_STYLES = {
13
+ // The plain default look — reserves the same border width as every
14
+ // accented color below (an invisible border, not an absent one) so a
15
+ // row's size never shifts when it becomes accented.
16
+ light: { border: "transparent", background: DEFAULT_PANEL_BACKGROUND },
17
+ dark: { border: "transparent", background: "#202225" },
18
+ // Fully invisible — for a row inside a continuous divided list
19
+ // (bottomSeparator), which must show no card look of its own.
20
+ transparent: { border: "transparent", background: "transparent" },
21
+ success: { border: ACCENT_SUCCESS, background: "#0d1f0d" },
22
+ danger: { border: ACCENT_DANGER, background: "#2a0d0d" },
23
+ info: { border: ACCENT_INFO, background: "#0d1a2a" },
24
+ warning: { border: ACCENT_WARNING, background: "#2a1f0d" },
25
+ };
26
+ // A focusable media+title(+details)(+actions) row — the shape shared by
27
+ // "a list of apps, each with a status stack and inline action buttons"
28
+ // and "a grid of game capsules, each just a cover and a title" alike.
29
+ // Which of those two a given instance looks like follows entirely from
30
+ // which props are passed: `actions` opts into the header+actions-row
31
+ // split (with its own show/hide), `mediaLayout="stretch"` opts into a
32
+ // cover-image box instead of a centered icon. Neither look is "the
33
+ // special case" — both are just points on the same prop surface.
34
+ export const MediaRow = ({ media, mediaWidth = 32, mediaLayout = "fixed", mediaHeight = 32,
35
+ // Layout-dependent default, not a flat "center" for both — a flex item
36
+ // with a definite cross-size (mediaBox always has one: mediaHeight)
37
+ // renders at the container's cross-axis start when align-items can't
38
+ // actually stretch it, which is what "stretch" always used before this
39
+ // prop existed. Defaulting it to "center" for both would have silently
40
+ // changed every existing mediaLayout="stretch" caller's look (e.g.
41
+ // decky-proton-launch's own GameRow cover art) the moment they upgraded
42
+ // — this keeps that exact prior look until a caller opts in.
43
+ mediaAlign = mediaLayout === "stretch" ? "top" : "center", 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, }) => {
44
+ const { cls, styleTag } = useFocusHighlightClass("dck-media-row", {
45
+ highlightOnFocus,
46
+ borderOnFocus,
47
+ highlightColor,
48
+ highlightBackground,
49
+ borderWidth: accentBorderWidth,
50
+ hasBottomDivider: bottomSeparator,
51
+ });
52
+ const hasActions = !!actions;
53
+ // `collapsedByDefault` always governs the initial state, `onPress` or
54
+ // not — a caller with both `onPress` and `actions` (the header presses
55
+ // through to `onPress`, so there's no in-place toggle for those rows)
56
+ // is expected to pick `collapsedByDefault` per row from its own data
57
+ // (e.g. only expanding the ones that actually need attention), not
58
+ // rely on this component to always force it open.
59
+ const [expanded, setExpanded] = useState(!collapsedByDefault || !hasActions);
60
+ const stretch = mediaLayout === "stretch";
61
+ const resolvedBorderColor = accentBorderColor ?? COLOR_STYLES[color].border;
62
+ const resolvedBackground = accentBackground ?? COLOR_STYLES[color].background;
63
+ // The card's own outer look — applied directly to whichever element
64
+ // ends up on the outside: the header button itself when there's no
65
+ // actions row (nothing else to wrap), or a containing div when there
66
+ // is (the actions row is that div's other child). `background`/
67
+ // `border` are always resolved to a real value (never omitted) — an
68
+ // inline style key present with value `undefined` still wins the
69
+ // object-spread merge against whatever default the element underneath
70
+ // set for that same property, so leaving either one unset would risk
71
+ // the browser's own native DialogButton chrome bleeding through
72
+ // instead of this card's own look.
73
+ // bottomSeparator rows use an inset box-shadow (see focusHighlight.ts)
74
+ // for their focus frame instead of a border-color swap, so they carry
75
+ // no border of their own to begin with (always "transparent" anyway,
76
+ // per this prop's own convention) — reserving one here regardless
77
+ // would push that box-shadow the same width further inward, leaving a
78
+ // ring of this row's own background visible between its true edge and
79
+ // the highlight frame.
80
+ const cardStyle = {
81
+ // Always the full shared roundness, all 4 corners, bottomSeparator
82
+ // row or not — the divider itself is a separate element (see
83
+ // Separator below), not this row's own border, so there's nothing
84
+ // here for a radius to clip or curve.
85
+ borderRadius: DEFAULT_ROUNDNESS,
86
+ overflow: "hidden",
87
+ background: resolvedBackground,
88
+ border: `${bottomSeparator ? 0 : accentBorderWidth}px solid ${resolvedBorderColor}`,
89
+ ...(spacing ? { marginBottom: spacing } : {}),
90
+ };
91
+ const highlightStyle = styleTag ? _jsx("style", { children: styleTag }) : null;
92
+ const titleNode = (_jsx("div", { style: {
93
+ fontSize: 13,
94
+ // Steam's own default line-height runs noticeably taller than this
95
+ // font actually needs — harmless for a single line, but it's what
96
+ // pushes a 2+ line title past mediaHeight in the first place
97
+ // (mediaAlign, above, only ever manages the leftover once that
98
+ // happens; this cuts down how much leftover there is to manage).
99
+ lineHeight: 1.2,
100
+ fontWeight: 600,
101
+ color: "#fff",
102
+ ...(titleLines > 1
103
+ ? {
104
+ overflow: "hidden",
105
+ display: "-webkit-box",
106
+ WebkitLineClamp: titleLines,
107
+ WebkitBoxOrient: "vertical",
108
+ }
109
+ : {
110
+ overflow: "hidden",
111
+ textOverflow: "ellipsis",
112
+ whiteSpace: "nowrap",
113
+ }),
114
+ }, children: title }));
115
+ const mediaBox = (_jsx("div", { style: stretch
116
+ ? {
117
+ position: "relative",
118
+ height: mediaHeight,
119
+ flexShrink: 0,
120
+ overflow: "hidden",
121
+ alignSelf: MEDIA_ALIGN[mediaAlign],
122
+ }
123
+ : {
124
+ width: mediaWidth,
125
+ height: mediaHeight,
126
+ flexShrink: 0,
127
+ display: "flex",
128
+ alignItems: "center",
129
+ justifyContent: "center",
130
+ alignSelf: MEDIA_ALIGN[mediaAlign],
131
+ }, children: media }));
132
+ const textBox = (_jsxs("div", { style: {
133
+ flex: 1,
134
+ minWidth: 0,
135
+ textAlign: "left",
136
+ ...(stretch ? { display: "flex", alignItems: "center" } : {}),
137
+ }, children: [titleNode, details] }));
138
+ const handleClick = () => {
139
+ if (onPress)
140
+ onPress();
141
+ else if (hasActions)
142
+ setExpanded((v) => !v);
143
+ };
144
+ // No actions row: the header button IS the whole card — no wrapper
145
+ // element at all, the exact single-element structure a plain "press to
146
+ // open" capsule (e.g. a game cover) had before this became a shared
147
+ // component. Only an actions row (below) needs something to wrap.
148
+ if (!hasActions) {
149
+ return (_jsxs(_Fragment, { children: [highlightStyle, _jsxs(DialogButton, { className: cls, onClick: handleClick, onSecondaryButton: onSecondaryButton, onSecondaryActionDescription: onSecondaryActionDescription, style: {
150
+ ...cardStyle,
151
+ width: "100%",
152
+ boxSizing: "border-box",
153
+ display: "flex",
154
+ alignItems: stretch ? "stretch" : "center",
155
+ gap: 10,
156
+ padding: stretch ? 0 : "4px 8px",
157
+ }, children: [mediaBox, textBox] }), bottomSeparator && _jsx(Separator, { marginTop: 1 })] }));
158
+ }
159
+ 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: {
160
+ width: "100%",
161
+ boxSizing: "border-box",
162
+ display: "flex",
163
+ alignItems: stretch ? "stretch" : "center",
164
+ gap: 10,
165
+ padding: stretch ? 0 : "4px 8px",
166
+ background: "transparent",
167
+ border: "none",
168
+ }, children: [mediaBox, textBox] }), expanded && (_jsx(Focusable, { style: {
169
+ display: "flex",
170
+ gap: 8,
171
+ width: "100%",
172
+ boxSizing: "border-box",
173
+ padding: "0 8px 6px",
174
+ }, "flow-children": "horizontal", children: actions }))] }), bottomSeparator && _jsx(Separator, { marginTop: 1 })] }));
175
+ };
@@ -0,0 +1,12 @@
1
+ import React from "react";
2
+ export interface QrCodeButtonProps {
3
+ value: string;
4
+ label: React.ReactNode;
5
+ hint?: React.ReactNode;
6
+ qrSize?: number;
7
+ borderOnFocus?: boolean;
8
+ highlightColor?: string;
9
+ highlightOnFocus?: boolean;
10
+ highlightBackground?: string;
11
+ }
12
+ export declare const QrCodeButton: React.FC<QrCodeButtonProps>;
@@ -0,0 +1,36 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useState } from "react";
3
+ import { QRCodeSVG } from "qrcode.react";
4
+ import { DialogButton, Navigation } from "@decky/ui";
5
+ import { CollapsibleSection } from "./CollapsibleSection";
6
+ import { useFocusHighlightClass } from "./internal/focusHighlight";
7
+ import { DEFAULT_HIGHLIGHT_BACKGROUND } from "./internal/theme";
8
+ // A collapsible section that reveals a QR code on expand — for handing off
9
+ // a URL to the user's phone (a plugin's own feedback form, a release page,
10
+ // ...) without them having to type it on a gamepad. The revealed code is
11
+ // itself a real focusable button — pressing it (gamepad A / click) opens
12
+ // `value` directly in Steam's own browser overlay via
13
+ // Navigation.NavigateToExternalWeb, for anyone who'd rather not reach for
14
+ // their phone at all.
15
+ export const QrCodeButton = ({ value, label, hint, qrSize = 160, borderOnFocus = true, highlightColor = DEFAULT_HIGHLIGHT_BACKGROUND, highlightOnFocus = false, highlightBackground, }) => {
16
+ const [expanded, setExpanded] = useState(false);
17
+ const { cls, styleTag, reserveBorder } = useFocusHighlightClass("dck-qr-btn", {
18
+ borderOnFocus,
19
+ highlightColor,
20
+ highlightOnFocus,
21
+ highlightBackground,
22
+ });
23
+ return (_jsxs(CollapsibleSection, { label: label, expanded: expanded, onToggle: () => setExpanded((v) => !v), children: [styleTag && _jsx("style", { children: styleTag }), _jsxs(DialogButton, { className: cls, onClick: () => Navigation.NavigateToExternalWeb(value), style: {
24
+ display: "flex",
25
+ flexDirection: "column",
26
+ alignItems: "center",
27
+ width: "100%",
28
+ boxSizing: "border-box",
29
+ marginTop: 10,
30
+ marginBottom: 10,
31
+ padding: 12,
32
+ background: "#fff",
33
+ borderRadius: 8,
34
+ ...reserveBorder,
35
+ }, children: [_jsx(QRCodeSVG, { value: value, size: qrSize }), hint && (_jsx("div", { style: { marginTop: 8, fontSize: 11, color: "#333", textAlign: "center" }, children: hint }))] })] }));
36
+ };
@@ -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" | "info";
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,63 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { FaCheckCircle, FaTimesCircle } from "react-icons/fa";
3
+ import { FiInfo } from "react-icons/fi";
4
+ import { DEFAULT_ROUNDNESS } from "./internal/theme";
5
+ const VARIANT_COLORS = {
6
+ success: {
7
+ fg: "#5fdb6a",
8
+ bg: "rgba(95, 219, 106, 0.12)",
9
+ border: "rgba(95, 219, 106, 0.35)",
10
+ },
11
+ error: {
12
+ fg: "#ff6b6b",
13
+ bg: "rgba(255, 107, 107, 0.12)",
14
+ border: "rgba(255, 107, 107, 0.35)",
15
+ },
16
+ // Not a finished-state ("done, here's what happened") like the other
17
+ // two — for a plain announcement/notice instead (e.g. "check out my
18
+ // other plugins"), same card look, neutral blue instead of a verdict.
19
+ info: {
20
+ fg: "#4b9cf7",
21
+ bg: "rgba(75, 156, 247, 0.12)",
22
+ border: "rgba(75, 156, 247, 0.35)",
23
+ },
24
+ };
25
+ const DEFAULT_ICON = {
26
+ success: _jsx(FaCheckCircle, {}),
27
+ error: _jsx(FaTimesCircle, {}),
28
+ info: _jsx(FiInfo, {}),
29
+ };
30
+ // A finished-state card — "done, here's what happened" — for after an
31
+ // update/install/check completes (or, with variant="info", a plain
32
+ // announcement/notice instead). Colors and layout match the hand-rolled
33
+ // success/error cards several Decky plugins (e.g. decky-nvidia-update)
34
+ // already converged on independently; this gives that same look as one
35
+ // reusable component instead of copy-pasted CSS. There's no first-class
36
+ // dismiss-button prop — the same `children` slot that already fits a
37
+ // "Reboot now"/"Try again" action fits a dismiss button just as well
38
+ // (render one, e.g. `ActionButton`, straight into `children`).
39
+ export const StatusCard = ({ variant = "success", title, description, icon, children, }) => {
40
+ const colors = VARIANT_COLORS[variant];
41
+ return (_jsxs("div", { style: {
42
+ display: "flex",
43
+ flexDirection: "column",
44
+ alignItems: "center",
45
+ textAlign: "center",
46
+ padding: "18px 10px 14px",
47
+ borderRadius: DEFAULT_ROUNDNESS,
48
+ background: colors.bg,
49
+ border: `1px solid ${colors.border}`,
50
+ }, children: [_jsx("div", { style: { fontSize: 42, color: colors.fg, marginBottom: 8 }, children: icon ?? DEFAULT_ICON[variant] }), _jsx("div", { style: {
51
+ fontSize: 15,
52
+ fontWeight: 700,
53
+ // No description: the title sits directly above `children`, so it
54
+ // needs the same breathing room the description would otherwise
55
+ // provide (see its own marginBottom below) — not the tighter gap
56
+ // meant for a title/description pair.
57
+ marginBottom: description ? 4 : children ? 14 : 0,
58
+ }, children: title }), description && (_jsx("div", { style: {
59
+ fontSize: 11,
60
+ opacity: 0.75,
61
+ marginBottom: children ? 14 : 0,
62
+ }, children: description })), children] }));
63
+ };