horizon-design 2.0.0 → 2.0.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/README.md CHANGED
@@ -330,7 +330,7 @@ variants).
330
330
  | [`Carousel`](https://play-horizon.github.io/horizon-design/carousel) | A horizontal slideshow of `slides` with previous and next controls and indicators (Ark Carousel); `label`, required, names it, and Ark `translations`, required, name the slides and the controls and the roles of the carousel and its slides. The arrows and dots show their names in tooltips. |
331
331
  | [`DataList`](https://play-horizon.github.io/horizon-design/data-list) | A list of label and value pairs (`items`), such as the details of a game. |
332
332
  | [`Frame`](https://play-horizon.github.io/horizon-design/frame) | A window-like frame around content, such as a code sample or a screenshot; with a `title`, a title bar shows it, with three window controls at its end. |
333
- | [`GameCard`](https://play-horizon.github.io/horizon-design/game-card) | A game in a list: its 16:9 thumbnail and its name, the card's link (`href`) or button (`onclick`); the `feature` variant is the larger Continue playing card, with the icon and an `action` (Play). |
333
+ | [`GameCard`](https://play-horizon.github.io/horizon-design/game-card) | A game in a list, its 16:9 thumbnail and its name: a link with `href`, a button with `onclick`, either covering the whole card; a plain display with neither. The `feature` variant is the larger Continue playing card, with the icon and an `action` (Play). |
334
334
  | [`GameHero`](https://play-horizon.github.io/horizon-design/game-hero) | The top of a game page: the game's 16:9 thumbnail as a banner that fades into the page, with the square icon, the name, a `byline` (the creator) and the game's `tags` over its bottom, and a `top` slot at its top left (Back, a `Button` of the `art` variant). |
335
335
  | [`Item`](https://play-horizon.github.io/horizon-design/item) | A row of a list, laying out what it is given (media, a title, a description, actions) in a line: a link with `href`, a button with `onclick` (its content then holds no other control), a plain row with neither. |
336
336
  | [`Kbd`](https://play-horizon.github.io/horizon-design/kbd) | A keyboard key or shortcut, such as `Ctrl K`, drawn as a raised key. With `command` (its names, translated), the platform's command key: ⌘ on Apple's platforms, Ctrl elsewhere, from the user agent once mounted, without changing size. `isApplePlatform` tells the app which key its shortcuts use. |
@@ -370,7 +370,7 @@ variants).
370
370
  | [`CommandPalette`](https://play-horizon.github.io/horizon-design/command-palette) | The command palette: a dialog at the top of the window with a search field and every command that matches what is typed (each word whole, ignoring case and accents, through Ark's `useFilter`), ranked by [fuzzysort](https://github.com/farzher/fuzzysort), label matches first, each with its shortcut. The field and the virtualised list are an Ark combobox: Up, Down, Home and End move through the commands that can run, Enter runs one, Escape closes. `open` binds, `onRun` runs the chosen command once the palette has finished closing, so the command can move the focus, and `label` and `emptyText` are required. |
371
371
  | [`LinkOverlay`](https://play-horizon.github.io/horizon-design/link-overlay) | The link of a `LinkBox`, stretched over the whole box so a click anywhere follows it, while the box's other links and controls stay usable. |
372
372
  | [`Pagination`](https://play-horizon.github.io/horizon-design/pagination) | Page links with previous and next for `count` items, required (Ark Pagination); `page` binds the current page, and Ark `translations` name its controls; the built-in arrows show their names as tooltips. `children` replaces the built-in controls with the parts `PaginationPrevTrigger` and `PaginationNextTrigger` (an icon-only one takes a `label`, its tooltip), `PaginationItem`, `PaginationEllipsis` and `PaginationContext`, which reads its state. |
373
- | [`Sidebar`](https://play-horizon.github.io/horizon-design/sidebar) | An app's navigation sidebar: a sunken column with an optional header (the brand), the navigation itself (`SidebarSection` and `SidebarItem`, named by `label`) and an optional footer (the account); `collapsed` narrows it to its icons, and each item then shows its text as a tooltip. |
373
+ | [`Sidebar`](https://play-horizon.github.io/horizon-design/sidebar) | An app's navigation sidebar: a sunken column with an optional header (the brand), then the navigation landmark (named by `label`), holding the navigation itself (`SidebarSection` and `SidebarItem`) and an optional footer (the account's entries); `collapsed` narrows it to its icons, and each item then shows its text as a tooltip. |
374
374
  | [`SkipNav`](https://play-horizon.github.io/horizon-design/skip-nav) | A link, shown on keyboard focus, that skips to the page's main content. |
375
375
  | [`Steps`](https://play-horizon.github.io/horizon-design/steps) | A multi-step flow (Ark Steps): the `steps` (each an `id`, a `title` and its `content`), the current step's content, and back and next buttons named by `prevLabel` and `nextLabel`, required; `step` binds the current step. |
376
376
 
@@ -1,8 +1,9 @@
1
1
  <!--
2
2
  @component
3
- A game in a list: its 16:9 thumbnail and its name, the card's link (`href`) or button
4
- (`onclick`). The link covers the whole card, while controls drawn on it (`action`, `corner`) stay
5
- their own buttons.
3
+ A game in a list: its 16:9 thumbnail and its name. It is interactive only when given something to
4
+ do: with `href`, the name is a link; with `onclick`, a button; either covers the whole card (hover
5
+ lift, focus ring), while controls drawn on it (`action`, `corner`) stay their own buttons. With
6
+ neither, it is a plain display: no hover, no focus.
6
7
 
7
8
  - `default`: the art, then the name and a `meta` line (tags, status) under it; `overlay` draws
8
9
  at the art's top left (a `PlayerCount`), `corner` at its top right (an `AvatarStack`).
@@ -28,11 +29,11 @@ The art carries the colour; without a thumbnail, a neutral fill stands in.
28
29
  action,
29
30
  class: className = ''
30
31
  }: {
31
- /** The game's name: the card's link text. */
32
+ /** The game's name: the card's link or button text. */
32
33
  name: string;
33
- /** Where the card leads. */
34
+ /** Where the card leads, already resolved: its name is a link. */
34
35
  href?: string;
35
- /** Called when the card is chosen, when it has no `href`. */
36
+ /** Called when the card is chosen, when it has no `href`: its name is a button. */
36
37
  onclick?: () => void;
37
38
  /** The 16:9 thumbnail's URL. */
38
39
  thumbnail?: string;
@@ -52,6 +53,9 @@ The art carries the colour; without a thumbnail, a neutral fill stands in.
52
53
  class?: string;
53
54
  } = $props();
54
55
 
56
+ const interactive = $derived(Boolean(href || onclick));
57
+ // The art lifts on hover only when the card leads somewhere.
58
+ const lift = $derived(interactive && 'group-hover:-translate-y-0.5 group-hover:shadow-md');
55
59
  // The link's ::after covers the card, so a click anywhere follows it; focus rings the card.
56
60
  const stretched =
57
61
  'outline-none after:absolute after:inset-0 after:z-1 after:rounded-lg focus-visible:after:ring-2 focus-visible:after:ring-primary focus-visible:after:ring-offset-2 focus-visible:after:ring-offset-background';
@@ -61,15 +65,25 @@ The art carries the colour; without a thumbnail, a neutral fill stands in.
61
65
  {#if href}
62
66
  <!-- eslint-disable-next-line svelte/no-navigation-without-resolve -- the app passes an href it has already resolved -->
63
67
  <a {href} class={cn(stretched, extra)}>{name}</a>
64
- {:else}
68
+ {:else if onclick}
65
69
  <button type="button" class={cn(stretched, 'text-left', extra)} {onclick}>{name}</button>
70
+ {:else}
71
+ <span class={extra}>{name}</span>
66
72
  {/if}
67
73
  {/snippet}
68
74
 
69
75
  {#if variant === 'feature'}
70
- <div class={cn('group relative min-w-0', className)} data-slot="game-card" data-variant="feature">
76
+ <div
77
+ class={cn('group relative min-w-0', className)}
78
+ data-slot="game-card"
79
+ data-variant="feature"
80
+ data-interactive={interactive || undefined}
81
+ >
71
82
  <div
72
- class="relative grid aspect-video overflow-hidden rounded-lg bg-raised shadow-sm transition-[transform,box-shadow] duration-200 ease-standard group-hover:-translate-y-0.5 group-hover:shadow-md"
83
+ class={cn(
84
+ 'relative grid aspect-video overflow-hidden rounded-lg bg-raised shadow-sm transition-[transform,box-shadow] duration-200 ease-standard',
85
+ lift
86
+ )}
73
87
  >
74
88
  <!-- The art, its scrim and the name bar share one grid cell, none of them positioned, so
75
89
  the link's ::after is placed against this container and covers the whole card. -->
@@ -104,9 +118,13 @@ The art carries the colour; without a thumbnail, a neutral fill stands in.
104
118
  class={cn('group relative grid min-w-0 content-start gap-2', className)}
105
119
  data-slot="game-card"
106
120
  data-variant="default"
121
+ data-interactive={interactive || undefined}
107
122
  >
108
123
  <div
109
- class="relative aspect-video overflow-hidden rounded-lg bg-raised shadow-sm transition-[transform,box-shadow] duration-200 ease-standard group-hover:-translate-y-0.5 group-hover:shadow-md"
124
+ class={cn(
125
+ 'relative aspect-video overflow-hidden rounded-lg bg-raised shadow-sm transition-[transform,box-shadow] duration-200 ease-standard',
126
+ lift
127
+ )}
110
128
  >
111
129
  {#if thumbnail}
112
130
  <img src={thumbnail} alt="" class="absolute inset-0 size-full object-cover" />
@@ -1,10 +1,10 @@
1
1
  import type { Snippet } from 'svelte';
2
2
  type $$ComponentProps = {
3
- /** The game's name: the card's link text. */
3
+ /** The game's name: the card's link or button text. */
4
4
  name: string;
5
- /** Where the card leads. */
5
+ /** Where the card leads, already resolved: its name is a link. */
6
6
  href?: string;
7
- /** Called when the card is chosen, when it has no `href`. */
7
+ /** Called when the card is chosen, when it has no `href`: its name is a button. */
8
8
  onclick?: () => void;
9
9
  /** The 16:9 thumbnail's URL. */
10
10
  thumbnail?: string;
@@ -24,9 +24,10 @@ type $$ComponentProps = {
24
24
  class?: string;
25
25
  };
26
26
  /**
27
- * A game in a list: its 16:9 thumbnail and its name, the card's link (`href`) or button
28
- * (`onclick`). The link covers the whole card, while controls drawn on it (`action`, `corner`) stay
29
- * their own buttons.
27
+ * A game in a list: its 16:9 thumbnail and its name. It is interactive only when given something to
28
+ * do: with `href`, the name is a link; with `onclick`, a button; either covers the whole card (hover
29
+ * lift, focus ring), while controls drawn on it (`action`, `corner`) stay their own buttons. With
30
+ * neither, it is a plain display: no hover, no focus.
30
31
  *
31
32
  * - `default`: the art, then the name and a `meta` line (tags, status) under it; `overlay` draws
32
33
  * at the art's top left (a `PlayerCount`), `corner` at its top right (an `AvatarStack`).
@@ -1,8 +1,9 @@
1
1
  <!--
2
2
  @component
3
- An app's navigation sidebar: a sunken column with an optional header (the brand), the
4
- navigation itself (`SidebarSection` and `SidebarItem`, named by `label`) and an optional footer
5
- (the account). `collapsed` narrows it to the items' icons: their text and the sections' labels
3
+ An app's navigation sidebar: a sunken column with an optional header (the brand), then the
4
+ navigation landmark (named by `label`), which holds both the navigation itself (`SidebarSection`
5
+ and `SidebarItem`), scrolling when it overflows, and the optional footer pinned beneath it (the
6
+ account's entries). `collapsed` narrows it to the items' icons: their text and the sections' labels
6
7
  are clipped or visually hidden, and still read by assistive technology, and each item shows its
7
8
  text as a tooltip.
8
9
  -->
@@ -31,7 +32,7 @@ text as a tooltip.
31
32
  label?: string;
32
33
  /** The top of the sidebar, such as the brand. */
33
34
  header?: Snippet;
34
- /** The bottom of the sidebar, such as the account. */
35
+ /** The bottom of the sidebar, inside the navigation landmark, such as the account's entries. */
35
36
  footer?: Snippet;
36
37
  /** The navigation: `SidebarSection`s and `SidebarItem`s. */
37
38
  children?: Snippet;
@@ -61,16 +62,20 @@ text as a tooltip.
61
62
  {@render header()}
62
63
  </div>
63
64
  {/if}
64
- <nav
65
- aria-label={label}
66
- class="flex flex-1 flex-col gap-0.5 overflow-x-hidden overflow-y-auto px-2.5 pb-3"
67
- data-slot="sidebar-content"
68
- >
69
- {@render children?.()}
70
- </nav>
71
- {#if footer}
72
- <div class="mx-2.5 border-t border-border px-1 py-3" data-slot="sidebar-footer">
73
- {@render footer()}
65
+ <nav aria-label={label} class="flex min-h-0 flex-1 flex-col">
66
+ <div
67
+ class="flex flex-1 flex-col gap-0.5 overflow-x-hidden overflow-y-auto px-2.5 pb-3"
68
+ data-slot="sidebar-content"
69
+ >
70
+ {@render children?.()}
74
71
  </div>
75
- {/if}
72
+ {#if footer}
73
+ <div
74
+ class="mx-2.5 flex flex-col gap-0.5 border-t border-border py-3"
75
+ data-slot="sidebar-footer"
76
+ >
77
+ {@render footer()}
78
+ </div>
79
+ {/if}
80
+ </nav>
76
81
  </aside>
@@ -11,7 +11,7 @@ type $$ComponentProps = {
11
11
  label?: string;
12
12
  /** The top of the sidebar, such as the brand. */
13
13
  header?: Snippet;
14
- /** The bottom of the sidebar, such as the account. */
14
+ /** The bottom of the sidebar, inside the navigation landmark, such as the account's entries. */
15
15
  footer?: Snippet;
16
16
  /** The navigation: `SidebarSection`s and `SidebarItem`s. */
17
17
  children?: Snippet;
@@ -19,9 +19,10 @@ type $$ComponentProps = {
19
19
  [key: string]: unknown;
20
20
  };
21
21
  /**
22
- * An app's navigation sidebar: a sunken column with an optional header (the brand), the
23
- * navigation itself (`SidebarSection` and `SidebarItem`, named by `label`) and an optional footer
24
- * (the account). `collapsed` narrows it to the items' icons: their text and the sections' labels
22
+ * An app's navigation sidebar: a sunken column with an optional header (the brand), then the
23
+ * navigation landmark (named by `label`), which holds both the navigation itself (`SidebarSection`
24
+ * and `SidebarItem`), scrolling when it overflows, and the optional footer pinned beneath it (the
25
+ * account's entries). `collapsed` narrows it to the items' icons: their text and the sections' labels
25
26
  * are clipped or visually hidden, and still read by assistive technology, and each item shows its
26
27
  * text as a tooltip.
27
28
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "horizon-design",
3
- "version": "2.0.0",
3
+ "version": "2.0.2",
4
4
  "keywords": [
5
5
  "svelte"
6
6
  ],