Skip to content

Commit c8ad066

Browse files
committed
Dashboard storybook minor cleanup + fix crashing stories (#5359)
## Problem solved Short description of the bug fixed or feature added <!-- start pr-codex --> --- ## PR-Codex overview This PR primarily focuses on updating the titles in various story files to follow a consistent naming convention, improving UI component integration, and enhancing the use of the `getThirdwebClient()` function across multiple components. ### Detailed summary - Updated titles in story files for consistency. - Modified `StatBreakdownCard` to use a max width. - Integrated `getThirdwebClient()` in multiple components. - Adjusted `AccountTeamsUI` and `TeamRow` to accept `client` as a prop. - Enhanced theme handling in the Storybook preview. > ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}` <!-- end pr-codex -->
1 parent 0bba414 commit c8ad066

22 files changed

+65
-62
lines changed

apps/dashboard/.storybook/preview.tsx

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,13 @@ import type { Preview } from "@storybook/react";
22
import "@/styles/globals.css";
33
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
44
import { MoonIcon, SunIcon } from "lucide-react";
5+
import { ThemeProvider, useTheme } from "next-themes";
56
import { Inter as interFont } from "next/font/google";
67
// biome-ignore lint/style/useImportType: <explanation>
7-
import React, { useState } from "react";
8+
import React from "react";
89
import { useEffect } from "react";
910
import { Button } from "../src/@/components/ui/button";
1011

11-
// Note: Wrapping the Stoy with AppRouterProviders makes the storybook server time SUPER SLOW
12-
// so let's just not have it there - all stories should be independent from context anyway and just rely on props
13-
1412
const queryClient = new QueryClient();
1513

1614
const fontSans = interFont({
@@ -31,9 +29,16 @@ const preview: Preview = {
3129
decorators: [
3230
(Story) => {
3331
return (
34-
<StoryLayout>
35-
<Story />
36-
</StoryLayout>
32+
<ThemeProvider
33+
attribute="class"
34+
disableTransitionOnChange
35+
enableSystem={false}
36+
defaultTheme="dark"
37+
>
38+
<StoryLayout>
39+
<Story />
40+
</StoryLayout>
41+
</ThemeProvider>
3742
);
3843
},
3944
],
@@ -44,34 +49,36 @@ export default preview;
4449
function StoryLayout(props: {
4550
children: React.ReactNode;
4651
}) {
47-
const [theme, setTheme] = useState<"light" | "dark">("dark");
52+
const { setTheme, theme } = useTheme();
4853

4954
useEffect(() => {
50-
document.body.className = `font-sans antialiased ${fontSans.variable} ${theme === "dark" ? " dark" : ""}`;
51-
}, [theme]);
55+
document.body.className = `font-sans antialiased ${fontSans.variable}`;
56+
}, []);
5257

5358
return (
5459
<QueryClientProvider client={queryClient}>
55-
<div className="min-h-screen flex flex-col bg-background text-foreground min-w-0">
56-
<div className="flex justify-end p-4 border-b gap-2">
60+
<div className="flex min-h-screen min-w-0 flex-col bg-background text-foreground">
61+
<div className="flex justify-end gap-2 border-b p-4">
5762
<Button
5863
onClick={() => setTheme("dark")}
5964
size="sm"
60-
variant={theme === "dark" ? "default" : "ghost"}
65+
variant={theme === "dark" ? "default" : "outline"}
66+
className="h-auto w-auto rounded-full p-2"
6167
>
62-
<MoonIcon className="size-5" />
68+
<MoonIcon className="size-4" />
6369
</Button>
6470

6571
<Button
6672
onClick={() => setTheme("light")}
6773
size="sm"
68-
variant={theme === "light" ? "default" : "ghost"}
74+
variant={theme === "light" ? "default" : "outline"}
75+
className="h-auto w-auto rounded-full p-2"
6976
>
70-
<SunIcon className="size-5" />
77+
<SunIcon className="size-4" />
7178
</Button>
7279
</div>
7380

74-
<div className="grow flex flex-col min-w-0">{props.children}</div>
81+
<div className="flex min-w-0 grow flex-col">{props.children}</div>
7582
</div>
7683
</QueryClientProvider>
7784
);

apps/dashboard/src/@/components/blocks/DangerSettingCard.stories.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { BadgeContainer, mobileViewport } from "../../../stories/utils";
33
import { DangerSettingCard } from "./DangerSettingCard";
44

55
const meta = {
6-
title: "blocks/DangerSettingCard",
6+
title: "blocks/Cards/DangerSettingCard",
77
component: Story,
88
parameters: {
99
nextjs: {

apps/dashboard/src/@/components/blocks/SettingsCard.stories.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { BadgeContainer, mobileViewport } from "../../../stories/utils";
33
import { SettingsCard } from "./SettingsCard";
44

55
const meta = {
6-
title: "blocks/SettingsCard",
6+
title: "Blocks/Cards/SettingsCard",
77
component: Story,
88
parameters: {
99
nextjs: {

apps/dashboard/src/@/components/ui/select.stories.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import type { Meta, StoryObj } from "@storybook/react";
1111
import { BadgeContainer } from "../../../stories/utils";
1212

1313
const meta = {
14-
title: "Shadcn/select",
14+
title: "Shadcn/Select",
1515
component: Component,
1616
parameters: {
1717
layout: "centered",

apps/dashboard/src/@/components/ui/table.stories.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { BadgeContainer, mobileViewport } from "../../../stories/utils";
1313
import { Badge } from "./badge";
1414

1515
const meta = {
16-
title: "Shadcn/table",
16+
title: "Shadcn/Table",
1717
component: Component,
1818
parameters: {
1919
layout: "centered",

apps/dashboard/src/app/account/components/AccountHeaderUI.stories.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {
1010
} from "./AccountHeaderUI";
1111

1212
const meta = {
13-
title: "Account/Account Header",
13+
title: "Headers/AccountHeader",
1414
component: Variants,
1515
parameters: {
1616
nextjs: {

apps/dashboard/src/app/account/overview/AccountTeamsUI.stories.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { getThirdwebClient } from "@/constants/thirdweb.server";
12
import type { Meta, StoryObj } from "@storybook/react";
23
import { teamStub } from "../../../stories/stubs";
34
import { BadgeContainer, mobileViewport } from "../../../stories/utils";
@@ -36,6 +37,7 @@ function Variants() {
3637
<div className="container mx-auto flex w-full max-w-[1100px] flex-col gap-10 py-10">
3738
<BadgeContainer label="4 Teams">
3839
<AccountTeamsUI
40+
client={getThirdwebClient()}
3941
teamsWithRole={[
4042
{
4143
team: teamStub("1", "free"),
@@ -59,6 +61,7 @@ function Variants() {
5961

6062
<BadgeContainer label="1 Team">
6163
<AccountTeamsUI
64+
client={getThirdwebClient()}
6265
teamsWithRole={[
6366
{
6467
team: teamStub("1", "free"),

apps/dashboard/src/app/account/overview/AccountTeamsUI.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ import {
1111
DropdownMenuTrigger,
1212
} from "@/components/ui/dropdown-menu";
1313
import { ToolTipLabel } from "@/components/ui/tooltip";
14-
import { useThirdwebClient } from "@/constants/thirdweb.client";
1514
import { EllipsisIcon, PlusIcon } from "lucide-react";
1615
import Link from "next/link";
1716
import { useState } from "react";
17+
import type { ThirdwebClient } from "thirdweb";
1818
import { TeamPlanBadge } from "../../components/TeamPlanBadge";
1919
import { getValidTeamPlan } from "../../team/components/TeamHeader/getValidTeamPlan";
2020
import { SearchInput } from "../components/SearchInput";
@@ -24,6 +24,7 @@ export function AccountTeamsUI(props: {
2424
team: Team;
2525
role: TeamAccountRole;
2626
}[];
27+
client: ThirdwebClient;
2728
}) {
2829
const [teamSearchValue, setTeamSearchValue] = useState("");
2930
const teamsToShow = !teamSearchValue
@@ -70,7 +71,7 @@ export function AccountTeamsUI(props: {
7071
key={v.team.id}
7172
className="border-border border-b p-4 last:border-b-0"
7273
>
73-
<TeamRow team={v.team} role={v.role} />
74+
<TeamRow team={v.team} role={v.role} client={props.client} />
7475
</li>
7576
);
7677
})}
@@ -97,8 +98,8 @@ export function AccountTeamsUI(props: {
9798
function TeamRow(props: {
9899
team: Team;
99100
role: TeamAccountRole;
101+
client: ThirdwebClient;
100102
}) {
101-
const client = useThirdwebClient();
102103
const plan = getValidTeamPlan(props.team);
103104

104105
return (
@@ -109,7 +110,7 @@ function TeamRow(props: {
109110
className="size-8"
110111
src={props.team.image}
111112
id={props.team.id}
112-
client={client}
113+
client={props.client}
113114
/>
114115

115116
<div>

apps/dashboard/src/app/account/page.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { getTeams } from "@/api/team";
22
import { getMembers } from "@/api/team-members";
3+
import { getThirdwebClient } from "@/constants/thirdweb.server";
34
import { BillingAlerts } from "components/settings/Account/Billing/alerts/Alert";
45
import { redirect } from "next/navigation";
56
import { AccountTeamsUI } from "./overview/AccountTeamsUI";
@@ -40,7 +41,10 @@ export default async function Page() {
4041
return (
4142
<div className="container grow py-8">
4243
<BillingAlerts className="mb-10" />
43-
<AccountTeamsUI teamsWithRole={teamsWithRole} />
44+
<AccountTeamsUI
45+
teamsWithRole={teamsWithRole}
46+
client={getThirdwebClient()}
47+
/>
4448
</div>
4549
);
4650
}

apps/dashboard/src/app/team/[team_slug]/(team)/~/engine/(instance)/[engineId]/alerts/components/ManageEngineAlerts.stories.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { BadgeContainer, mobileViewport } from "stories/utils";
1313
import { ManageEngineAlertsSectionUI } from "./ManageEngineAlerts";
1414

1515
const meta = {
16-
title: "engine/alerts/manage",
16+
title: "Engine/Alerts/Manage Alerts",
1717
component: Story,
1818
parameters: {
1919
nextjs: {

0 commit comments

Comments
 (0)