@kystverket/styrbord 2.9.1 → 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.
- package/dist/src/components/designsystemet/Avatar/Avatar.context.d.ts +15 -1
- package/dist/src/components/designsystemet/Avatar/Avatar.d.ts +7 -1
- package/dist/src/components/designsystemet/Avatar/Avatar.helpers.d.ts +10 -1
- package/dist/src/components/designsystemet/Avatar/Avatar.stories.d.ts +12 -0
- package/dist/src/components/kystverket/Header/Header.d.ts +11 -1
- package/dist/src/components/kystverket/Header/Header.stories.d.ts +6 -0
- package/dist/style.js +1648 -1630
- package/dist/style.umd.cjs +10 -10
- package/package.json +1 -1
|
@@ -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,12 @@ 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
|
+
*/
|
|
21
|
+
'auto-seed'?: string;
|
|
16
22
|
'data-color'?: DataColor;
|
|
17
23
|
'data-color-variant'?: DataColorVariant;
|
|
18
24
|
'data-size'?: '2xs' | '3xs' | DsAvatarProps['data-size'];
|
|
@@ -27,7 +33,7 @@ export type AvatarProps = MergeRight<DsAvatarProps, (AriaLabel | AriaHidden) & {
|
|
|
27
33
|
checked?: boolean;
|
|
28
34
|
/**
|
|
29
35
|
* Renders a generated [boring avatar](https://boringavatars.com) in Kystverket's colors,
|
|
30
|
-
* seeded from `aria-label
|
|
36
|
+
* seeded from `auto-seed`, or `aria-label` when that is unset. Ignored when `children` is set.
|
|
31
37
|
*
|
|
32
38
|
* Defaults to the `auto` of the nearest `AvatarProvider`. Set to `false` to opt this avatar
|
|
33
39
|
* out of a provider's default and render it without generated colors.
|
|
@@ -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
|
-
|
|
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;
|
|
@@ -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
|
-
|
|
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;
|