@kystverket/styrbord 2.4.2 → 2.5.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.
@@ -0,0 +1,14 @@
1
+ import { ReactNode } from 'react';
2
+ import type { AvatarAuto } from './Avatar';
3
+ export declare const AvatarContext: React.Context<{
4
+ auto?: AvatarAuto;
5
+ }>;
6
+ export type AvatarProviderProps = {
7
+ /**
8
+ * Default `auto` mode for every `Avatar` inside. An avatar's own `auto` prop takes precedence,
9
+ * so `auto={false}` opts a single avatar out.
10
+ */
11
+ auto?: AvatarAuto;
12
+ children: ReactNode;
13
+ };
14
+ export declare const AvatarProvider: ({ auto, children }: AvatarProviderProps) => React.JSX.Element;
@@ -2,6 +2,7 @@ import { FC } from 'react';
2
2
  import { AvatarProps as DsAvatarProps, MergeRight } from '@digdir/designsystemet-react';
3
3
  import { DataColor, DataColorVariant } from '~/main';
4
4
  export type AvatarBoringVariant = 'marble' | 'beam' | 'pixel' | 'sunset' | 'ring' | 'bauhaus' | 'geometric' | 'abstract';
5
+ export type AvatarAuto = boolean | 'solid' | AvatarBoringVariant;
5
6
  type AriaLabel = {
6
7
  /**
7
8
  * The name of the person the avatar represents.
@@ -27,8 +28,11 @@ export type AvatarProps = MergeRight<DsAvatarProps, (AriaLabel | AriaHidden) & {
27
28
  /**
28
29
  * Renders a generated [boring avatar](https://boringavatars.com) in Kystverket's colors,
29
30
  * seeded from `aria-label`. Ignored when `children` is set.
31
+ *
32
+ * Defaults to the `auto` of the nearest `AvatarProvider`. Set to `false` to opt this avatar
33
+ * out of a provider's default and render it without generated colors.
30
34
  */
31
- auto?: true | 'solid' | AvatarBoringVariant;
35
+ auto?: AvatarAuto;
32
36
  }>;
33
37
  export declare const Avatar: FC<AvatarProps>;
34
38
  export {};
@@ -1,4 +1,4 @@
1
- import { AvatarBoringVariant } from './Avatar';
1
+ import { AvatarAuto, AvatarBoringVariant } from './Avatar';
2
2
  /**
3
3
  * Kystverket's avatar palette. boring-avatars needs hex strings (some variants compute
4
4
  * contrast from them), so these are resolved token values rather than CSS variables.
@@ -7,4 +7,7 @@ export declare const boringColors: string[];
7
7
  export declare const sizeClasses: (size: string) => string;
8
8
  export declare const borderStyleClasses: (borderStyle: string | undefined) => string | undefined;
9
9
  export declare const autoSolidStyles: (ariaLabel?: string) => Record<string, string>;
10
- export declare const determineAutoMode: (auto: true | undefined | "solid" | AvatarBoringVariant, ariaLabel?: string) => AvatarBoringVariant | "solid";
10
+ /**
11
+ * `undefined` means auto is explicitly disabled (`auto={false}`): no generated colors at all.
12
+ */
13
+ export declare const determineAutoMode: (auto: AvatarAuto | undefined, ariaLabel?: string) => AvatarBoringVariant | "solid" | undefined;
@@ -15,4 +15,5 @@ export declare const InDropdown: Story;
15
15
  export declare const WithTooltip: Story;
16
16
  export declare const Checked: Story;
17
17
  export declare const Boring: Story;
18
+ export declare const WithProvider: Story;
18
19
  export declare const AsLink: Story;
@@ -90,7 +90,9 @@ export { Link } from './components/designsystemet/Link/Link';
90
90
  export type { LinkProps } from './components/designsystemet/Link/Link';
91
91
  export { default as Table } from './components/designsystemet/Table/Table';
92
92
  export { Avatar } from './components/designsystemet/Avatar/Avatar';
93
- export type { AvatarProps, AvatarBoringVariant } from './components/designsystemet/Avatar/Avatar';
93
+ export type { AvatarProps, AvatarAuto, AvatarBoringVariant } from './components/designsystemet/Avatar/Avatar';
94
+ export { AvatarProvider } from './components/designsystemet/Avatar/Avatar.context';
95
+ export type { AvatarProviderProps } from './components/designsystemet/Avatar/Avatar.context';
94
96
  export { AvatarStack } from './components/designsystemet/AvatarStack/AvatarStack';
95
97
  export type { AvatarStackProps } from './components/designsystemet/AvatarStack/AvatarStack';
96
98
  export { SlotDialog, type SlotDialogProps } from './components/kystverket/SlotDialog/SlotDialog';