@sit-onyx/storybook-utils 0.1.0-alpha.2 → 1.0.0-alpha.4

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,13 +1,14 @@
1
1
  {
2
2
  "name": "@sit-onyx/storybook-utils",
3
3
  "description": "Storybook utilities for Vue",
4
- "version": "0.1.0-alpha.2",
4
+ "version": "1.0.0-alpha.4",
5
5
  "type": "module",
6
6
  "author": "Schwarz IT KG",
7
7
  "license": "Apache-2.0",
8
8
  "files": [
9
9
  "src"
10
10
  ],
11
+ "types": "./src/index.ts",
11
12
  "exports": {
12
13
  ".": "./src/index.ts",
13
14
  "./style.css": "./src/index.css"
@@ -18,7 +19,7 @@
18
19
  "@storybook/theming": ">= 7",
19
20
  "@storybook/vue3": ">= 7",
20
21
  "storybook-dark-mode": ">= 3",
21
- "sit-onyx": "^0.1.0-alpha.2"
22
+ "sit-onyx": "^0.1.0-alpha.4"
22
23
  },
23
24
  "dependencies": {
24
25
  "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
@@ -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-base-neutral-300);
25
+ color: var(--onyx-color-text-neutral-medium);
26
26
  }
package/src/theme.ts CHANGED
@@ -14,7 +14,7 @@ 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-themed-brand-500"];
17
+ const primaryColor = onyxVariables["onyx-color-themed-primary-500"];
18
18
 
19
19
  return create({
20
20
  brandTitle: options?.brandTitle ?? "onyx Storybook",
@@ -25,7 +25,7 @@ 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-themed-action-500"],
28
+ colorSecondary: onyxVariables["onyx-color-themed-secondary-500"],
29
29
  barSelectedColor: primaryColor,
30
30
  barHoverColor: primaryColor,
31
31
  appBorderRadius: remToNumber(onyxVariables["onyx-number-radius-300"]),
@@ -38,11 +38,11 @@ export const createTheme = (
38
38
 
39
39
  const getLightTheme = (): Partial<ThemeVars> => {
40
40
  return defineTheme({
41
- background: onyxVariables["onyx-color-universal-greyscale-white"],
41
+ background: onyxVariables["onyx-color-universal-grayscale-white"],
42
42
  contentBackground: onyxVariables["onyx-color-themed-neutral-100"],
43
- text: onyxVariables["onyx-color-themed-neutral-800"],
44
- textMuted: onyxVariables["onyx-color-themed-neutral-900"],
45
- border: onyxVariables["onyx-color-themed-neutral-200"],
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
 
@@ -51,8 +51,8 @@ const getDarkTheme = (): Partial<ThemeVars> => {
51
51
  background: onyxVariables["onyx-color-themed-neutral-1100"],
52
52
  contentBackground: onyxVariables["onyx-color-themed-neutral-1200"],
53
53
  text: onyxVariables["onyx-color-themed-neutral-200"],
54
- textMuted: onyxVariables["onyx-color-themed-neutral-300"],
55
- border: onyxVariables["onyx-color-themed-neutral-1000"],
54
+ textMuted: onyxVariables["onyx-color-themed-neutral-400"],
55
+ border: onyxVariables["onyx-color-themed-neutral-900"],
56
56
  });
57
57
  };
58
58
 
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;