diff --git a/.storybook/manager.ts b/.storybook/manager.ts
index e8d35732..f93ef5bd 100644
--- a/.storybook/manager.ts
+++ b/.storybook/manager.ts
@@ -1,6 +1,17 @@
-import { addons } from "@storybook/manager-api";
+import { addons, types } from "@storybook/manager-api";
import { sbTheme } from "./theme";
-
+import { ExperimentalDsToggle } from "../stories/addons/ExperimentalDsToggle";
addons.setConfig({
theme: sbTheme
});
+
+// Register the addon
+addons.register("EXPERIMENTAL_DS_ADDON", () => {
+ // Register the tool
+ addons.add("EXPERIMENTAL_DS_ADDON_ID", {
+ type: types.TOOL,
+ title: "Experimental DS Addon",
+ match: ({ viewMode }) => !!(viewMode && viewMode.match(/^(story|docs)$/)),
+ render: ExperimentalDsToggle
+ });
+});
diff --git a/.storybook/preview.tsx b/.storybook/preview.tsx
index 42a6dc5a..8d5d4b62 100644
--- a/.storybook/preview.tsx
+++ b/.storybook/preview.tsx
@@ -1,14 +1,15 @@
import React from "react";
import type { Preview } from "@storybook/react";
import { IOThemeLight, IOThemeDark } from "../src/core";
+import { withEperimentalDs } from "../stories/utils";
+import { EXPERIMENTAL_DS_PARAM_KEY } from "../stories/addons/ExperimentalDsToggle";
const preview: Preview = {
+ decorators: [withEperimentalDs],
+ globals: {
+ [EXPERIMENTAL_DS_PARAM_KEY]: false
+ },
parameters: {
- options: {
- storySort: {
- order: ["Getting Started", ["Atoms", "Components"], "Changelog"]
- }
- },
backgrounds: {
default: "light",
values: [
diff --git a/stories/addons/ExperimentalDsToggle.tsx b/stories/addons/ExperimentalDsToggle.tsx
new file mode 100644
index 00000000..1864a088
--- /dev/null
+++ b/stories/addons/ExperimentalDsToggle.tsx
@@ -0,0 +1,40 @@
+import React, { memo, useCallback, useEffect } from "react";
+
+import { useGlobals, useStorybookApi } from "@storybook/manager-api";
+import { Icons, IconButton } from "@storybook/components";
+
+export const EXPERIMENTAL_DS_PARAM_KEY = "experimentalDs";
+
+export const ExperimentalDsToggle = memo(function ExperimentalDS() {
+ const [globals, updateGlobals] = useGlobals();
+ const api = useStorybookApi();
+
+ const isActive = [true, "true"].includes(globals[EXPERIMENTAL_DS_PARAM_KEY]);
+
+ const toggleMyTool = useCallback(() => {
+ updateGlobals({
+ [EXPERIMENTAL_DS_PARAM_KEY]: !isActive
+ });
+ }, [isActive, updateGlobals]);
+
+ useEffect(() => {
+ void api.setAddonShortcut("EXPERIMENTAL_DS_ADDON", {
+ label: "Toggle Addon [8]",
+ defaultShortcut: ["8"],
+ actionName: "ExperimentalDS",
+ showInMenu: false,
+ action: toggleMyTool
+ });
+ }, [toggleMyTool, api]);
+
+ return (
+