Skip to content

Commit 651b800

Browse files
committed
Add storybook
1 parent 5fa1f8f commit 651b800

File tree

10 files changed

+214
-274
lines changed

10 files changed

+214
-274
lines changed

site/.storybook/preview.jsx

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ export const decorators = [
1717
(Story, context) => {
1818
const selectedTheme = DecoratorHelpers.pluckThemeFromContext(context);
1919
const { themeOverride } = DecoratorHelpers.useThemeParameters();
20-
2120
const selected = themeOverride || selectedTheme || "dark";
2221

2322
return (
@@ -39,23 +38,7 @@ export const decorators = [
3938
</HelmetProvider>
4039
);
4140
},
42-
(Story) => {
43-
return (
44-
<QueryClientProvider
45-
client={
46-
new QueryClient({
47-
defaultOptions: {
48-
queries: {
49-
staleTime: Infinity,
50-
},
51-
},
52-
})
53-
}
54-
>
55-
<Story />
56-
</QueryClientProvider>
57-
);
58-
},
41+
withQuery,
5942
];
6043

6144
export const parameters = {
@@ -89,3 +72,25 @@ export const parameters = {
8972
},
9073
},
9174
};
75+
76+
function withQuery(Story, { parameters }) {
77+
const queryClient = new QueryClient({
78+
defaultOptions: {
79+
queries: {
80+
staleTime: Infinity,
81+
},
82+
},
83+
});
84+
85+
if (parameters.queries) {
86+
parameters.queries.forEach((query) => {
87+
queryClient.setQueryData(query.key, query.data);
88+
});
89+
}
90+
91+
return (
92+
<QueryClientProvider client={queryClient}>
93+
<Story />
94+
</QueryClientProvider>
95+
);
96+
}

site/src/@types/storybook.d.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import * as _storybook_types from "@storybook/react";
2+
import { Experiments, FeatureName } from "api/typesGenerated";
3+
import { QueryKey } from "react-query";
4+
5+
declare module "@storybook/react" {
6+
interface Parameters {
7+
features?: FeatureName[];
8+
experiments?: Experiments;
9+
queries?: { key: QueryKey; data: unknown }[];
10+
}
11+
}

site/src/api/queries/workspaceQuota.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as API from "api/api";
22

3-
const getWorkspaceQuotaQueryKey = (username: string) => [
3+
export const getWorkspaceQuotaQueryKey = (username: string) => [
44
username,
55
"workspaceQuota",
66
];
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
1-
export * from "../../pages/WorkspacePage/WorkspaceTopbar/DormantTopbarData";
21
export * from "./DormantDeletionText";
32
export * from "./DormantWorkspaceBanner";

site/src/pages/WorkspacePage/WorkspaceStats.stories.tsx

Lines changed: 0 additions & 53 deletions
This file was deleted.

site/src/pages/WorkspacePage/WorkspaceStats.tsx

Lines changed: 0 additions & 137 deletions
This file was deleted.

site/src/pages/WorkspacePage/WorkspaceTopbar/DormantTopbarData.tsx

Lines changed: 0 additions & 49 deletions
This file was deleted.

0 commit comments

Comments
 (0)