@wirecore/wirelayer-recipes 0.4.0 → 0.4.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/dist/avatar.d.ts CHANGED
@@ -72,7 +72,10 @@ export declare const avatar: import("tailwind-variants").TVReturnType<{
72
72
  base: string;
73
73
  };
74
74
  };
75
- /** A button (`as="button"`), e.g. the trigger of a user menu: focus ring, a ring on hover and while open */
75
+ /**
76
+ * A button (`as="button"`), e.g. the trigger of a user menu: focus ring and hover of the IconButton with the
77
+ * same look (see the compound variants), so triggers side by side in a bar behave alike
78
+ */
76
79
  interactive: {
77
80
  true: {
78
81
  base: string[];
@@ -152,7 +155,10 @@ export declare const avatar: import("tailwind-variants").TVReturnType<{
152
155
  base: string;
153
156
  };
154
157
  };
155
- /** A button (`as="button"`), e.g. the trigger of a user menu: focus ring, a ring on hover and while open */
158
+ /**
159
+ * A button (`as="button"`), e.g. the trigger of a user menu: focus ring and hover of the IconButton with the
160
+ * same look (see the compound variants), so triggers side by side in a bar behave alike
161
+ */
156
162
  interactive: {
157
163
  true: {
158
164
  base: string[];
@@ -232,7 +238,10 @@ export declare const avatar: import("tailwind-variants").TVReturnType<{
232
238
  base: string;
233
239
  };
234
240
  };
235
- /** A button (`as="button"`), e.g. the trigger of a user menu: focus ring, a ring on hover and while open */
241
+ /**
242
+ * A button (`as="button"`), e.g. the trigger of a user menu: focus ring and hover of the IconButton with the
243
+ * same look (see the compound variants), so triggers side by side in a bar behave alike
244
+ */
236
245
  interactive: {
237
246
  true: {
238
247
  base: string[];
@@ -1 +1 @@
1
- {"version":3,"file":"avatar.d.ts","sourceRoot":"","sources":["../src/avatar.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,aAAa,GAAG,OAAO,GAAG,SAAS,GAAG,MAAM,CAAC;AACzD,MAAM,MAAM,WAAW,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAC9C,MAAM,MAAM,UAAU,GAAG,IAAI,GAAG,IAA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gB7E,wEAAwE;AACxE,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,WAAW,CAIrD;AAED,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAsBX;;;OAGG;;;;;;;;;;;;;;;;;;;;;;;;IAYH,uGAAuG;;;;;;IAIvG;;;OAGG;;;;;;;;;;;IAtCH,qGAAqG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAgBrG;;;OAGG;;;;;;;;;;;;;;;;;;;;;;;;IAYH,uGAAuG;;;;;;IAIvG;;;OAGG;;;;;;;;;;;IAtCH,qGAAqG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAgBrG;;;OAGG;;;;;;;;;;;;;;;;;;;;;;;;IAYH,uGAAuG;;;;;;IAIvG;;;OAGG;;;;;;;;;;;IAtCH,qGAAqG;;GAoE3G,CAAC;AAEH,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiBtB,CAAC"}
package/dist/avatar.js CHANGED
@@ -1,5 +1,16 @@
1
1
  import { pressable, tv } from './tv.js';
2
2
  const avatarColors = ['primary', 'info', 'success', 'warn', 'danger'];
3
+ /**
4
+ * Hover of a tinted avatar button: the tint goes from 14 % to 18 %, like soft buttons from /10 to /14 – more would miss
5
+ * 4.5:1 in some themes (token contrast test)
6
+ */
7
+ const tintHover = {
8
+ primary: 'hover:bg-[color-mix(in_srgb,var(--color-primary)_18%,var(--color-card))]',
9
+ success: 'hover:bg-[color-mix(in_srgb,var(--color-success)_18%,var(--color-card))]',
10
+ info: 'hover:bg-[color-mix(in_srgb,var(--color-info)_18%,var(--color-card))]',
11
+ warn: 'hover:bg-[color-mix(in_srgb,var(--color-warn)_18%,var(--color-card))]',
12
+ danger: 'hover:bg-[color-mix(in_srgb,var(--color-danger)_18%,var(--color-card))]',
13
+ };
3
14
  /** The same name always gets the same colour: "Julia Klein" → "info" */
4
15
  export function avatarColor(name) {
5
16
  let hash = 0;
@@ -48,14 +59,12 @@ export const avatar = tv({
48
59
  grouped: {
49
60
  true: { base: 'border-2 border-card' },
50
61
  },
51
- /** A button (`as="button"`), e.g. the trigger of a user menu: focus ring, a ring on hover and while open */
62
+ /**
63
+ * A button (`as="button"`), e.g. the trigger of a user menu: focus ring and hover of the IconButton with the
64
+ * same look (see the compound variants), so triggers side by side in a bar behave alike
65
+ */
52
66
  interactive: {
53
- true: {
54
- base: [
55
- ...pressable,
56
- 'hover:ring-2 hover:ring-line-2 data-[state=open]:ring-2 data-[state=open]:ring-line-2',
57
- ],
58
- },
67
+ true: { base: pressable },
59
68
  },
60
69
  },
61
70
  compoundVariants: [
@@ -65,6 +74,18 @@ export const avatar = tv({
65
74
  { shape: 'square', size: 'xl', class: { base: 'rounded-2xl' } },
66
75
  { shape: 'square', size: '2xl', class: { base: 'rounded-3xl' } },
67
76
  { grouped: true, variant: 'soft', class: { base: 'bg-bg-2 shadow-[inset_0_0_0_1px_var(--color-line-2)]' } },
77
+ // Hover like IconButton: outline darkens its border, soft (bg-line) the background like `secondary`, solid
78
+ // fades like the filled variants
79
+ { interactive: true, variant: 'outline', class: { base: 'hover:border-fg' } },
80
+ { interactive: true, variant: 'soft', class: { base: 'hover:bg-line-2' } },
81
+ { interactive: true, variant: 'solid', class: { base: 'hover:opacity-85' } },
82
+ ...avatarColors.map((color) => ({ interactive: true, color, class: { base: tintHover[color] } })),
83
+ // A loaded image covers the background, and without a border nothing would change: a ring on hover instead
84
+ {
85
+ interactive: true,
86
+ variant: ['soft', 'solid'],
87
+ class: { base: 'hover:has-[img:not([hidden])]:ring-2 hover:has-[img:not([hidden])]:ring-line-2' },
88
+ },
68
89
  ],
69
90
  defaultVariants: {
70
91
  variant: 'soft',
@@ -1 +1 @@
1
- {"version":3,"file":"avatar.js","sourceRoot":"","sources":["../src/avatar.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAA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classes of the WireLayer recipe avatar – generated by scripts/sources.ts, do not edit */
2
- @source inline("aria-busy:cursor-wait bg-[color-mix(in_srgb,var(--color-danger)_14%,var(--color-card))] bg-[color-mix(in_srgb,var(--color-info)_14%,var(--color-card))] bg-[color-mix(in_srgb,var(--color-primary)_14%,var(--color-card))] bg-[color-mix(in_srgb,var(--color-success)_14%,var(--color-card))] bg-[color-mix(in_srgb,var(--color-warn)_14%,var(--color-card))] bg-bg-2 bg-fg bg-line border border-2 border-card border-line-2 cursor-pointer data-[state=open]:ring-2 data-[state=open]:ring-line-2 disabled:cursor-not-allowed disabled:opacity-40 duration-150 flex focus-visible:outline-2 focus-visible:outline-fg focus-visible:outline-offset-2 font-semibold forced-colors:border forced-colors:border-[ButtonBorder] hover:ring-2 hover:ring-line-2 inline-flex items-center justify-center motion-reduce:transition-none object-cover overflow-hidden relative rounded-2xl rounded-3xl rounded-[10px] rounded-full rounded-lg rounded-xl select-none shadow-[inset_0_0_0_1px_var(--color-line-2)] shrink-0 size-10 size-12 size-16 size-24 size-4 size-5 size-7 size-8 size-[18px] size-full text-3xl text-base text-bg text-danger text-fg text-info text-primary text-sm text-success text-warn text-xl text-xs transition-[opacity,background-color,border-color,color]");
2
+ @source inline("aria-busy:cursor-wait bg-[color-mix(in_srgb,var(--color-danger)_14%,var(--color-card))] bg-[color-mix(in_srgb,var(--color-info)_14%,var(--color-card))] bg-[color-mix(in_srgb,var(--color-primary)_14%,var(--color-card))] bg-[color-mix(in_srgb,var(--color-success)_14%,var(--color-card))] bg-[color-mix(in_srgb,var(--color-warn)_14%,var(--color-card))] bg-bg-2 bg-fg bg-line border border-2 border-card border-line-2 cursor-pointer disabled:cursor-not-allowed disabled:opacity-40 duration-150 flex focus-visible:outline-2 focus-visible:outline-fg focus-visible:outline-offset-2 font-semibold forced-colors:border forced-colors:border-[ButtonBorder] hover:bg-[color-mix(in_srgb,var(--color-danger)_18%,var(--color-card))] hover:bg-[color-mix(in_srgb,var(--color-info)_18%,var(--color-card))] hover:bg-[color-mix(in_srgb,var(--color-primary)_18%,var(--color-card))] hover:bg-[color-mix(in_srgb,var(--color-success)_18%,var(--color-card))] hover:bg-[color-mix(in_srgb,var(--color-warn)_18%,var(--color-card))] hover:bg-line-2 hover:border-fg hover:has-[img:not([hidden])]:ring-2 hover:has-[img:not([hidden])]:ring-line-2 hover:opacity-85 inline-flex items-center justify-center motion-reduce:transition-none object-cover overflow-hidden relative rounded-2xl rounded-3xl rounded-[10px] rounded-full rounded-lg rounded-xl select-none shadow-[inset_0_0_0_1px_var(--color-line-2)] shrink-0 size-10 size-12 size-16 size-24 size-4 size-5 size-7 size-8 size-[18px] size-full text-3xl text-base text-bg text-danger text-fg text-info text-primary text-sm text-success text-warn text-xl text-xs transition-[opacity,background-color,border-color,color]");
3
3
  :root {
4
4
  --wc-recipe-avatar: 1;
5
5
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wirecore/wirelayer-recipes",
3
- "version": "0.4.0",
3
+ "version": "0.4.1",
4
4
  "description": "Framework-agnostic WireLayer component recipes (tailwind-variants)",
5
5
  "license": "MIT",
6
6
  "repository": {
package/src/avatar.ts CHANGED
@@ -8,6 +8,18 @@ export type AvatarColor = 'primary' | 'success' | 'info' | 'warn' | 'danger';
8
8
 
9
9
  const avatarColors: AvatarColor[] = ['primary', 'info', 'success', 'warn', 'danger'];
10
10
 
11
+ /**
12
+ * Hover of a tinted avatar button: the tint goes from 14 % to 18 %, like soft buttons from /10 to /14 – more would miss
13
+ * 4.5:1 in some themes (token contrast test)
14
+ */
15
+ const tintHover: Record<AvatarColor, string> = {
16
+ primary: 'hover:bg-[color-mix(in_srgb,var(--color-primary)_18%,var(--color-card))]',
17
+ success: 'hover:bg-[color-mix(in_srgb,var(--color-success)_18%,var(--color-card))]',
18
+ info: 'hover:bg-[color-mix(in_srgb,var(--color-info)_18%,var(--color-card))]',
19
+ warn: 'hover:bg-[color-mix(in_srgb,var(--color-warn)_18%,var(--color-card))]',
20
+ danger: 'hover:bg-[color-mix(in_srgb,var(--color-danger)_18%,var(--color-card))]',
21
+ };
22
+
11
23
  /** The same name always gets the same colour: "Julia Klein" → "info" */
12
24
  export function avatarColor(name: string): AvatarColor {
13
25
  let hash = 0;
@@ -56,14 +68,12 @@ export const avatar = tv({
56
68
  grouped: {
57
69
  true: { base: 'border-2 border-card' },
58
70
  },
59
- /** A button (`as="button"`), e.g. the trigger of a user menu: focus ring, a ring on hover and while open */
71
+ /**
72
+ * A button (`as="button"`), e.g. the trigger of a user menu: focus ring and hover of the IconButton with the
73
+ * same look (see the compound variants), so triggers side by side in a bar behave alike
74
+ */
60
75
  interactive: {
61
- true: {
62
- base: [
63
- ...pressable,
64
- 'hover:ring-2 hover:ring-line-2 data-[state=open]:ring-2 data-[state=open]:ring-line-2',
65
- ],
66
- },
76
+ true: { base: pressable },
67
77
  },
68
78
  },
69
79
  compoundVariants: [
@@ -73,6 +83,18 @@ export const avatar = tv({
73
83
  { shape: 'square', size: 'xl', class: { base: 'rounded-2xl' } },
74
84
  { shape: 'square', size: '2xl', class: { base: 'rounded-3xl' } },
75
85
  { grouped: true, variant: 'soft', class: { base: 'bg-bg-2 shadow-[inset_0_0_0_1px_var(--color-line-2)]' } },
86
+ // Hover like IconButton: outline darkens its border, soft (bg-line) the background like `secondary`, solid
87
+ // fades like the filled variants
88
+ { interactive: true, variant: 'outline', class: { base: 'hover:border-fg' } },
89
+ { interactive: true, variant: 'soft', class: { base: 'hover:bg-line-2' } },
90
+ { interactive: true, variant: 'solid', class: { base: 'hover:opacity-85' } },
91
+ ...avatarColors.map((color) => ({ interactive: true, color, class: { base: tintHover[color] } })),
92
+ // A loaded image covers the background, and without a border nothing would change: a ring on hover instead
93
+ {
94
+ interactive: true,
95
+ variant: ['soft', 'solid'] as AvatarVariant[],
96
+ class: { base: 'hover:has-[img:not([hidden])]:ring-2 hover:has-[img:not([hidden])]:ring-line-2' },
97
+ },
76
98
  ],
77
99
  defaultVariants: {
78
100
  variant: 'soft',