UNPKG

@kemuridama/storybook-addon-github

Version:

A Storybook addon that allows you to link a source code of your story on GitHub.

29 lines 1.04 kB
import { IconButton, Icons } from "@storybook/components"; import { useParameter } from "@storybook/manager-api"; import { jsx as _jsx } from "react/jsx-runtime"; export var GitHub = function GitHub(_ref) { var active = _ref.active, api = _ref.api; var currentStoryData = api.getCurrentStoryData(); var _useParameter = useParameter("github", {}), _useParameter$baseURL = _useParameter.baseURL, baseURL = _useParameter$baseURL === void 0 ? "https://github.com" : _useParameter$baseURL, repository = _useParameter.repository, branch = _useParameter.branch; if (!currentStoryData || !repository || !branch) { return null; } var url = [baseURL, repository, "blob", branch, currentStoryData.importPath.replace(/\.\//, "")].join("/"); return /*#__PURE__*/_jsx(IconButton, { active: active, children: /*#__PURE__*/_jsx("a", { href: url, title: "GitHub", target: "_blank", rel: "noreferrer", children: /*#__PURE__*/_jsx(Icons, { icon: "github" }) }) }); };