@kystverket/styrbord 2.19.0 → 2.20.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.
@@ -1,7 +1,7 @@
1
1
  import type { ReactElement } from 'react';
2
2
  import type { ColorSchemeToggleProps } from './ColorSchemeToggle.types';
3
3
  /**
4
- * Round 48 px button that switches between light and dark colour scheme. Shows a sun over the sea in
4
+ * Round button (32 px by default, see `data-size`) that switches between light and dark colour scheme. Shows a sun over the sea in
5
5
  * light mode; in dark mode the sun sinks and a crescent moon and stars appear.
6
6
  *
7
7
  * Controlled: pair it with `useColorScheme`, which stores the choice and sets `data-color-scheme`
@@ -12,4 +12,4 @@ import type { ColorSchemeToggleProps } from './ColorSchemeToggle.types';
12
12
  * const [colorScheme, setColorScheme] = useColorScheme();
13
13
  * <ColorSchemeToggle colorScheme={colorScheme} onColorSchemeChange={setColorScheme} />
14
14
  */
15
- export declare function ColorSchemeToggle({ colorScheme, onColorSchemeChange, variant, className, style, onClick, ...rest }: ColorSchemeToggleProps): ReactElement;
15
+ export declare function ColorSchemeToggle({ colorScheme, onColorSchemeChange, variant, 'data-size': size, className, style, onClick, ...rest }: ColorSchemeToggleProps): ReactElement;
@@ -7,7 +7,8 @@ declare const meta: {
7
7
  args: {
8
8
  colorScheme: "light";
9
9
  onColorSchemeChange: () => void;
10
- variant: "color";
10
+ variant: "mono";
11
+ 'data-size': "md";
11
12
  };
12
13
  argTypes: {
13
14
  colorScheme: {
@@ -20,6 +21,10 @@ declare const meta: {
20
21
  control: "inline-radio";
21
22
  options: string[];
22
23
  };
24
+ 'data-size': {
25
+ control: "inline-radio";
26
+ options: string[];
27
+ };
23
28
  };
24
29
  parameters: {
25
30
  docs: {
@@ -33,6 +38,7 @@ export default meta;
33
38
  type Story = StoryObj<typeof meta>;
34
39
  export declare const Preview: Story;
35
40
  export declare const Variants: Story;
41
+ export declare const Sizes: Story;
36
42
  export declare const AllStates: Story;
37
43
  /**
38
44
  * With `useColorScheme` the page follows the system until the user picks the other scheme. That choice
@@ -1,6 +1,7 @@
1
1
  import type { ButtonHTMLAttributes, Ref } from 'react';
2
2
  export type ColorScheme = 'light' | 'dark';
3
- export type ColorSchemeToggleVariant = 'color' | 'mono';
3
+ export type ColorSchemeToggleVariant = 'color' | 'mono' | 'icon';
4
+ export type ColorSchemeToggleSize = 'xs' | 'sm' | 'md' | 'lg' | 'xl';
4
5
  export type ColorSchemeToggleProps = Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'type' | 'children' | 'onChange' | 'aria-label' | 'title'> & {
5
6
  /** The colour scheme currently in use. The button shows a sun for `light` and a moon for `dark`. */
6
7
  colorScheme: ColorScheme;
@@ -9,8 +10,16 @@ export type ColorSchemeToggleProps = Omit<ButtonHTMLAttributes<HTMLButtonElement
9
10
  /**
10
11
  * `color` draws sky, sea and a yellow sun. `mono` is a single-colour line icon in
11
12
  * `primary-base-default` on `primary-surface-default`, and follows the page's colour scheme.
12
- * @default 'color'
13
+ * `icon` is just a solid light bulb (light) or moon (dark) in `primary-base-default` inside the border, with no sky or sea. Made for
14
+ * the small sizes (`xs`, `sm`), where the scene is too detailed to read.
15
+ * @default 'mono'
13
16
  */
14
17
  variant?: ColorSchemeToggleVariant;
18
+ /**
19
+ * Diameter: `xs` ≈ 16 px, `sm` ≈ 24 px, `md` ≈ 32 px, `lg` ≈ 48 px, `xl` ≈ 64 px. Taken from the
20
+ * `--ds-size-*` scale, so it follows the root font size.
21
+ * @default 'md'
22
+ */
23
+ 'data-size'?: ColorSchemeToggleSize;
15
24
  ref?: Ref<HTMLButtonElement>;
16
25
  };
@@ -49,7 +49,7 @@ export type { LogoProps, LogoVariant } from './components/kystverket/Logo/Logo';
49
49
  export { Search, SearchInput, SearchClear, SearchButton } from './components/kystverket/Search/Search';
50
50
  export type { SearchProps, SearchInputProps, SearchClearProps, SearchButtonProps, } from './components/kystverket/Search/Search.types';
51
51
  export { ColorSchemeToggle } from './components/kystverket/ColorSchemeToggle/ColorSchemeToggle';
52
- export type { ColorScheme, ColorSchemeToggleProps, ColorSchemeToggleVariant, } from './components/kystverket/ColorSchemeToggle/ColorSchemeToggle.types';
52
+ export type { ColorScheme, ColorSchemeToggleProps, ColorSchemeToggleSize, ColorSchemeToggleVariant, } from './components/kystverket/ColorSchemeToggle/ColorSchemeToggle.types';
53
53
  export { useColorScheme, COLOR_SCHEME_STORAGE_KEY } from './components/kystverket/ColorSchemeToggle/useColorScheme';
54
54
  export { Footer } from './components/kystverket/Footer/Footer';
55
55
  export type { FooterProps } from './components/kystverket/Footer/Footer';