Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show project picker when no project id is in main.js #10

Merged
Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
d439a03
add back prerelease check so we have somewhere to add additional chec…
weeksling Jun 26, 2023
1973bd0
WIP: Adding the useParameter hook to get the projectId and token (cur…
weeksling Jun 27, 2023
9b64dae
Accounts and Projects graphql types and queries
weeksling Jun 28, 2023
d548777
fix parameters error move useProjectId to Panel. Includes bare ui
weeksling Jun 28, 2023
b65c2ea
clean up comments, imports, jsx
weeksling Jun 28, 2023
d68d08a
Add boilerplate for adding projectId (rename to appId) config to prev…
weeksling Jun 28, 2023
814b627
Cleaned up UI and removed private repo form
weeksling Jul 5, 2023
8ff7c7b
connected projectId selection and add in memory variable for singleton
weeksling Jul 5, 2023
33818eb
Display visual tests after selecting a project and in memory selected…
weeksling Jul 5, 2023
f04fdf5
Adding serverChannel methods to update the storybook config directly …
weeksling Jun 26, 2023
5d62f8b
Include projectToken in updateProject hook and serverChannel
weeksling Jul 5, 2023
5690a40
Update useProjectId hook to use memo to return projectId in preview c…
weeksling Jul 5, 2023
84e978f
serverChannel updates preview.tsx - main.ts update currently not working
weeksling Jul 5, 2023
bd2ab4f
Update selector with correct schema
weeksling Jul 11, 2023
fb359d2
Fix visual test queries (useProjectId only in panel, no parameters ho…
weeksling Jul 11, 2023
b39b004
Use `main.js` and env for projectId + git info
tmeasday Jul 13, 2023
b61c87d
Use update project token for builds
tmeasday Jul 13, 2023
77dd481
Pass branch into `VisualTests`
tmeasday Jul 13, 2023
96a5b3c
Switch to default export
tmeasday Jul 13, 2023
5246be4
Don't set env in prod
tmeasday Jul 13, 2023
a4f2299
Fix formatting
ghengeveld Jul 14, 2023
10f2b5e
Fix formatting
ghengeveld Jul 14, 2023
4d2869b
Fix formatting
ghengeveld Jul 14, 2023
870c0a8
cleanup
ndelangen Jul 14, 2023
7a86c94
add slug partially implemented
ndelangen Jul 14, 2023
f60be53
Update src/Panel.tsx
ghengeveld Jul 14, 2023
6df7fd8
Validate slug and pass it to the project.lastBuild field
ghengeveld Jul 14, 2023
ceb649b
Merge branch 'main' into matt/ap-3260-project-picker-with-chromatic-a…
ghengeveld Jul 15, 2023
f8c401c
Fix missing dependency and bad import
ghengeveld Jul 15, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 1 addition & 8 deletions .storybook/main.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
import type { StorybookConfig } from "@storybook/react-vite";

const CHROMATIC_BASE_URL = process.env.CHROMATIC_BASE_URL || "https://www.chromatic.com";

const config: StorybookConfig = {
addons: [
{
Expand All @@ -17,16 +14,13 @@ const config: StorybookConfig = {
name: "../dist/index.js",
options: {
projectToken: "chpt_c4206d1157d8947",
projectId: "6480e1b0042842f149cfd74c", // Default to the the production project of this addon - WILL BE MOVED TO preview.tsx since we can't access options in the manager.
},
},
],
docs: {
autodocs: "tag",
},
env: (config) => ({
...config,
CHROMATIC_BASE_URL,
}),
framework: {
name: "@storybook/react-vite",
options: {},
Expand All @@ -35,5 +29,4 @@ const config: StorybookConfig = {
stories: ["../src/**/*.stories.@(js|jsx|ts|tsx)"],
logLevel: "debug",
};

export default config;
174 changes: 86 additions & 88 deletions .storybook/preview.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,4 @@
import {
Global,
ThemeProvider,
themes,
createReset,
convert,
styled,
useTheme,
} from "@storybook/theming";
import { Global, ThemeProvider, themes, createReset, convert, styled, useTheme } from "@storybook/theming";
import type { Preview } from "@storybook/react";
import { initialize, mswDecorator } from "msw-storybook-addon";
import React from "react";
Expand All @@ -15,44 +7,40 @@ import React from "react";
initialize({
onUnhandledRequest(req) {
if (req.url.origin !== document.location.origin) {
console.error(
`[MSW] %s %s %s (UNHANDLED)`,
new Date().toTimeString().slice(0, 8),
req.method.toUpperCase(),
req.url.href
);
console.error(`[MSW] %s %s %s (UNHANDLED)`, new Date().toTimeString().slice(0, 8), req.method.toUpperCase(), req.url.href);
}
},
});

const Panels = styled.div<{ orientation: "right" | "bottom" }>(
({ orientation }) => ({
flexDirection: orientation === "right" ? "row" : "column",
}),
{
display: "flex",
justifyContent: "center",
alignItems: "center",
gap: 40,
margin: 40,
}
);

const Panel = styled.div<{ orientation: "right" | "bottom" }>(
({ orientation }) => ({
width: orientation === "right" ? 420 : 880,
height: orientation === "right" ? 640 : 300,
overflow: "auto",
}),
({ theme }) => ({
position: "relative",
outline: `1px solid ${theme.color.border}`,
background: theme.background.content,
color: theme.color.defaultText,
fontSize: theme.typography.size.s2 - 1,
})
);

});
const Panels = styled.div<{
orientation: "right" | "bottom";
}>(({
orientation
}) => ({
flexDirection: orientation === "right" ? "row" : "column"
}), {
display: "flex",
justifyContent: "center",
alignItems: "center",
gap: 40,
margin: 40
});
const Panel = styled.div<{
orientation: "right" | "bottom";
}>(({
orientation
}) => ({
width: orientation === "right" ? 420 : 880,
height: orientation === "right" ? 640 : 300,
overflow: "auto"
}), ({
theme
}) => ({
position: "relative",
outline: `1px solid ${theme.color.border}`,
background: theme.background.content,
color: theme.color.defaultText,
fontSize: theme.typography.size.s2 - 1
}));
const ThemedSetRoot = () => {
const theme = useTheme();
React.useEffect(() => {
Expand All @@ -62,77 +50,87 @@ const ThemedSetRoot = () => {
});
return null;
};

export const decorators = [
// Provide the MSW addon decorator globally
mswDecorator,

// Render two panels side-by-side or stacked, depending on selected orientation
// Note this assumes any play functions are equipped to deal with multiple canvases
(StoryFn, { globals, parameters }) => {
(StoryFn, {
globals,
parameters
}) => {
const theme = globals.theme || parameters.theme || "right";
return theme === "light" || theme === "dark" ? (
<ThemeProvider theme={convert(themes[theme])}>
return theme === "light" || theme === "dark" ? <ThemeProvider theme={convert(themes[theme])}>
<Global styles={createReset} />
<Global styles={{
"#storybook-root": {
height: "100vh",
padding: 0
}
}}></Global>
<ThemedSetRoot />
<StoryFn />
</ThemeProvider> : <>
<ThemeProvider theme={convert(themes.light)}>
<Global styles={createReset} />
<Global styles={{ "#storybook-root": { height: "100vh", padding: 0 } }}></Global>
<ThemedSetRoot />
<StoryFn />
</ThemeProvider>
) : (
<>
<Panels orientation={theme}>
<ThemeProvider theme={convert(themes.light)}>
<Global styles={createReset} />
<ThemedSetRoot />
<Panel orientation={theme} data-canvas={theme}>
<StoryFn />
</Panel>
</ThemeProvider>
<Panels orientation={theme}>
<ThemeProvider theme={convert(themes.light)}>
<Panel orientation={theme} data-canvas={theme}>
<StoryFn />
</Panel>
</ThemeProvider>
<ThemeProvider theme={convert(themes.dark)}>
<Panel orientation={theme} data-canvas={theme}>
<StoryFn />
</Panel>
</ThemeProvider>
</Panels>
</>
);
},
];

<ThemeProvider theme={convert(themes.dark)}>
<Panel orientation={theme} data-canvas={theme}>
<StoryFn />
</Panel>
</ThemeProvider>
</Panels>
</>;
}];
export const parameters: Preview["parameters"] = {
actions: {
argTypesRegex: "^on[A-Z].*",
argTypesRegex: "^on[A-Z].*"
},
backgrounds: {
disable: true,
disable: true
},
chromatic: {
viewports: [960],
viewports: [960]
},
controls: {
matchers: {
color: /(background|color)$/i,
date: /Date$/,
},
date: /Date$/
}
},
layout: "fullscreen",
layout: "fullscreen"
};

export const globalTypes = {
theme: {
name: "Theme",
description: "Panel theme",
toolbar: {
icon: "sidebaralt",
title: "Theme",
items: [
{ value: "light", icon: "circlehollow", title: "Light" },
{ value: "dark", icon: "circle", title: "Dark" },
{ value: "right", icon: "sidebaralt", title: "Right 2-up" },
{ value: "bottom", icon: "bottombar", title: "Bottom 2-up" },
],
},
},
items: [{
value: "light",
icon: "circlehollow",
title: "Light"
}, {
value: "dark",
icon: "circle",
title: "Dark"
}, {
value: "right",
icon: "sidebaralt",
title: "Right 2-up"
}, {
value: "bottom",
icon: "bottombar",
title: "Bottom 2-up"
}]
}
}
};
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,11 @@
"lint": "eslint src --max-warnings 0 --report-unused-disable-directives",
"release": "pnpm run build && auto shipit",
"start": "run-p build:watch 'storybook --quiet'",
"storybook": "storybook dev -p 6006"
"prerelease": "zx scripts/prepublish-checks.mjs",
"storybook": "CHROMATIC_ADDON_NAME='../dist/index.js' storybook dev -p 6006"
},
"dependencies": {
"@storybook/csf-tools": "^7.1.0-alpha.34",
"@storybook/design-system": "^7.15.11",
"chromatic": "^6.19.8",
"date-fns": "^2.30.0",
Expand Down
Loading