generated from storybookjs/addon-kit
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Pull type defs from constants into types.ts and fix eyebrow progress …
…overview
- Loading branch information
1 parent
b61d599
commit 7cd0334
Showing
17 changed files
with
295 additions
and
284 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
import { TaskName } from "chromatic/node"; | ||
import { filesize } from "filesize"; | ||
|
||
import { KnownStep, RunningBuildPayload } from "./types"; | ||
|
||
export const isKnownStep = (task: TaskName): task is KnownStep => | ||
BUILD_STEP_ORDER.includes(task as KnownStep); | ||
|
||
// Note this does not include the "complete" and "error" steps | ||
export const BUILD_STEP_ORDER: KnownStep[] = [ | ||
"initialize", | ||
"build", | ||
"upload", | ||
"verify", | ||
"snapshot", | ||
]; | ||
|
||
export const BUILD_STEP_CONFIG: Record< | ||
RunningBuildPayload["step"], | ||
{ | ||
key: RunningBuildPayload["step"]; | ||
emoji: string; | ||
renderName: () => string; | ||
renderProgress: (payload: RunningBuildPayload) => string; | ||
renderComplete: () => string; | ||
weight: number; | ||
} | ||
> = { | ||
initialize: { | ||
key: "initialize", | ||
emoji: "🚀", | ||
renderName: () => `Initialize build`, | ||
renderProgress: () => `Initializing build`, | ||
renderComplete: () => `Initialized`, | ||
weight: 5, | ||
}, | ||
build: { | ||
key: "build", | ||
emoji: "🏗", | ||
renderName: () => `Build Storybook`, | ||
renderProgress: () => `Building your Storybook...`, | ||
renderComplete: () => `Storybook built`, | ||
weight: 35, | ||
}, | ||
upload: { | ||
key: "upload", | ||
emoji: "📡", | ||
renderName: () => `Publish your Storybook`, | ||
renderProgress: (payload) => { | ||
if (!payload.stepProgressTotal) return `Uploading files`; | ||
const { value: total, exponent } = filesize(payload.stepProgressTotal, { | ||
output: "object", | ||
round: 1, | ||
}); | ||
const { value: progress, symbol } = filesize(payload.stepProgressValue, { | ||
exponent, | ||
output: "object", | ||
round: 1, | ||
}); | ||
return `Uploading files (${progress}/${total} ${symbol})`; | ||
}, | ||
renderComplete: () => `Publish complete`, | ||
weight: 15, | ||
}, | ||
verify: { | ||
key: "verify", | ||
emoji: "🔍", | ||
renderName: () => `Verify your Storybook`, | ||
renderProgress: () => `Verifying contents...`, | ||
renderComplete: () => `Storybook verified`, | ||
weight: 10, | ||
}, | ||
snapshot: { | ||
key: "snapshot", | ||
emoji: "📸", | ||
renderName: () => `Run visual tests`, | ||
renderProgress: (payload) => | ||
payload.stepProgressTotal | ||
? `Running visual tests (${payload.stepProgressValue}/${payload.stepProgressTotal})` | ||
: `Running visual tests`, | ||
renderComplete: () => `Tested your stories`, | ||
weight: 35, | ||
}, | ||
|
||
// These are special steps that are not part of the build process | ||
complete: { | ||
key: "complete", | ||
emoji: "🎉", | ||
renderName: () => `Visual tests completed!`, | ||
renderProgress: () => `Visual tests completed!`, | ||
renderComplete: () => `Visual tests completed!`, | ||
weight: 0, | ||
}, | ||
error: { | ||
key: "error", | ||
emoji: "🚨", | ||
renderName: () => `Build failed`, | ||
renderProgress: () => `Build failed`, | ||
renderComplete: () => `Build failed`, | ||
weight: 0, | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,17 @@ | ||
import React from "react"; | ||
|
||
import { RunningBuildPayload } from "../constants"; | ||
|
||
const messageMap: Record<RunningBuildPayload["step"], (payload: RunningBuildPayload) => string> = { | ||
initialize: () => `📦 Validating Storybook files...`, | ||
build: () => `📦 Validating Storybook files...`, | ||
upload: () => `📡 Uploading to Chromatic...`, // TODO represent progress in bytes | ||
verify: () => `🛠️ Initiating build...`, // TODO build number | ||
snapshot: () => `👀 Running visual tests...`, // TODO count | ||
complete: () => `🎉 Visual tests completed!`, | ||
error: () => `❌ Build failed`, // TODO error | ||
}; | ||
import { BUILD_STEP_CONFIG } from "../buildSteps"; | ||
import { RunningBuildPayload } from "../types"; | ||
|
||
interface BuildProgressLabelProps { | ||
runningBuild: RunningBuildPayload; | ||
} | ||
|
||
export const BuildProgressLabel = ({ runningBuild }: BuildProgressLabelProps) => ( | ||
<>{messageMap[runningBuild.step](runningBuild)}</> | ||
); | ||
export const BuildProgressLabel = ({ runningBuild }: BuildProgressLabelProps) => { | ||
const { emoji, renderProgress } = BUILD_STEP_CONFIG[runningBuild.step]; | ||
return ( | ||
<> | ||
{emoji} {renderProgress(runningBuild)} | ||
</> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.