@kystverket/styrbord 2.9.1 → 2.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.
@@ -2,6 +2,8 @@ import { ReactNode } from 'react';
2
2
  import type { AvatarAuto } from './Avatar';
3
3
  export declare const AvatarContext: React.Context<{
4
4
  auto?: AvatarAuto;
5
+ reservedSeed?: string;
6
+ reservedIndex?: number;
5
7
  }>;
6
8
  export type AvatarProviderProps = {
7
9
  /**
@@ -9,6 +11,18 @@ export type AvatarProviderProps = {
9
11
  * so `auto={false}` opts a single avatar out.
10
12
  */
11
13
  auto?: AvatarAuto;
14
+ /**
15
+ * A seed, typically the logged-in user's id, that gets a `solid` color no other seed inside
16
+ * gets. Matched against each avatar's `auto-seed`, or its `aria-label` when it has none.
17
+ * Generated patterns ignore it.
18
+ */
19
+ 'auto-reserved-seed'?: string;
20
+ /**
21
+ * Which `solid` palette color `auto-reserved-seed` gets. Any integer works: it wraps around
22
+ * the palette's length, so -1 is the last color.
23
+ * @default 0
24
+ */
25
+ 'auto-reserved-index'?: number;
12
26
  children: ReactNode;
13
27
  };
14
- export declare const AvatarProvider: ({ auto, children }: AvatarProviderProps) => React.JSX.Element;
28
+ export declare const AvatarProvider: ({ auto, "auto-reserved-seed": reservedSeed, "auto-reserved-index": reservedIndex, children, }: AvatarProviderProps) => React.JSX.Element;
@@ -13,6 +13,7 @@ type AriaHidden = Partial<AriaLabel> & {
13
13
  'aria-hidden': true | 'true';
14
14
  };
15
15
  export type AvatarProps = MergeRight<DsAvatarProps, (AriaLabel | AriaHidden) & {
16
+ 'auto-seed'?: string;
16
17
  'data-color'?: DataColor;
17
18
  'data-color-variant'?: DataColorVariant;
18
19
  'data-size'?: '2xs' | '3xs' | DsAvatarProps['data-size'];
@@ -4,9 +4,18 @@ import { AvatarAuto, AvatarBoringVariant } from './Avatar';
4
4
  * contrast from them), so these are resolved token values rather than CSS variables.
5
5
  */
6
6
  export declare const boringColors: string[];
7
+ /**
8
+ * `undefined` when there is no reservation, otherwise whether `seed` is the reserved one.
9
+ */
10
+ export declare const matchReservedSeed: (seed: string | undefined, reservedSeed: string | undefined) => boolean | undefined;
7
11
  export declare const sizeClasses: (size: string) => string;
8
12
  export declare const borderStyleClasses: (borderStyle: string | undefined) => string | undefined;
9
- export declare const autoSolidStyles: (ariaLabel?: string) => Record<string, string>;
13
+ /**
14
+ * @param isReserved From `matchReservedSeed`: `true` gets the reserved color, `false` never does,
15
+ * `undefined` (no reservation) picks from the full palette.
16
+ * @param reservedIndex Which palette color is reserved, wrapped to the palette's length.
17
+ */
18
+ export declare const autoSolidStyles: (ariaLabel?: string, isReserved?: boolean, reservedIndex?: number) => Record<string, string>;
10
19
  /**
11
20
  * `undefined` means auto is explicitly disabled (`auto={false}`): no generated colors at all.
12
21
  */
@@ -16,4 +16,16 @@ export declare const WithTooltip: Story;
16
16
  export declare const Checked: Story;
17
17
  export declare const Boring: Story;
18
18
  export declare const WithProvider: Story;
19
+ /**
20
+ * `auto-seed` decouples the generated pattern from `aria-label`. Seed from something stable,
21
+ * like a user id, so two people with the same name look different and a person keeps their
22
+ * pattern when the label changes.
23
+ */
24
+ export declare const AutoSeed: Story;
25
+ /**
26
+ * Decorative avatars next to a visible name are `aria-hidden` and have no `aria-label` to seed
27
+ * from. With an `AvatarProvider` setting `auto`, `auto-seed` is all each avatar needs.
28
+ */
29
+ export declare const AutoSeedWithProvider: Story;
30
+ export declare const AutoReservedSeed: Story;
19
31
  export declare const AsLink: Story;