horizon-design 2.0.0 → 2.0.1

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. |
@@ -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`).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "horizon-design",
3
- "version": "2.0.0",
3
+ "version": "2.0.1",
4
4
  "keywords": [
5
5
  "svelte"
6
6
  ],