@kystverket/styrbord 2.10.0 → 2.11.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.
@@ -13,6 +13,11 @@ type AriaHidden = Partial<AriaLabel> & {
13
13
  'aria-hidden': true | 'true';
14
14
  };
15
15
  export type AvatarProps = MergeRight<DsAvatarProps, (AriaLabel | AriaHidden) & {
16
+ /**
17
+ * What `auto` seeds the generated color or pattern from, typically a user id. Use it when two
18
+ * people can share a name, or when `aria-label` holds more than the name. Falls back to
19
+ * `aria-label` when unset or blank.
20
+ */
16
21
  'auto-seed'?: string;
17
22
  'data-color'?: DataColor;
18
23
  'data-color-variant'?: DataColorVariant;
@@ -28,7 +33,7 @@ export type AvatarProps = MergeRight<DsAvatarProps, (AriaLabel | AriaHidden) & {
28
33
  checked?: boolean;
29
34
  /**
30
35
  * Renders a generated [boring avatar](https://boringavatars.com) in Kystverket's colors,
31
- * seeded from `aria-label`. Ignored when `children` is set.
36
+ * seeded from `auto-seed`, or `aria-label` when that is unset. Ignored when `children` is set.
32
37
  *
33
38
  * Defaults to the `auto` of the nearest `AvatarProvider`. Set to `false` to opt this avatar
34
39
  * out of a provider's default and render it without generated colors.
@@ -39,13 +39,23 @@ export interface HeaderProps {
39
39
  };
40
40
  }
41
41
  type HeaderProfile = {
42
+ /**
43
+ * A stable id for the user. Seeds the avatar's generated color or pattern, and is what an
44
+ * `AvatarProvider`'s `auto-reserved-seed` should be set to. Falls back to `name`.
45
+ */
46
+ id?: string;
42
47
  name: string;
43
48
  department?: string;
44
49
  /**
45
50
  * URL of a profile picture. Falls back to initials when unset or when the image fails to load.
46
51
  */
47
52
  image?: string;
48
- avatarStyle?: Pick<AvatarProps, 'data-color' | 'data-color-variant' | 'border-style'>;
53
+ /**
54
+ * Props for the profile avatar. Every `Avatar` prop is accepted except those the header sets
55
+ * itself, so new `Avatar` props reach the header without changes here.
56
+ * Without it, the avatar is `data-color="success"` unless an `AvatarProvider` sets `auto`.
57
+ */
58
+ avatarStyle?: Omit<AvatarProps, 'aria-label' | 'aria-hidden' | 'initials' | 'children' | 'data-size'>;
49
59
  };
50
60
  export declare const nameToInitials: (name?: string) => string;
51
61
  export declare function MainLinkItem(props: HeaderLinkItemWithOnClick): React.JSX.Element;
@@ -28,4 +28,10 @@ export declare const medProfilOgMenyItems: Story;
28
28
  export declare const medMenyItems: Story;
29
29
  export declare const medProfil: Story;
30
30
  export declare const medProfilbilde: Story;
31
+ /**
32
+ * Inside an `AvatarProvider` with `auto`, the header avatar gets a generated color seeded from
33
+ * `profile.id`. With `auto-reserved-seed` set to the same id, the logged-in user keeps a color
34
+ * no one else on the page gets, and looks the same in the header as in the list below.
35
+ */
36
+ export declare const medAvatarProvider: Story;
31
37
  export declare const medProfilLenker: Story;