@glasshome/ui 1.9.0 → 1.10.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.
@@ -1,4 +1,4 @@
1
- import { Icon } from "@iconify-icon/solid";
2
1
  import { type Component, type ComponentProps } from "solid-js";
2
+ import { Icon } from "./icon.js";
3
3
  declare const Spinner: Component<Omit<ComponentProps<typeof Icon>, "icon">>;
4
4
  export { Spinner };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@glasshome/ui",
3
- "version": "1.9.0",
3
+ "version": "1.10.0",
4
4
  "description": "SolidJS component library for GlassHome, built on Kobalte",
5
5
  "type": "module",
6
6
  "homepage": "https://github.com/glasshome/ui#readme",
@@ -29,11 +29,13 @@
29
29
  "exports": {
30
30
  ".": {
31
31
  "@glasshome/source": "./src/index.ts",
32
+ "solid": "./src/index.ts",
32
33
  "types": "./dist/index.d.ts",
33
34
  "import": "./dist/index.js"
34
35
  },
35
36
  "./solid": {
36
37
  "@glasshome/source": "./src/solid/index.ts",
38
+ "solid": "./src/solid/index.ts",
37
39
  "types": "./dist/solid/index.d.ts",
38
40
  "import": "./dist/solid/index.js"
39
41
  },
@@ -42,7 +44,6 @@
42
44
  "types": "./dist/tokens/index.d.ts",
43
45
  "import": "./dist/tokens/index.js"
44
46
  },
45
- "./astro/*": "./src/astro/*",
46
47
  "./styles": "./src/styles/globals.css",
47
48
  "./package.json": "./package.json",
48
49
  "./styles/theme": "./src/styles/theme.css",
@@ -50,7 +51,6 @@
50
51
  },
51
52
  "files": [
52
53
  "dist",
53
- "src/astro",
54
54
  "src/lib",
55
55
  "src/styles",
56
56
  "scripts",
@@ -72,19 +72,18 @@
72
72
  "gallery:shots": "node dev/shoot.mjs"
73
73
  },
74
74
  "peerDependencies": {
75
- "astro": ">=4",
76
75
  "solid-js": "^1.9.9",
77
76
  "tailwindcss": "^4.1.13",
78
77
  "tw-animate-css": "^1.4.0"
79
78
  },
80
79
  "dependencies": {
81
- "@iconify-icon/solid": "^3.0.3",
82
80
  "@kobalte/core": "^0.13.13",
83
81
  "clsx": "^2.1.1",
84
82
  "cva": "^1.0.0-beta.4",
85
83
  "embla-carousel": "^8.5.1",
86
84
  "embla-carousel-autoplay": "^8.5.1",
87
85
  "embla-carousel-fade": "^8.5.1",
86
+ "iconify-icon": "^3.0.2",
88
87
  "solid-sonner": "^0.3.1",
89
88
  "tailwind-merge": "^3.4.0"
90
89
  },
@@ -111,10 +110,5 @@
111
110
  "url": "git+https://github.com/glasshome/ui.git"
112
111
  },
113
112
  "author": "GlassHome Labs",
114
- "license": "MIT",
115
- "peerDependenciesMeta": {
116
- "astro": {
117
- "optional": true
118
- }
119
- }
113
+ "license": "MIT"
120
114
  }
@@ -1,11 +1,7 @@
1
1
  import { NEUTRAL_KNOBS } from "./glass-tone.js";
2
- import { CHIP } from "./pill-classes.js";
3
2
 
4
3
  export const BADGE_DEFAULT_TONE = "var(--primary)";
5
4
 
6
- /** @deprecated CHIP from lib/pill-classes.ts */
7
- export const BADGE_TONE_CLASS = CHIP;
8
-
9
5
  /* The neutral chip also drops the tint sheen: at chip size it reads as a
10
6
  * milky cap over the text. */
11
7
  export const BADGE_NEUTRAL_KNOBS = `${NEUTRAL_KNOBS} [--glass-light:0.08]`;
@@ -1,6 +1,5 @@
1
- /* Shared by the Solid <Carousel> and astro/Carousel.astro so the two render the
2
- * same markup. Astro renders slides server-side (SEO, LCP) and enhances them on
3
- * the client with the same embla engine. */
1
+ /* Exported from the root entry so a server-rendered carousel (hub's content
2
+ * pages) shares the Solid <Carousel> markup. */
4
3
  import { POSITION_BAR, POSITION_BAR_LIT } from "./position-bar-classes.js";
5
4
 
6
5
  export type CarouselTransition = "slide" | "fade" | "wipe";
@@ -1,9 +0,0 @@
1
- /**
2
- * Client enhancement for astro/Carousel.astro. The markup is already in the
3
- * server HTML; this only adds behaviour, so the slides stay visible (and
4
- * indexable) if the script never runs.
5
- *
6
- * Emits `carousel:select` with `{ index }` so a host page can sync its own
7
- * chrome (labels, lightboxes) without owning the carousel.
8
- */
9
- export declare function initCarousels(root?: ParentNode): void;
@@ -1,63 +0,0 @@
1
- ---
2
- import {
3
- ALERT_CLASS,
4
- ALERT_CONTENT_CLASS,
5
- ALERT_DESCRIPTION_CLASS,
6
- ALERT_ICON_BG_CLASS,
7
- ALERT_ICON_PATHS,
8
- ALERT_TITLE_CLASS,
9
- ALERT_TONES,
10
- type AlertTone,
11
- alertIconBgStyle,
12
- cn,
13
- glassToneText,
14
- } from "@glasshome/ui";
15
- /**
16
- * Static tone alert/callout for Astro / SSR pages — the same `ALERT_TONES` table
17
- * and surface recipe the Solid <Alert> and hub's docs Callout use, rendered as
18
- * plain HTML with zero JS and the lucide glyph inlined as SVG (no icon runtime).
19
- * Drop this into `.astro` markup instead of hand-writing a
20
- * `rounded-lg border border-primary/40 bg-primary/10` note box.
21
- */
22
- import type { HTMLAttributes } from "astro/types";
23
-
24
- interface Props extends HTMLAttributes<"div"> {
25
- tone?: AlertTone;
26
- /** Bold heading line. Optional. */
27
- title?: string;
28
- }
29
-
30
- const { tone = "info", title, class: className, ...rest } = Astro.props;
31
- const t = ALERT_TONES[tone];
32
-
33
- const surfaceStyle = `--glass-tone:${t.color};color:var(--foreground)`;
34
-
35
- const iconBgStyle = Object.entries(alertIconBgStyle(t.color))
36
- .map(([k, v]) => `${k}:${v}`)
37
- .join(";");
38
- ---
39
-
40
- <div
41
- data-slot="alert"
42
- role={tone === "destructive" ? "alert" : "status"}
43
- class={cn(ALERT_CLASS, "glass glass-tint", className)}
44
- style={surfaceStyle}
45
- {...rest}
46
- >
47
- <span class={ALERT_ICON_BG_CLASS} style={iconBgStyle} aria-hidden="true">
48
- <svg
49
- xmlns="http://www.w3.org/2000/svg"
50
- viewBox="0 0 24 24"
51
- fill="none"
52
- stroke="currentColor"
53
- stroke-width="2"
54
- stroke-linecap="round"
55
- stroke-linejoin="round"
56
- set:html={ALERT_ICON_PATHS[tone]}
57
- />
58
- </span>
59
- <div class={ALERT_CONTENT_CLASS}>
60
- {title && <p data-slot="alert-title" class={ALERT_TITLE_CLASS} style={`color:${glassToneText(t.color)}`}>{title}</p>}
61
- <div data-slot="alert-description" class={ALERT_DESCRIPTION_CLASS}><slot /></div>
62
- </div>
63
- </div>
@@ -1,18 +0,0 @@
1
- ---
2
- import type { HTMLTag, Polymorphic } from "astro/types";
3
- import { BADGE_DEFAULT_TONE, BADGE_TONE_CLASS } from "../lib/badge-tone";
4
- import { cn } from "../lib/utils";
5
-
6
- // Polymorphic because `as` changes the rendered tag: everything not
7
- // destructured below is spread onto it, so that tag's attributes must be
8
- // accepted.
9
- type Props<Tag extends HTMLTag = "span"> = Polymorphic<{ as: Tag }> & {
10
- tone?: string;
11
- };
12
-
13
- const { tone = BADGE_DEFAULT_TONE, as: Tag = "span", class: className, ...rest } = Astro.props;
14
- ---
15
-
16
- <Tag data-slot="badge" class={cn(BADGE_TONE_CLASS, "glass glass-tint", className)} style={`--glass-tone:${tone}`} {...rest}>
17
- <slot />
18
- </Tag>
@@ -1,47 +0,0 @@
1
- ---
2
- import { buttonVariants, cn } from "@glasshome/ui";
3
- import type { HTMLAttributes } from "astro/types";
4
-
5
- /**
6
- * Static button/CTA for Astro / SSR pages — the same `buttonVariants` recipe the
7
- * Solid <Button> uses, rendered as a plain <a>/<button> with zero JS. Drop this
8
- * into `.astro` markup instead of hand-writing a `rounded-full bg-primary px-6`
9
- * pill.
10
- *
11
- * Renders an <a> when `href` is set, else a <button>. `size` defaults to `none`
12
- * (sizeless: color + shape only) so marketing CTAs supply their own height and
13
- * padding via `class`, matching how the hub pill tokens are used.
14
- */
15
-
16
- // Renders <a> when href is set, <button> otherwise. `type` is omitted from the
17
- // button attributes because this component narrows it to the three form values.
18
- type Props = Omit<HTMLAttributes<"button">, "type"> &
19
- Partial<Pick<HTMLAttributes<"a">, "target" | "rel" | "download">> & {
20
- variant?: "default" | "destructive" | "outline" | "secondary" | "ghost" | "link";
21
- size?: "default" | "sm" | "lg" | "icon" | "none";
22
- href?: string;
23
- type?: "button" | "submit" | "reset";
24
- };
25
-
26
- const {
27
- variant = "default",
28
- size = "none",
29
- href,
30
- type = "button",
31
- class: className,
32
- ...rest
33
- } = Astro.props;
34
- const cls = cn(buttonVariants({ variant, size }), className);
35
- ---
36
-
37
- {
38
- href ? (
39
- <a data-slot="button" href={href} class={cls} {...rest}>
40
- <slot />
41
- </a>
42
- ) : (
43
- <button data-slot="button" type={type} class={cls} {...rest}>
44
- <slot />
45
- </button>
46
- )
47
- }
@@ -1,48 +0,0 @@
1
- ---
2
- import type { HTMLAttributes } from "astro/types";
3
- import {
4
- CARD_INTERACTIVE,
5
- CARD_PADDING,
6
- CARD_SURFACE,
7
- CARD_SURFACE_OPAQUE,
8
- type CardPadding,
9
- } from "../lib/card-classes";
10
- import { cn } from "../lib/utils";
11
-
12
- // Everything not destructured below is spread onto the rendered tag, so its
13
- // attributes must be accepted. Not Polymorphic<>: call sites pick the tag at
14
- // runtime (`as={href ? "a" : "div"}`), which widens to a union that a generic
15
- // tag parameter cannot resolve. The div attributes are the base; the handful
16
- // belonging to the other tags this is used as are named.
17
- interface Props
18
- extends HTMLAttributes<"div">,
19
- Partial<Pick<HTMLAttributes<"a">, "href" | "target" | "rel">>,
20
- Partial<Pick<HTMLAttributes<"details">, "name" | "open">> {
21
- as?: keyof HTMLElementTagNameMap;
22
- interactive?: boolean;
23
- opaque?: boolean;
24
- padding?: CardPadding;
25
- type?: "button" | "submit" | "reset";
26
- }
27
-
28
- const {
29
- as: Tag = "div",
30
- interactive = false,
31
- opaque = false,
32
- padding = "none",
33
- class: className,
34
- ...rest
35
- } = Astro.props;
36
-
37
- const classes = cn(
38
- opaque ? CARD_SURFACE_OPAQUE : CARD_SURFACE,
39
- "rounded-[var(--radius)]",
40
- CARD_PADDING[padding],
41
- interactive && CARD_INTERACTIVE,
42
- className,
43
- );
44
- ---
45
-
46
- <Tag data-slot="card" class={classes} {...rest}>
47
- <slot />
48
- </Tag>
@@ -1,82 +0,0 @@
1
- ---
2
- /**
3
- * Server-rendered carousel. Slides live in the HTML, so they are indexable and
4
- * the first one is the LCP image; the client script only adds behaviour.
5
- * Use this on content pages; use the Solid <Carousel> inside an app.
6
- *
7
- * Slides go in the default slot as <CarouselItem>-shaped elements, or pass
8
- * `count` to have dots rendered for you.
9
- */
10
- import type { HTMLAttributes } from "astro/types";
11
- import {
12
- CAROUSEL_DOTS,
13
- CAROUSEL_VIEWPORT,
14
- type CarouselTransition,
15
- carouselDot,
16
- carouselTrack,
17
- } from "../lib/carousel-classes";
18
- import { cn } from "../lib/utils";
19
-
20
- // Extends div attributes because everything not destructured below is spread
21
- // onto the root; without it a caller's style/role/aria-* is a type error while
22
- // still working at runtime.
23
- interface Props extends HTMLAttributes<"div"> {
24
- transition?: CarouselTransition;
25
- /** Advance every N ms. Skipped under prefers-reduced-motion. */
26
- autoplay?: number;
27
- loop?: boolean;
28
- /** Slide count; when set, dots are rendered. */
29
- count?: number;
30
- }
31
-
32
- const {
33
- transition = "slide",
34
- autoplay,
35
- loop = false,
36
- count,
37
- class: className,
38
- ...rest
39
- } = Astro.props;
40
- ---
41
-
42
- <div
43
- data-carousel
44
- data-carousel-transition={transition}
45
- data-carousel-autoplay={autoplay}
46
- data-carousel-loop={loop ? "" : undefined}
47
- class={cn("relative", className)}
48
- role="region"
49
- aria-roledescription="carousel"
50
- {...rest}
51
- >
52
- <div data-carousel-viewport class={CAROUSEL_VIEWPORT}>
53
- <div class={carouselTrack(transition)}>
54
- <slot />
55
- </div>
56
- </div>
57
-
58
- <slot name="controls" />
59
-
60
- {
61
- count && (
62
- <div class={CAROUSEL_DOTS} data-carousel-dots>
63
- {Array.from({ length: count }, (_, i) => (
64
- <button
65
- type="button"
66
- data-carousel-dot
67
- aria-label={`Go to slide ${i + 1}`}
68
- aria-current={i === 0}
69
- class={carouselDot(i === 0)}
70
- />
71
- ))}
72
- </div>
73
- )
74
- }
75
- </div>
76
-
77
- <script>
78
- import { initCarousels } from "../lib/carousel-init";
79
-
80
- initCarousels();
81
- document.addEventListener("astro:page-load", () => initCarousels());
82
- </script>
@@ -1,73 +0,0 @@
1
- ---
2
- import {
3
- cn,
4
- LOGO_DEFAULT_SIZE,
5
- LOGO_DEFAULT_SRC,
6
- LOGO_DEFAULT_SUB,
7
- LOGO_MARK_CLASS,
8
- LOGO_MARK_PX,
9
- LOGO_NAME_CLASS,
10
- LOGO_ROOT_CLASS,
11
- LOGO_SIZES,
12
- LOGO_STACK_CLASS,
13
- LOGO_SUB_CLASS,
14
- type LogoSize,
15
- } from "@glasshome/ui";
16
- /**
17
- * The GlassHome lockup for Astro / SSR pages — the same spec the Solid <Logo>
18
- * renders, as plain HTML with zero JS. Use this instead of hand-building a
19
- * mark + "GlassHome" + sub-line stack; that is how the lockup ended up in six
20
- * shapes across the repos.
21
- *
22
- * `href` renders the whole lockup as a link. The `sub` slot replaces the
23
- * sub-brand line for surfaces that animate over it (e.g. hub's launch
24
- * countdown cross-fade); it inherits nothing, so pass LOGO_SUB_CLASS yourself.
25
- */
26
- import type { HTMLAttributes } from "astro/types";
27
-
28
- // Renders <a> when href is set, <div> otherwise, so the div attributes are the
29
- // common base and the anchor-only ones a lockup link actually wants are added.
30
- interface Props
31
- extends HTMLAttributes<"div">,
32
- Partial<Pick<HTMLAttributes<"a">, "target" | "rel">> {
33
- /** Sub-brand line. Defaults to "Dash". */
34
- sub?: string;
35
- size?: LogoSize;
36
- /** Renders the lockup as a link when set. */
37
- href?: string;
38
- /** Override the mark asset. Both apps serve the default path. */
39
- src?: string;
40
- /** Extra classes for the mark, e.g. a hover transform. */
41
- markClass?: string;
42
- }
43
-
44
- const {
45
- sub = LOGO_DEFAULT_SUB,
46
- size = LOGO_DEFAULT_SIZE,
47
- href,
48
- src = LOGO_DEFAULT_SRC,
49
- class: className,
50
- markClass,
51
- ...rest
52
- } = Astro.props;
53
-
54
- const s = LOGO_SIZES[size];
55
- const px = LOGO_MARK_PX[size];
56
- const Tag = href ? "a" : "div";
57
- ---
58
-
59
- <Tag data-slot="logo" class={cn(LOGO_ROOT_CLASS, s.gap, className)} href={href} {...rest}>
60
- <img
61
- src={src}
62
- alt=""
63
- width={px}
64
- height={px}
65
- class={cn(LOGO_MARK_CLASS, s.mark, markClass)}
66
- />
67
- <span class={LOGO_STACK_CLASS}>
68
- <span data-slot="logo-name" class={cn(s.name, LOGO_NAME_CLASS)}>GlassHome</span>
69
- <slot name="sub">
70
- <span data-slot="logo-sub" class={cn(s.sub, LOGO_SUB_CLASS)}>{sub}</span>
71
- </slot>
72
- </span>
73
- </Tag>
@@ -1,33 +0,0 @@
1
- ---
2
- /**
3
- * Static metallic tier chip for Astro / SSR pages (PRO / EARLY BIRD / CREATOR /
4
- * FOUNDER) — the same tier tokens the Solid <TierBadge> uses, rendered as plain
5
- * HTML with zero JS. One family; only the hi/lo/text triplet changes per tier.
6
- */
7
- import type { HTMLAttributes } from "astro/types";
8
- import { TIER_BADGE_CLASS, tierBadgeStyle } from "../lib/tier-badge";
9
- import { cn } from "../lib/utils";
10
-
11
- interface Props extends HTMLAttributes<"span"> {
12
- /** Gradient high stop (the near end of the diagonal sweep, and by default
13
- * the far end too). */
14
- hi: string;
15
- /** Gradient low stop (the dip). */
16
- lo: string;
17
- /** Dark label color. */
18
- text: string;
19
- /** Far end of the sweep. Default: `hi` (symmetric brushed look). */
20
- end?: string;
21
- /** Where `lo` sits, in percent. Default: 50. */
22
- stop?: number;
23
- }
24
-
25
- const { hi, lo, text, end, stop, class: className, ...rest } = Astro.props;
26
- const style = Object.entries(tierBadgeStyle(hi, lo, text, { end, stop }))
27
- .map(([k, v]) => `${k}:${v}`)
28
- .join(";");
29
- ---
30
-
31
- <span data-slot="tier-badge" class={cn(TIER_BADGE_CLASS, className)} style={style} {...rest}>
32
- <slot />
33
- </span>
@@ -1,87 +0,0 @@
1
- import EmblaCarousel from "embla-carousel";
2
- import Autoplay from "embla-carousel-autoplay";
3
- import Fade from "embla-carousel-fade";
4
- import { type CarouselTransition, carouselDot } from "./carousel-classes.js";
5
-
6
- /**
7
- * Client enhancement for astro/Carousel.astro. The markup is already in the
8
- * server HTML; this only adds behaviour, so the slides stay visible (and
9
- * indexable) if the script never runs.
10
- *
11
- * Emits `carousel:select` with `{ index }` so a host page can sync its own
12
- * chrome (labels, lightboxes) without owning the carousel.
13
- */
14
- export function initCarousels(root: ParentNode = document) {
15
- const roots = Array.from(root.querySelectorAll("[data-carousel]")) as HTMLElement[];
16
- for (const el of roots) {
17
- if (el.dataset.carouselReady) continue;
18
- el.dataset.carouselReady = "1";
19
-
20
- const viewport = el.querySelector("[data-carousel-viewport]") as HTMLElement | null;
21
- if (!viewport) continue;
22
-
23
- const transition = (el.dataset.carouselTransition ?? "slide") as CarouselTransition;
24
- const autoplayMs = Number(el.dataset.carouselAutoplay ?? 0);
25
- const loop = el.dataset.carouselLoop === "";
26
- const reduced = window.matchMedia("(prefers-reduced-motion: reduce)").matches;
27
-
28
- const plugins = [];
29
- if (transition !== "slide") plugins.push(Fade());
30
- if (autoplayMs > 0 && !reduced) {
31
- // Manual nav should not kill autoplay for good; hovering pauses it and
32
- // leaving resumes, which is what a hero carousel wants.
33
- plugins.push(
34
- Autoplay({
35
- delay: autoplayMs,
36
- stopOnInteraction: false,
37
- stopOnMouseEnter: true,
38
- stopOnFocusIn: true,
39
- }),
40
- );
41
- }
42
-
43
- const embla = EmblaCarousel(viewport, { loop }, plugins);
44
- const dots = Array.from(el.querySelectorAll("[data-carousel-dot]")) as HTMLButtonElement[];
45
-
46
- let previous = -1;
47
- const onSelect = () => {
48
- const index = embla.selectedScrollSnap();
49
- embla.slideNodes().forEach((node, i) => {
50
- node.toggleAttribute("data-selected", i === index);
51
- // The outgoing slide stays visible one layer down until the sweep lands.
52
- node.toggleAttribute("data-prev", i === previous && i !== index);
53
- });
54
- previous = index;
55
- dots.forEach((dot, i) => {
56
- dot.className = carouselDot(i === index);
57
- dot.setAttribute("aria-current", String(i === index));
58
- });
59
- el.dispatchEvent(new CustomEvent("carousel:select", { detail: { index }, bubbles: true }));
60
- };
61
-
62
- el.addEventListener("keydown", (e) => {
63
- const key = (e as KeyboardEvent).key;
64
- if (key !== "ArrowLeft" && key !== "ArrowRight") return;
65
- e.preventDefault();
66
- if (key === "ArrowLeft") embla.scrollPrev();
67
- else embla.scrollNext();
68
- });
69
-
70
- // A host that covers the carousel (a lightbox) pauses it, so the slide
71
- // does not change behind the overlay.
72
- const autoplay = (embla.plugins() as { autoplay?: { play: () => void; stop: () => void } })
73
- .autoplay;
74
- el.addEventListener("carousel:pause", () => autoplay?.stop());
75
- el.addEventListener("carousel:resume", () => autoplay?.play());
76
-
77
- dots.forEach((dot, i) => {
78
- dot.addEventListener("click", () => embla.scrollTo(i));
79
- });
80
- el.querySelector("[data-carousel-prev]")?.addEventListener("click", () => embla.scrollPrev());
81
- el.querySelector("[data-carousel-next]")?.addEventListener("click", () => embla.scrollNext());
82
-
83
- onSelect();
84
- embla.on("select", onSelect);
85
- embla.on("reInit", onSelect);
86
- }
87
- }