@glasshome/ui 1.21.0 → 1.21.2
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/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/lib/use-is-mobile.d.ts +3 -1
- package/dist/solid/alert-dialog.d.ts +7 -1
- package/dist/solid/bottom-sheet/bottom-sheet.d.ts +7 -1
- package/dist/solid/dialog-parts.d.ts +3 -2
- package/dist/solid/dialog.d.ts +7 -1
- package/dist/solid/docked-panel.d.ts +7 -1
- package/dist/solid/index.d.ts +9 -9
- package/dist/solid/index.js +5456 -5447
- package/dist/solid/media-store.d.ts +4 -1
- package/dist/solid/option-card.d.ts +4 -1
- package/dist/solid/responsive-dialog.d.ts +7 -1
- package/dist/solid/sheet.d.ts +7 -1
- package/dist/{utils-CMk7R3zM.js → utils-D5blHO4O.js} +624 -622
- package/package.json +128 -126
- package/scripts/check-gallery.ts +142 -142
- package/scripts/check-pack.ts +13 -13
- package/scripts/check-structural-classes.ts +20 -20
- package/scripts/check-tokens.ts +27 -27
- package/scripts/check-ui-drift.mjs +103 -103
- package/src/index.ts +75 -80
- package/src/lib/alert-tones.ts +41 -41
- package/src/lib/anchor-placement.ts +21 -21
- package/src/lib/button-variants.ts +28 -28
- package/src/lib/card-classes.ts +9 -9
- package/src/lib/carousel-classes.ts +14 -14
- package/src/lib/glass-tone.ts +11 -11
- package/src/lib/input-classes.ts +6 -6
- package/src/lib/layers.ts +4 -4
- package/src/lib/logo-lockup.ts +8 -8
- package/src/lib/menu-classes.ts +2 -2
- package/src/lib/motion-classes.ts +8 -8
- package/src/lib/motion-window.ts +24 -24
- package/src/lib/overlay-classes.ts +6 -6
- package/src/lib/pill-classes.ts +3 -3
- package/src/lib/position-bar-classes.ts +1 -1
- package/src/lib/spotlight-geometry.ts +67 -67
- package/src/lib/thumb-classes.ts +2 -2
- package/src/lib/tier-badge.ts +16 -16
- package/src/lib/use-is-mobile.ts +17 -14
- package/src/lib/utils.ts +1 -1
- package/src/solid/accordion.tsx +41 -41
- package/src/solid/alert-dialog.tsx +95 -95
- package/src/solid/alert.tsx +88 -88
- package/src/solid/area-picker.tsx +204 -204
- package/src/solid/aspect-ratio.tsx +13 -13
- package/src/solid/avatar.tsx +27 -27
- package/src/solid/badge.tsx +49 -49
- package/src/solid/bottom-sheet/arbitration.ts +22 -22
- package/src/solid/bottom-sheet/bottom-sheet.tsx +394 -394
- package/src/solid/bottom-sheet/drag-controller.ts +201 -201
- package/src/solid/bottom-sheet/focus-trap.ts +51 -47
- package/src/solid/bottom-sheet/index.ts +12 -12
- package/src/solid/bottom-sheet/keyboard.ts +25 -25
- package/src/solid/bottom-sheet/scroll-lock.ts +46 -46
- package/src/solid/bottom-sheet/state-machine.ts +28 -28
- package/src/solid/bottom-sheet/velocity.ts +29 -29
- package/src/solid/breadcrumb.tsx +76 -76
- package/src/solid/button-group.tsx +46 -46
- package/src/solid/button.tsx +19 -19
- package/src/solid/card.tsx +67 -67
- package/src/solid/carousel.tsx +246 -246
- package/src/solid/charts.tsx +253 -253
- package/src/solid/checkbox.tsx +51 -51
- package/src/solid/collapsible.tsx +22 -22
- package/src/solid/color-disc.tsx +213 -213
- package/src/solid/color-slider.tsx +81 -81
- package/src/solid/color-wheel.tsx +61 -61
- package/src/solid/context-menu.tsx +63 -63
- package/src/solid/copy-button.tsx +31 -31
- package/src/solid/count-pill.tsx +11 -11
- package/src/solid/dashboard-preview.tsx +104 -104
- package/src/solid/data-table.tsx +228 -228
- package/src/solid/dialog-parts.tsx +129 -129
- package/src/solid/dialog.tsx +113 -113
- package/src/solid/dock-paging.ts +9 -9
- package/src/solid/dock.tsx +339 -338
- package/src/solid/docked-panel.tsx +35 -35
- package/src/solid/dropdown-menu.tsx +77 -77
- package/src/solid/empty.tsx +70 -70
- package/src/solid/entity-data.ts +38 -38
- package/src/solid/entity-selector.tsx +634 -634
- package/src/solid/field.tsx +205 -205
- package/src/solid/form.tsx +159 -159
- package/src/solid/hero-action.tsx +85 -85
- package/src/solid/hover-card.tsx +11 -11
- package/src/solid/icon-picker.tsx +401 -401
- package/src/solid/icon.tsx +101 -78
- package/src/solid/image-picker.tsx +416 -414
- package/src/solid/index.ts +265 -304
- package/src/solid/input-group.tsx +123 -123
- package/src/solid/input-otp.tsx +143 -143
- package/src/solid/input.tsx +4 -4
- package/src/solid/item.tsx +130 -130
- package/src/solid/kbd.tsx +20 -20
- package/src/solid/label.tsx +12 -12
- package/src/solid/list-reorder.ts +122 -122
- package/src/solid/logo.tsx +60 -60
- package/src/solid/media-copy.ts +21 -21
- package/src/solid/media-store.ts +60 -57
- package/src/solid/media-tile.tsx +85 -85
- package/src/solid/menu-parts.tsx +164 -164
- package/src/solid/number-field.tsx +56 -56
- package/src/solid/option-card.tsx +168 -165
- package/src/solid/ornament.tsx +43 -43
- package/src/solid/overlay.tsx +4 -4
- package/src/solid/page-header.tsx +75 -75
- package/src/solid/pagination.tsx +80 -80
- package/src/solid/password-input.tsx +51 -51
- package/src/solid/picker-row.tsx +83 -83
- package/src/solid/picker-search.tsx +65 -63
- package/src/solid/picker-trigger.tsx +59 -57
- package/src/solid/popover.tsx +54 -54
- package/src/solid/preview-tile.tsx +67 -67
- package/src/solid/progress.tsx +21 -21
- package/src/solid/radio-group.tsx +51 -51
- package/src/solid/resizable.tsx +128 -128
- package/src/solid/responsive-dialog.tsx +134 -134
- package/src/solid/schema-form.tsx +746 -739
- package/src/solid/scope-indicator.tsx +5 -5
- package/src/solid/scroll-area.tsx +16 -16
- package/src/solid/section-card.tsx +281 -281
- package/src/solid/select.tsx +101 -101
- package/src/solid/separator.tsx +25 -25
- package/src/solid/settings-row.tsx +122 -122
- package/src/solid/sheet.tsx +96 -96
- package/src/solid/skeleton.tsx +8 -8
- package/src/solid/slider.tsx +132 -132
- package/src/solid/sliding-indicator.tsx +280 -265
- package/src/solid/sonner.tsx +164 -164
- package/src/solid/spinner.tsx +12 -12
- package/src/solid/spotlight.tsx +140 -140
- package/src/solid/step-indicator.tsx +18 -18
- package/src/solid/swatch-picker.tsx +38 -38
- package/src/solid/switch.tsx +52 -52
- package/src/solid/table.tsx +63 -63
- package/src/solid/tabs.tsx +93 -93
- package/src/solid/textarea.tsx +8 -8
- package/src/solid/toggle-group.tsx +83 -83
- package/src/solid/toggle.tsx +33 -33
- package/src/solid/tooltip.tsx +16 -16
- package/src/solid/widget-card.tsx +90 -90
- package/src/solid/widget-identity.tsx +99 -99
- package/src/solid/widget-trust-badge.tsx +20 -20
- package/src/styles/globals.css +316 -319
- package/src/styles/theme.css +448 -448
- package/src/tokens/hex.ts +29 -29
- package/src/tokens/material.ts +75 -75
- package/src/tokens/presets.ts +303 -303
- package/src/tokens/readability.ts +32 -32
- package/src/tokens/theme-colors.ts +95 -95
- package/src/tokens/theme-css.ts +22 -22
- package/src/tokens/theme-recipe.ts +106 -106
package/src/solid/toggle.tsx
CHANGED
|
@@ -7,22 +7,22 @@ import { SEGMENT_ITEM } from "../lib/segment-classes.js";
|
|
|
7
7
|
import { cn } from "../lib/utils.js";
|
|
8
8
|
|
|
9
9
|
const toggleVariants = cva({
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
10
|
+
base: `${SEGMENT_ITEM} aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 border border-transparent [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,
|
|
11
|
+
variants: {
|
|
12
|
+
variant: {
|
|
13
|
+
default: "bg-transparent",
|
|
14
|
+
outline: OUTLINE_SURFACE,
|
|
15
|
+
},
|
|
16
|
+
size: {
|
|
17
|
+
default: `${CONTROL_H.default} min-w-9 px-2`,
|
|
18
|
+
sm: `${CONTROL_H.sm} min-w-8 px-1.5`,
|
|
19
|
+
lg: `${CONTROL_H.lg} min-w-10 px-2.5`,
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
defaultVariants: {
|
|
23
|
+
variant: "default",
|
|
24
|
+
size: "default",
|
|
25
|
+
},
|
|
26
26
|
});
|
|
27
27
|
|
|
28
28
|
/* The hover fill lives here, not in the shared variants: a ToggleGroupItem
|
|
@@ -31,27 +31,27 @@ const toggleVariants = cva({
|
|
|
31
31
|
* adds to cancel it. Unpressed only, because a background utility is a no-op
|
|
32
32
|
* once `data-[pressed]:glass` engages, so the pressed hover bumps a knob. */
|
|
33
33
|
const TOGGLE_HOVER: Record<"default" | "outline", string> = {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
34
|
+
default:
|
|
35
|
+
"not-data-[pressed]:hover:bg-muted not-data-[pressed]:hover:text-muted-foreground data-[pressed]:hover:[--glass-wash:40%]",
|
|
36
|
+
outline: "",
|
|
37
37
|
};
|
|
38
38
|
|
|
39
39
|
const Toggle: Component<
|
|
40
|
-
|
|
40
|
+
ComponentProps<typeof ToggleButtonPrimitive> & VariantProps<typeof toggleVariants>
|
|
41
41
|
> = (props) => {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
42
|
+
const [local, rest] = splitProps(props, ["class", "variant", "size"] as const);
|
|
43
|
+
return (
|
|
44
|
+
<ToggleButtonPrimitive
|
|
45
|
+
data-slot="toggle"
|
|
46
|
+
class={cn(
|
|
47
|
+
toggleVariants({ variant: local.variant, size: local.size }),
|
|
48
|
+
TOGGLE_HOVER[local.variant ?? "default"],
|
|
49
|
+
"data-[pressed]:glass data-[pressed]:[--glass-tone:var(--primary)]",
|
|
50
|
+
local.class,
|
|
51
|
+
)}
|
|
52
|
+
{...rest}
|
|
53
|
+
/>
|
|
54
|
+
);
|
|
55
55
|
};
|
|
56
56
|
|
|
57
57
|
export { Toggle, toggleVariants };
|
package/src/solid/tooltip.tsx
CHANGED
|
@@ -7,7 +7,7 @@ import { cn } from "../lib/utils.js";
|
|
|
7
7
|
/* Kobalte takes the popper options on the root, not on the content, so the
|
|
8
8
|
* gutter that keeps the panel off its trigger has to default here. */
|
|
9
9
|
const TooltipRoot: Component<ComponentProps<typeof TooltipPrimitive>> = (props) => (
|
|
10
|
-
|
|
10
|
+
<TooltipPrimitive gutter={6} {...props} />
|
|
11
11
|
);
|
|
12
12
|
|
|
13
13
|
/* Object.assign, not a bare wrapper: Kobalte ships Tooltip as a callable
|
|
@@ -18,21 +18,21 @@ const Tooltip = Object.assign(TooltipRoot, TooltipPrimitive);
|
|
|
18
18
|
const TooltipTrigger = TooltipPrimitive.Trigger;
|
|
19
19
|
|
|
20
20
|
const TooltipContent: Component<ComponentProps<typeof TooltipPrimitive.Content>> = (props) => {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
21
|
+
const [local, others] = splitProps(props, ["class"]);
|
|
22
|
+
return (
|
|
23
|
+
<TooltipPrimitive.Portal>
|
|
24
|
+
<TooltipPrimitive.Content
|
|
25
|
+
data-slot="tooltip-content"
|
|
26
|
+
class={cn(
|
|
27
|
+
FLOATING_PANEL,
|
|
28
|
+
OVERLAY_MOTION,
|
|
29
|
+
"overflow-hidden px-3 py-1.5 text-xs",
|
|
30
|
+
local.class,
|
|
31
|
+
)}
|
|
32
|
+
{...others}
|
|
33
|
+
/>
|
|
34
|
+
</TooltipPrimitive.Portal>
|
|
35
|
+
);
|
|
36
36
|
};
|
|
37
37
|
|
|
38
38
|
export { Tooltip, TooltipContent, TooltipTrigger };
|
|
@@ -11,108 +11,108 @@ import { WidgetIdentity, WidgetMeta, type WidgetSummary, widgetHref } from "./wi
|
|
|
11
11
|
* apps; the data model is `WidgetSummary`.
|
|
12
12
|
*/
|
|
13
13
|
type WidgetCardProps = {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
14
|
+
widget: WidgetSummary;
|
|
15
|
+
/** `row` for dense lists, `tile` for grids/galleries. Default `row`. */
|
|
16
|
+
layout?: "row" | "tile";
|
|
17
|
+
/** When set, the whole card becomes a link. */
|
|
18
|
+
href?: string;
|
|
19
|
+
/** Click handler (used when no href). */
|
|
20
|
+
onClick?: (e: MouseEvent) => void;
|
|
21
|
+
/** Show the (personal/org) scope pill. Default false. */
|
|
22
|
+
showScopeIndicator?: boolean;
|
|
23
|
+
/** Show the version-count meta. Default false. */
|
|
24
|
+
showVersions?: boolean;
|
|
25
|
+
/** Show the description (tile only). Default true for tiles. */
|
|
26
|
+
showDescription?: boolean;
|
|
27
|
+
/** Custom trailing element for the row layout. Defaults to a chevron when
|
|
28
|
+
* the card is interactive (href/onClick), otherwise nothing. */
|
|
29
|
+
trailing?: JSX.Element;
|
|
30
|
+
class?: string;
|
|
31
31
|
};
|
|
32
32
|
|
|
33
33
|
export function WidgetCard(_props: WidgetCardProps) {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
34
|
+
const props = mergeProps({ layout: "row" as const }, _props);
|
|
35
|
+
// Default: link to the widget's public page. A call-site that wants different
|
|
36
|
+
// behavior (e.g. open a dialog) passes `onClick` and opts out of the link.
|
|
37
|
+
const href = () => props.href ?? (props.onClick ? undefined : widgetHref(props.widget));
|
|
38
|
+
const interactive = () => href() != null || props.onClick != null;
|
|
39
39
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
40
|
+
return (
|
|
41
|
+
<Show
|
|
42
|
+
when={props.layout === "tile"}
|
|
43
|
+
fallback={<WidgetCardRow {...props} href={href()} interactive={interactive()} />}
|
|
44
|
+
>
|
|
45
|
+
<WidgetCardTile {...props} href={href()} interactive={interactive()} />
|
|
46
|
+
</Show>
|
|
47
|
+
);
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
type InternalProps = WidgetCardProps & { interactive: boolean };
|
|
51
51
|
|
|
52
52
|
function WidgetCardRow(props: InternalProps) {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
53
|
+
const hasMeta = () =>
|
|
54
|
+
props.widget.downloadCount != null || (props.showVersions && props.widget.versionCount != null);
|
|
55
|
+
const showTrailing = () => props.trailing !== undefined || props.interactive;
|
|
56
56
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
57
|
+
return (
|
|
58
|
+
<Card
|
|
59
|
+
as={props.href ? "a" : "div"}
|
|
60
|
+
href={props.href}
|
|
61
|
+
onClick={props.onClick}
|
|
62
|
+
interactive={props.interactive}
|
|
63
|
+
padding="sm"
|
|
64
|
+
class={cn("group flex-row items-center gap-3", props.class)}
|
|
65
|
+
>
|
|
66
|
+
<WidgetIdentity
|
|
67
|
+
widget={props.widget}
|
|
68
|
+
iconSize="sm"
|
|
69
|
+
showScopeIndicator={props.showScopeIndicator}
|
|
70
|
+
class="flex-1"
|
|
71
|
+
/>
|
|
72
|
+
<Show when={hasMeta()}>
|
|
73
|
+
<WidgetMeta widget={props.widget} showVersions={props.showVersions} class="shrink-0" />
|
|
74
|
+
</Show>
|
|
75
|
+
<Show when={showTrailing()} fallback={null}>
|
|
76
|
+
<Show
|
|
77
|
+
when={props.trailing !== undefined}
|
|
78
|
+
fallback={
|
|
79
|
+
<Icon
|
|
80
|
+
icon="lucide:chevron-right"
|
|
81
|
+
width={16}
|
|
82
|
+
height={16}
|
|
83
|
+
class="text-muted-foreground group-hover:text-foreground h-4 w-4 shrink-0 transition-transform duration-200 group-hover:translate-x-0.5"
|
|
84
|
+
/>
|
|
85
|
+
}
|
|
86
|
+
>
|
|
87
|
+
{props.trailing}
|
|
88
|
+
</Show>
|
|
89
|
+
</Show>
|
|
90
|
+
</Card>
|
|
91
|
+
);
|
|
92
92
|
}
|
|
93
93
|
|
|
94
94
|
function WidgetCardTile(props: InternalProps) {
|
|
95
|
-
|
|
95
|
+
const showDescription = () => props.showDescription !== false;
|
|
96
96
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
97
|
+
return (
|
|
98
|
+
<Card
|
|
99
|
+
as={props.href ? "a" : "div"}
|
|
100
|
+
href={props.href}
|
|
101
|
+
onClick={props.onClick}
|
|
102
|
+
interactive={props.interactive}
|
|
103
|
+
padding="md"
|
|
104
|
+
class={cn("group h-full", props.class)}
|
|
105
|
+
>
|
|
106
|
+
{/* flex-1 body: the meta stays pinned to the tile's foot whether the description is long, missing or off. */}
|
|
107
|
+
<div data-slot="widget-card-body" class="flex flex-1 flex-col gap-3">
|
|
108
|
+
<WidgetIdentity widget={props.widget} iconSize="md" showVersionInline={false} />
|
|
109
|
+
<Show when={showDescription() && props.widget.description}>
|
|
110
|
+
<p class="text-muted-foreground line-clamp-2 text-xs leading-relaxed">
|
|
111
|
+
{props.widget.description}
|
|
112
|
+
</p>
|
|
113
|
+
</Show>
|
|
114
|
+
</div>
|
|
115
|
+
<WidgetMeta widget={props.widget} showLatestVersion />
|
|
116
|
+
</Card>
|
|
117
|
+
);
|
|
118
118
|
}
|
|
@@ -15,123 +15,123 @@ import { WidgetTrustBadge } from "./widget-trust-badge.js";
|
|
|
15
15
|
* `WidgetSummary`.
|
|
16
16
|
*/
|
|
17
17
|
export interface WidgetSummary {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
18
|
+
scope: string;
|
|
19
|
+
name: string;
|
|
20
|
+
displayName?: string | null;
|
|
21
|
+
icon?: string | null;
|
|
22
|
+
description?: string | null;
|
|
23
|
+
isOfficial?: boolean;
|
|
24
|
+
isUnlisted?: boolean;
|
|
25
|
+
/** Newest version never finished publishing (bundle upload never confirmed,
|
|
26
|
+
* or no version row at all), so nothing is installable. Distinct from
|
|
27
|
+
* `isUnlisted`, which is a published widget hidden from search.
|
|
28
|
+
* Owner-facing surfaces set it; public ones leave it off. */
|
|
29
|
+
isUnpublished?: boolean;
|
|
30
|
+
downloadCount?: number;
|
|
31
|
+
latestVersion?: string | null;
|
|
32
|
+
versionCount?: number;
|
|
33
|
+
ownerType?: "personal" | "organization";
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
/** Canonical public detail URL for a widget (`/widgets/@scope/name`). */
|
|
37
37
|
export function widgetHref(w: { scope: string; name: string }): string {
|
|
38
|
-
|
|
38
|
+
return `/widgets/@${w.scope}/${w.name}`;
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
/** Compact download/count formatting, shared by every surface. */
|
|
42
42
|
export function formatWidgetCount(n: number | null | undefined): string {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
43
|
+
const v = n ?? 0;
|
|
44
|
+
if (v >= 1_000_000) return `${(v / 1_000_000).toFixed(1)}M`;
|
|
45
|
+
if (v >= 1000) return `${(v / 1000).toFixed(1)}k`;
|
|
46
|
+
return v.toString();
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
type WidgetIdentityProps = {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
50
|
+
widget: WidgetSummary;
|
|
51
|
+
/** Icon pill size. Rows use sm, tiles use md. */
|
|
52
|
+
iconSize?: "sm" | "md";
|
|
53
|
+
/** CSS color for the icon pill; neutral when unset. */
|
|
54
|
+
iconTone?: string;
|
|
55
|
+
/** Append `v{latestVersion}` next to the name. Default true. */
|
|
56
|
+
showVersionInline?: boolean;
|
|
57
|
+
/** Show the (personal/org) scope pill after the @scope/name line. */
|
|
58
|
+
showScopeIndicator?: boolean;
|
|
59
|
+
class?: string;
|
|
60
60
|
};
|
|
61
61
|
|
|
62
62
|
export function WidgetIdentity(_props: WidgetIdentityProps) {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
63
|
+
const props = mergeProps({ iconSize: "sm" as const, showVersionInline: true }, _props);
|
|
64
|
+
return (
|
|
65
|
+
<div data-slot="widget-identity" class={cn("flex min-w-0 items-center gap-3", props.class)}>
|
|
66
|
+
<SectionIcon size={props.iconSize} tone={props.iconTone}>
|
|
67
|
+
<Show when={props.widget.icon} fallback={<Icon icon="lucide:package" />}>
|
|
68
|
+
{(icon) => <Icon icon={icon()} />}
|
|
69
|
+
</Show>
|
|
70
|
+
</SectionIcon>
|
|
71
|
+
<div data-slot="widget-identity-headings" class="flex min-w-0 flex-1 flex-col gap-0.5">
|
|
72
|
+
<div data-slot="widget-identity-headline" class="flex items-center gap-2">
|
|
73
|
+
<SectionSubtitle class="truncate">
|
|
74
|
+
{props.widget.displayName || props.widget.name}
|
|
75
|
+
</SectionSubtitle>
|
|
76
|
+
<Show when={props.showVersionInline && props.widget.latestVersion}>
|
|
77
|
+
<span class="text-muted-foreground shrink-0 font-mono text-xs tabular-nums">
|
|
78
|
+
v{props.widget.latestVersion}
|
|
79
|
+
</span>
|
|
80
|
+
</Show>
|
|
81
|
+
<WidgetTrustBadge isOfficial={!!props.widget.isOfficial} />
|
|
82
82
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
83
|
+
<Show when={props.widget.isUnlisted}>
|
|
84
|
+
<Badge tone="var(--warning)">Unlisted</Badge>
|
|
85
|
+
</Show>
|
|
86
|
+
<Show when={props.widget.isUnpublished}>
|
|
87
|
+
<Badge tone="var(--destructive)">Not published</Badge>
|
|
88
|
+
</Show>
|
|
89
|
+
</div>
|
|
90
|
+
<div data-slot="widget-identity-scope" class="flex min-w-0 flex-wrap items-center gap-1.5">
|
|
91
|
+
<span class="text-muted-foreground truncate font-mono text-xs">
|
|
92
|
+
@{props.widget.scope}/{props.widget.name}
|
|
93
|
+
</span>
|
|
94
|
+
<Show when={props.showScopeIndicator}>
|
|
95
|
+
<ScopeIndicator
|
|
96
|
+
scope={props.widget.scope}
|
|
97
|
+
type={props.widget.ownerType ?? "personal"}
|
|
98
|
+
/>
|
|
99
|
+
</Show>
|
|
100
|
+
</div>
|
|
101
|
+
</div>
|
|
102
|
+
</div>
|
|
103
|
+
);
|
|
104
104
|
}
|
|
105
105
|
|
|
106
106
|
/** Downloads (+ optional version counts) meta cluster. */
|
|
107
107
|
export function WidgetMeta(props: {
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
108
|
+
widget: WidgetSummary;
|
|
109
|
+
/** Append `N versions`. */
|
|
110
|
+
showVersions?: boolean;
|
|
111
|
+
/** Append `v{latestVersion}` (the tile footer's shape). */
|
|
112
|
+
showLatestVersion?: boolean;
|
|
113
|
+
class?: string;
|
|
114
114
|
}): JSX.Element {
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
115
|
+
return (
|
|
116
|
+
<div
|
|
117
|
+
data-slot="widget-meta"
|
|
118
|
+
class={cn("text-muted-foreground flex items-center gap-4 text-xs", props.class)}
|
|
119
|
+
>
|
|
120
|
+
<Show when={props.widget.downloadCount != null}>
|
|
121
|
+
<span class="flex items-center gap-1 tabular-nums">
|
|
122
|
+
<Icon icon="lucide:arrow-down-to-line" width={12} height={12} class="size-3" />
|
|
123
|
+
{formatWidgetCount(props.widget.downloadCount)}
|
|
124
|
+
</span>
|
|
125
|
+
</Show>
|
|
126
|
+
<Show when={props.showVersions && props.widget.versionCount != null}>
|
|
127
|
+
<span class="flex items-center gap-1 tabular-nums">
|
|
128
|
+
<Icon icon="lucide:layers" width={12} height={12} class="size-3" />
|
|
129
|
+
{props.widget.versionCount} versions
|
|
130
|
+
</span>
|
|
131
|
+
</Show>
|
|
132
|
+
<Show when={props.showLatestVersion && props.widget.latestVersion}>
|
|
133
|
+
<span class="tabular-nums">v{props.widget.latestVersion}</span>
|
|
134
|
+
</Show>
|
|
135
|
+
</div>
|
|
136
|
+
);
|
|
137
137
|
}
|
|
@@ -14,24 +14,24 @@ import { Show } from "solid-js";
|
|
|
14
14
|
* name, so it now matches the official marker's compact icon form.
|
|
15
15
|
*/
|
|
16
16
|
export function WidgetTrustBadge(props: { isOfficial: boolean }) {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
17
|
+
return (
|
|
18
|
+
<Show
|
|
19
|
+
when={props.isOfficial}
|
|
20
|
+
fallback={
|
|
21
|
+
<span class="text-muted-foreground inline-flex items-center" title="Community widget">
|
|
22
|
+
<svg width="14" height="14" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true">
|
|
23
|
+
<path d="M12 5.5A3.5 3.5 0 0 1 15.5 9a3.5 3.5 0 0 1-3.5 3.5A3.5 3.5 0 0 1 8.5 9 3.5 3.5 0 0 1 12 5.5M5 8c.56 0 1.08.15 1.53.42-.15 1.43.27 2.85 1.13 3.96C7.16 13.34 6.16 14 5 14a3 3 0 0 1-3-3 3 3 0 0 1 3-3m14 0a3 3 0 0 1 3 3 3 3 0 0 1-3 3c-1.16 0-2.16-.66-2.66-1.62a5.54 5.54 0 0 0 1.13-3.96c.45-.27.97-.42 1.53-.42M5.5 18.25c0-2.07 2.91-3.75 6.5-3.75s6.5 1.68 6.5 3.75V20h-13v-1.75M0 20v-1.5c0-1.39 1.89-2.56 4.45-2.9-.59.68-.95 1.62-.95 2.65V20H0m24 0h-3.5v-1.75c0-1.03-.36-1.97-.95-2.65 2.56.34 4.45 1.51 4.45 2.9V20Z" />
|
|
24
|
+
</svg>
|
|
25
|
+
<span class="sr-only">Community</span>
|
|
26
|
+
</span>
|
|
27
|
+
}
|
|
28
|
+
>
|
|
29
|
+
<span class="text-primary inline-flex items-center" title="Official GlassHome widget">
|
|
30
|
+
<svg width="14" height="14" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true">
|
|
31
|
+
<path d="M23 12l-2.44-2.78.34-3.68-3.61-.82-1.89-3.18L12 3 8.6 1.54 6.71 4.72l-3.61.81.34 3.68L1 12l2.44 2.78-.34 3.69 3.61.82 1.89 3.18L12 21l3.4 1.46 1.89-3.18 3.61-.82-.34-3.68L23 12m-13 5l-4-4 1.41-1.41L10 14.17l6.59-6.59L18 9l-8 8z" />
|
|
32
|
+
</svg>
|
|
33
|
+
<span class="sr-only">Official</span>
|
|
34
|
+
</span>
|
|
35
|
+
</Show>
|
|
36
|
+
);
|
|
37
37
|
}
|