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