mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-10 14:28:35 +00:00
improvements: address feedback
This commit is contained in:
@@ -0,0 +1,12 @@
|
|||||||
|
import { useEffect } from "react";
|
||||||
|
import type { Decorator } from "@storybook/react-vite";
|
||||||
|
|
||||||
|
export const DocumentDecorator: Decorator = (Story) => {
|
||||||
|
useEffect(() => {
|
||||||
|
const root = document.getElementsByTagName("html")[0];
|
||||||
|
|
||||||
|
root.setAttribute("class", "overflow-visible");
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
return <Story />;
|
||||||
|
};
|
||||||
@@ -1,17 +1,17 @@
|
|||||||
|
import { useMemo } from "react";
|
||||||
import type { Decorator } from "@storybook/react-vite";
|
import type { Decorator } from "@storybook/react-vite";
|
||||||
import { createRootRoute, createRouter, RouterProvider } from "@tanstack/react-router";
|
import { createRootRoute, createRouter, RouterProvider } from "@tanstack/react-router";
|
||||||
|
|
||||||
export const RouterDecorator: Decorator = (Story) => {
|
export const RouterDecorator: Decorator = (Story) => {
|
||||||
const rootRoute = createRootRoute({
|
const router = useMemo(() => {
|
||||||
|
const routeTree = createRootRoute({
|
||||||
component: Story
|
component: Story
|
||||||
});
|
});
|
||||||
|
|
||||||
const routeTree = rootRoute;
|
return createRouter({
|
||||||
|
|
||||||
const router = createRouter({
|
|
||||||
routeTree
|
routeTree
|
||||||
});
|
});
|
||||||
|
}, [Story]);
|
||||||
|
|
||||||
// @ts-expect-error just to make Links happy :)
|
return <RouterProvider router={router as any} />;
|
||||||
return <RouterProvider router={router} />;
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1 +1,2 @@
|
|||||||
|
export * from "./DocumentDecorator";
|
||||||
export * from "./RouterDecorator";
|
export * from "./RouterDecorator";
|
||||||
|
|||||||
@@ -1,20 +1,11 @@
|
|||||||
import type { Preview } from "@storybook/react-vite";
|
import type { Preview } from "@storybook/react-vite";
|
||||||
|
|
||||||
import { RouterDecorator } from "./decorators";
|
import { DocumentDecorator, RouterDecorator } from "./decorators";
|
||||||
|
|
||||||
import "../src/index.css";
|
import "../src/index.css";
|
||||||
|
|
||||||
const preview: Preview = {
|
const preview: Preview = {
|
||||||
decorators: [
|
decorators: [DocumentDecorator, RouterDecorator],
|
||||||
(Story) => {
|
|
||||||
const root = document.getElementsByTagName("html")[0];
|
|
||||||
|
|
||||||
root.setAttribute("class", "overflow-visible");
|
|
||||||
|
|
||||||
return <Story />;
|
|
||||||
},
|
|
||||||
RouterDecorator
|
|
||||||
],
|
|
||||||
parameters: {
|
parameters: {
|
||||||
controls: {
|
controls: {
|
||||||
matchers: {
|
matchers: {
|
||||||
|
|||||||
@@ -222,7 +222,7 @@ export const AsExternalLink: Story = {
|
|||||||
variant: "info",
|
variant: "info",
|
||||||
asChild: true,
|
asChild: true,
|
||||||
children: (
|
children: (
|
||||||
<a href="https://infisical.com/">
|
<a target="_blank" rel="noopener noreferrer" href="https://infisical.com/">
|
||||||
Link <ExternalLinkIcon />
|
Link <ExternalLinkIcon />
|
||||||
</a>
|
</a>
|
||||||
)
|
)
|
||||||
@@ -263,7 +263,7 @@ export const AsButton: Story = {
|
|||||||
variant: "org",
|
variant: "org",
|
||||||
asChild: true,
|
asChild: true,
|
||||||
children: (
|
children: (
|
||||||
<button type="button" onClick={() => alert("button clicked")}>
|
<button type="button" onClick={() => console.log("click")}>
|
||||||
<GlobeIcon />
|
<GlobeIcon />
|
||||||
Organization
|
Organization
|
||||||
<ChevronsUpDownIcon />
|
<ChevronsUpDownIcon />
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ type TBadgeProps = VariantProps<typeof badgeVariants> &
|
|||||||
asChild?: boolean;
|
asChild?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
const Badge = forwardRef<HTMLButtonElement | HTMLSpanElement | HTMLAnchorElement, TBadgeProps>(
|
const Badge = forwardRef<HTMLSpanElement, TBadgeProps>(
|
||||||
({ className, variant, asChild = false, isTruncatable = false, ...props }, ref): JSX.Element => {
|
({ className, variant, asChild = false, isTruncatable = false, ...props }, ref): JSX.Element => {
|
||||||
const Comp = asChild ? Slot : "span";
|
const Comp = asChild ? Slot : "span";
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -32,6 +32,6 @@
|
|||||||
"./src/**/*.ts",
|
"./src/**/*.ts",
|
||||||
"./src/**/*.tsx",
|
"./src/**/*.tsx",
|
||||||
"./.storybook/**/*.ts",
|
"./.storybook/**/*.ts",
|
||||||
"./.storybook/**/*.tsx",
|
"./.storybook/**/*.tsx"
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user