@sit-onyx/storybook-utils 0.1.0-alpha.1 → 1.0.0-alpha.3

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sit-onyx/storybook-utils",
3
3
  "description": "Storybook utilities for Vue",
4
- "version": "0.1.0-alpha.1",
4
+ "version": "1.0.0-alpha.3",
5
5
  "type": "module",
6
6
  "author": "Schwarz IT KG",
7
7
  "license": "Apache-2.0",
@@ -17,7 +17,8 @@
17
17
  "@storybook/preview-api": ">= 7",
18
18
  "@storybook/theming": ">= 7",
19
19
  "@storybook/vue3": ">= 7",
20
- "storybook-dark-mode": ">= 3"
20
+ "storybook-dark-mode": ">= 3",
21
+ "sit-onyx": "^0.1.0-alpha.3"
21
22
  },
22
23
  "dependencies": {
23
24
  "deepmerge-ts": "^5.1.0"
package/src/actions.ts CHANGED
@@ -1,12 +1,8 @@
1
1
  import { useArgs } from "@storybook/preview-api";
2
- import type { ArgTypes, Meta } from "@storybook/vue3";
2
+ import type { ArgTypes, Decorator, Meta } from "@storybook/vue3";
3
3
  import { deepmerge } from "deepmerge-ts";
4
4
  import { isReactive, reactive, watch } from "vue";
5
- import type {
6
- ArrayElement,
7
- DefineStorybookActionsAndVModelsOptions,
8
- ExtractVueEventNames,
9
- } from ".";
5
+ import type { DefineStorybookActionsAndVModelsOptions, ExtractVueEventNames } from ".";
10
6
 
11
7
  /**
12
8
  * Utility to define Storybook meta for a given Vue component which will take care of defining argTypes for
@@ -31,14 +27,14 @@ import type {
31
27
  */
32
28
  export const defineStorybookActionsAndVModels = <T>(
33
29
  options: DefineStorybookActionsAndVModelsOptions<T>,
34
- ): Meta<T> => {
30
+ ): Meta => {
35
31
  const defaultMeta = {
36
32
  argTypes: {
37
33
  ...defineActions(options.events),
38
34
  ...{}, // this is needed to fix a type issue
39
35
  },
40
36
  decorators: [withVModelDecorator(options.events)],
41
- } satisfies Meta<T>;
37
+ } satisfies Meta;
42
38
 
43
39
  return deepmerge(options, defaultMeta);
44
40
  };
@@ -81,9 +77,7 @@ export const defineActions = <T>(events: ExtractVueEventNames<T>[]): ArgTypes =>
81
77
  * }
82
78
  * ```
83
79
  */
84
- export const withVModelDecorator = <T>(
85
- events: ExtractVueEventNames<T>[],
86
- ): ArrayElement<Meta<T>["decorators"]> => {
80
+ export const withVModelDecorator = <T>(events: ExtractVueEventNames<T>[]): Decorator => {
87
81
  return (story, ctx) => {
88
82
  const vModelEvents = events.filter((event) => event.startsWith("update:"));
89
83
  if (!vModelEvents.length) return story();
package/src/index.css CHANGED
@@ -1,4 +1,4 @@
1
- @import url("../../sit-onyx/src/styles/variables-onyx.css");
1
+ @import url("sit-onyx/src/styles/variables-onyx.css");
2
2
 
3
3
  .onyx-disclaimer {
4
4
  border-radius: 0.5rem;
@@ -7,7 +7,7 @@
7
7
  margin: 1rem 0;
8
8
 
9
9
  /* same color as VitePress var(--vp-c-tip-soft) */
10
- background-color: color-mix(in srgb, var(--onyx-color-surface-info-400) 25%, transparent);
10
+ background-color: color-mix(in srgb, var(--onyx-color-base-info-400) 25%, transparent);
11
11
  }
12
12
 
13
13
  .onyx-disclaimer__title {
@@ -20,7 +20,7 @@
20
20
  }
21
21
 
22
22
  /* the Storybook table of content headline is always black so we need to manually set it for the dark mode */
23
- .dark #storybook-docs .sbdocs-wrapper > div:nth-child(2) {
23
+ #storybook-docs .sbdocs-wrapper > div:nth-child(2) {
24
24
  /* same as Storybook color "textMuted" inside ./theme.ts */
25
- color: var(--onyx-color-brand-neutral-300);
25
+ color: var(--onyx-color-text-neutral-medium);
26
26
  }
package/src/preview.ts CHANGED
@@ -12,13 +12,13 @@ const themes = {
12
12
  } as const;
13
13
 
14
14
  /**
15
- * Creates a default Storybook preview configuration for 'Onyx' with the following features:
15
+ * Creates a default Storybook preview configuration for 'onyx' with the following features:
16
16
  * - Improved controls (sorting and expanded controls so descriptions etc. are also shown in a single story)
17
17
  * - Improved Vue-specific code highlighting (e.g. using `@` instead of `v-on:`)
18
18
  * - Setup for dark mode (including docs page). Requires addon `storybook-dark-mode` to be enabled in .storybook/main.ts file
19
- * - Custom Storybook theme using Onyx colors (light and dark mode)
19
+ * - Custom Storybook theme using onyx colors (light and dark mode)
20
20
  * - Support for setting the light/dark mode when Storybook is embedded as an iframe (via query parameter, e.g. `?theme=dark`)
21
- * - Configure viewports / breakpoints as defined by Onyx
21
+ * - Configure viewports / breakpoints as defined by onyx
22
22
  *
23
23
  * @param overrides Custom preview / overrides, will be deep merged with the default preview.
24
24
  *
package/src/theme.ts CHANGED
@@ -1,11 +1,11 @@
1
1
  import type { ThemeVars, ThemeVarsPartial } from "@storybook/theming";
2
2
  import { create } from "@storybook/theming/create";
3
- import onyxVariables from "../../sit-onyx/src/styles/variables-onyx.json";
3
+ import onyxVariables from "sit-onyx/src/styles/variables-onyx.json";
4
4
  import storybookLogo from "./assets/logo-storybook-default.svg";
5
5
  import storybookLogoInverse from "./assets/logo-storybook-inverse.svg";
6
6
 
7
7
  /**
8
- * Creates a custom theme for Storybook that uses Onyx colors.
8
+ * Creates a custom theme for Storybook that uses onyx colors.
9
9
  *
10
10
  * @see https://storybook.js.org/docs/react/configure/theming#create-a-theme-quickstart
11
11
  */
@@ -14,10 +14,10 @@ export const createTheme = (
14
14
  ) => {
15
15
  const base = options?.base ?? "light";
16
16
  const defaultBrandImage = base === "light" ? storybookLogo : storybookLogoInverse;
17
- const primaryColor = onyxVariables["onyx-color-brand-primary-500"];
17
+ const primaryColor = onyxVariables["onyx-color-themed-primary-500"];
18
18
 
19
19
  return create({
20
- brandTitle: options?.brandTitle ?? "Onyx Storybook",
20
+ brandTitle: options?.brandTitle ?? "onyx Storybook",
21
21
  brandUrl: options?.brandUrl ?? "https://onyx.schwarz",
22
22
  brandImage: options?.brandImage ?? defaultBrandImage,
23
23
  brandTarget: "_blank",
@@ -25,11 +25,11 @@ export const createTheme = (
25
25
 
26
26
  // default theme values that are independent of the light/dark mode:
27
27
  colorPrimary: primaryColor,
28
- colorSecondary: onyxVariables["onyx-color-brand-secondary-500"],
28
+ colorSecondary: onyxVariables["onyx-color-themed-secondary-500"],
29
29
  barSelectedColor: primaryColor,
30
30
  barHoverColor: primaryColor,
31
- appBorderRadius: remToNumber(onyxVariables["onyx-number-radius-400"]),
32
- inputBorderRadius: remToNumber(onyxVariables["onyx-number-radius-300"]),
31
+ appBorderRadius: remToNumber(onyxVariables["onyx-number-radius-300"]),
32
+ inputBorderRadius: remToNumber(onyxVariables["onyx-number-radius-200"]),
33
33
 
34
34
  // custom colors depending on light/dark theme
35
35
  ...(base === "light" ? getLightTheme() : getDarkTheme()),
@@ -38,25 +38,25 @@ export const createTheme = (
38
38
 
39
39
  const getLightTheme = (): Partial<ThemeVars> => {
40
40
  return defineTheme({
41
- background: onyxVariables["onyx-color-universal-greyscale-white"],
42
- contentBackground: onyxVariables["onyx-color-brand-neutral-100"],
43
- text: onyxVariables["onyx-color-brand-neutral-800"],
44
- textMuted: onyxVariables["onyx-color-brand-neutral-900"],
45
- border: onyxVariables["onyx-color-brand-neutral-200"],
41
+ background: onyxVariables["onyx-color-universal-grayscale-white"],
42
+ contentBackground: onyxVariables["onyx-color-themed-neutral-100"],
43
+ text: onyxVariables["onyx-color-themed-neutral-700"],
44
+ textMuted: onyxVariables["onyx-color-themed-neutral-600"],
45
+ border: onyxVariables["onyx-color-themed-neutral-300"],
46
46
  });
47
47
  };
48
48
 
49
49
  const getDarkTheme = (): Partial<ThemeVars> => {
50
50
  return defineTheme({
51
- background: onyxVariables["onyx-color-brand-neutral-1100"],
52
- contentBackground: onyxVariables["onyx-color-brand-neutral-1200"],
53
- text: onyxVariables["onyx-color-brand-neutral-200"],
54
- textMuted: onyxVariables["onyx-color-brand-neutral-300"],
55
- border: onyxVariables["onyx-color-brand-neutral-1000"],
51
+ background: onyxVariables["onyx-color-themed-neutral-1100"],
52
+ contentBackground: onyxVariables["onyx-color-themed-neutral-1200"],
53
+ text: onyxVariables["onyx-color-themed-neutral-200"],
54
+ textMuted: onyxVariables["onyx-color-themed-neutral-400"],
55
+ border: onyxVariables["onyx-color-themed-neutral-900"],
56
56
  });
57
57
  };
58
58
 
59
- /** Define a full Onyx Storybook color theme based on the given 5 main colors. */
59
+ /** Define a full onyx Storybook color theme based on the given 5 main colors. */
60
60
  const defineTheme = (colors: {
61
61
  text: string;
62
62
  textMuted: string;
@@ -91,7 +91,7 @@ const defineTheme = (colors: {
91
91
  } satisfies Partial<ThemeVars>;
92
92
  };
93
93
 
94
- /** All available Storybook breakpoints / viewports supported by Onyx. */
94
+ /** All available Storybook breakpoints / viewports supported by onyx. */
95
95
  export const ONYX_BREAKPOINTS = {
96
96
  "2xs": {
97
97
  name: "2xs",
package/src/types.ts CHANGED
@@ -46,8 +46,3 @@ export type DefineStorybookActionsAndVModelsOptions<T> = Meta<T> & {
46
46
  component: NonNullable<T>;
47
47
  events: ExtractVueEventNames<T>[];
48
48
  };
49
-
50
- /**
51
- * A utility type that gets the type of an array element.
52
- */
53
- export type ArrayElement<A> = A extends readonly (infer T)[] ? T : never;