Skip to content

Commit

Permalink
feat: build and expose dist
Browse files Browse the repository at this point in the history
  • Loading branch information
jon301 committed Mar 22, 2024
1 parent 307490e commit 75c5ef0
Show file tree
Hide file tree
Showing 10 changed files with 892 additions and 0 deletions.
23 changes: 23 additions & 0 deletions dist/chunk-BBUBR5JW.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// src/constants.ts
var ADDON_ID = "storybook/pseudo-states";
var TOOL_ID = `${ADDON_ID}/tool`;
var PARAM_KEY = "pseudo";
var EXCLUDED_PSEUDO_ELEMENTS = ["::-webkit-scrollbar-thumb", "::-webkit-slider-thumb"];
var PSEUDO_STATES = {
hover: "hover",
active: "active",
focusVisible: "focus-visible",
focusWithin: "focus-within",
focus: "focus",
visited: "visited",
link: "link",
target: "target"
};

export {
ADDON_ID,
TOOL_ID,
PARAM_KEY,
EXCLUDED_PSEUDO_ELEMENTS,
PSEUDO_STATES
};
3 changes: 3 additions & 0 deletions dist/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
declare const _default: {};

export { _default as default };
31 changes: 31 additions & 0 deletions dist/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

// src/index.ts
var src_exports = {};
__export(src_exports, {
default: () => src_default
});
module.exports = __toCommonJS(src_exports);
if (module && module.hot && module.hot.decline) {
module.hot.decline();
}
var src_default = {};
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {});
8 changes: 8 additions & 0 deletions dist/index.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// src/index.ts
if (module && module.hot && module.hot.decline) {
module.hot.decline();
}
var src_default = {};
export {
src_default as default
};
1 change: 1 addition & 0 deletions dist/manager.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

112 changes: 112 additions & 0 deletions dist/manager.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));

// src/manager.ts
var import_manager_api2 = require("@storybook/manager-api");

// src/constants.ts
var ADDON_ID = "storybook/pseudo-states";
var TOOL_ID = `${ADDON_ID}/tool`;
var PARAM_KEY = "pseudo";
var PSEUDO_STATES = {
hover: "hover",
active: "active",
focusVisible: "focus-visible",
focusWithin: "focus-within",
focus: "focus",
visited: "visited",
link: "link",
target: "target"
};

// src/manager/PseudoStateTool.tsx
var import_react = __toESM(require("react"));
var import_components = require("@storybook/components");
var import_manager_api = require("@storybook/manager-api");
var import_theming = require("@storybook/theming");
var LinkTitle = import_theming.styled.span(({ active }) => ({
color: active ? import_theming.color.secondary : "inherit"
}));
var LinkIcon = (0, import_theming.styled)(import_components.Icons)(({ active }) => ({
opacity: active ? 1 : 0,
path: { fill: active ? import_theming.color.secondary : "inherit" }
}));
var options = Object.keys(PSEUDO_STATES).sort();
var PseudoStateTool = () => {
const [globals, updateGlobals] = (0, import_manager_api.useGlobals)();
const pseudo = globals[PARAM_KEY];
const isActive = (0, import_react.useCallback)(
(option) => {
if (!pseudo)
return false;
return pseudo[option] === true;
},
[pseudo]
);
const toggleOption = (0, import_react.useCallback)(
(option) => () => {
updateGlobals({
[PARAM_KEY]: {
...pseudo,
[option]: !isActive(option)
}
});
},
[pseudo]
);
return /* @__PURE__ */ import_react.default.createElement(
import_components.WithTooltip,
{
placement: "top",
trigger: "click",
tooltip: () => /* @__PURE__ */ import_react.default.createElement(
import_components.TooltipLinkList,
{
links: options.map((option) => ({
id: option,
title: /* @__PURE__ */ import_react.default.createElement(LinkTitle, { active: isActive(option) }, ":", PSEUDO_STATES[option]),
right: /* @__PURE__ */ import_react.default.createElement(LinkIcon, { icon: "check", width: 12, height: 12, active: isActive(option) }),
onClick: toggleOption(option),
active: isActive(option)
}))
}
)
},
/* @__PURE__ */ import_react.default.createElement(
import_components.IconButton,
{
key: "pseudo-state",
title: "Select CSS pseudo states",
active: options.some(isActive)
},
/* @__PURE__ */ import_react.default.createElement(import_components.Icons, { icon: "button" })
)
);
};

// src/manager.ts
import_manager_api2.addons.register(ADDON_ID, () => {
import_manager_api2.addons.add(TOOL_ID, {
type: import_manager_api2.types.TOOL,
title: "CSS pseudo states",
match: ({ viewMode }) => viewMode === "story",
render: PseudoStateTool
});
});
84 changes: 84 additions & 0 deletions dist/manager.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
import {
ADDON_ID,
PARAM_KEY,
PSEUDO_STATES,
TOOL_ID
} from "./chunk-BBUBR5JW.mjs";

// src/manager.ts
import { addons, types } from "@storybook/manager-api";

// src/manager/PseudoStateTool.tsx
import React, { useCallback } from "react";
import { Icons, IconButton, WithTooltip, TooltipLinkList } from "@storybook/components";
import { useGlobals } from "@storybook/manager-api";
import { styled, color } from "@storybook/theming";
var LinkTitle = styled.span(({ active }) => ({
color: active ? color.secondary : "inherit"
}));
var LinkIcon = styled(Icons)(({ active }) => ({
opacity: active ? 1 : 0,
path: { fill: active ? color.secondary : "inherit" }
}));
var options = Object.keys(PSEUDO_STATES).sort();
var PseudoStateTool = () => {
const [globals, updateGlobals] = useGlobals();
const pseudo = globals[PARAM_KEY];
const isActive = useCallback(
(option) => {
if (!pseudo)
return false;
return pseudo[option] === true;
},
[pseudo]
);
const toggleOption = useCallback(
(option) => () => {
updateGlobals({
[PARAM_KEY]: {
...pseudo,
[option]: !isActive(option)
}
});
},
[pseudo]
);
return /* @__PURE__ */ React.createElement(
WithTooltip,
{
placement: "top",
trigger: "click",
tooltip: () => /* @__PURE__ */ React.createElement(
TooltipLinkList,
{
links: options.map((option) => ({
id: option,
title: /* @__PURE__ */ React.createElement(LinkTitle, { active: isActive(option) }, ":", PSEUDO_STATES[option]),
right: /* @__PURE__ */ React.createElement(LinkIcon, { icon: "check", width: 12, height: 12, active: isActive(option) }),
onClick: toggleOption(option),
active: isActive(option)
}))
}
)
},
/* @__PURE__ */ React.createElement(
IconButton,
{
key: "pseudo-state",
title: "Select CSS pseudo states",
active: options.some(isActive)
},
/* @__PURE__ */ React.createElement(Icons, { icon: "button" })
)
);
};

// src/manager.ts
addons.register(ADDON_ID, () => {
addons.add(TOOL_ID, {
type: types.TOOL,
title: "CSS pseudo states",
match: ({ viewMode }) => viewMode === "story",
render: PseudoStateTool
});
});
8 changes: 8 additions & 0 deletions dist/preview.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import * as _storybook_types from '@storybook/types';

declare const decorators: _storybook_types.DecoratorFunction<_storybook_types.Renderer, _storybook_types.Args>[];
declare const globals: {
pseudo: boolean;
};

export { decorators, globals };
Loading

0 comments on commit 75c5ef0

Please sign in to comment.