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

Adjust UI to Support Dark Mode #179

Merged
merged 30 commits into from
Feb 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
be6704c
Adjust UI to Support Dark Mode
thafryer Feb 6, 2024
385705b
Adjust UI to Support Dark Mode
thafryer Feb 6, 2024
2efb7d0
Fine tune UI layout
domyen Feb 7, 2024
9b3b339
Add ellipses to build progress (removed hardcoded eliipses)
domyen Feb 8, 2024
2f1208d
Increase text contrast light mode
domyen Feb 8, 2024
fb9957c
Minor tweak
domyen Feb 8, 2024
a998ab0
Style pre snippets
domyen Feb 8, 2024
e383672
Fixes and tweaks
domyen Feb 8, 2024
2aa292e
Fine tune SnapshotImage hover state
domyen Feb 8, 2024
80a7351
Spacing tweaks
domyen Feb 8, 2024
84fe564
Fine tune more styles
domyen Feb 9, 2024
0581ac2
More layout and style fine tuning
domyen Feb 9, 2024
102723f
Minor tweaks for capitalization and spacing
domyen Feb 12, 2024
7d4c83c
Fix: consistent footer borderTop
domyen Feb 12, 2024
0d906c6
Use the universal appBorderColor for dark mode borders instead of che…
domyen Feb 12, 2024
27b15f7
Fix double border issue in layout
domyen Feb 12, 2024
9f0fd9b
Merge branch 'main' into dark-mode-adjustments
domyen Feb 12, 2024
ca800c2
Section: remove `last` prop to reconcile how we add borders
domyen Feb 12, 2024
57a015c
Remove border from Eyebrow
domyen Feb 12, 2024
542b6c2
Fix regressions
domyen Feb 12, 2024
8e26ba1
Minor copy updates
domyen Feb 13, 2024
a972048
Fix error message placement
domyen Feb 13, 2024
ccb27f2
Align messages and styles, fix a hardcoded message that was wrong
domyen Feb 13, 2024
1c49b76
Update src/components/BrowserSelector.tsx
domyen Feb 13, 2024
7d113c1
Update src/components/ModeSelector.tsx
domyen Feb 13, 2024
5b01dca
ProjectSelect: Fix dark mode and style it properly
domyen Feb 14, 2024
00adfea
Add correct hover state
domyen Feb 14, 2024
0ce6290
Add margin to sidebarbutton
domyen Feb 14, 2024
8f719f4
Merge branch 'dark-mode-adjustments' of https://github.com/chromaui/a…
domyen Feb 14, 2024
29b0d8c
Merge branch 'main' into dark-mode-adjustments
domyen Feb 14, 2024
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
2 changes: 1 addition & 1 deletion .storybook/preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ const Panel = styled.div<{ orientation: "right" | "bottom" }>(
// Add a backdrop to the outline because appBorderColor is semi-transparent
boxShadow: `0 0 0 1px ${theme.background.content}`,
background: theme.background.content,
color: theme.color.defaultText,
color: theme.base === "light" ? theme.color.dark : theme.color.mediumlight,
fontSize: theme.typography.size.s2 - 1,
})
);
Expand Down
10 changes: 5 additions & 5 deletions src/buildSteps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export const BUILD_STEP_CONFIG: Record<
key: "initialize",
emoji: "🚀",
renderName: () => `Initialize build`,
renderProgress: () => `Initializing build`,
renderProgress: () => `Initializing build...`,
renderComplete: () => `Initialized`,
estimateDuration: 2000,
},
Expand All @@ -52,7 +52,7 @@ export const BUILD_STEP_CONFIG: Record<
renderName: () => `Publish your Storybook`,
renderProgress: ({ stepProgress }) => {
const { numerator, denominator } = stepProgress.upload;
if (!denominator || !numerator) return `Uploading files`;
if (!denominator || !numerator) return `Uploading files...`;
const { value: total, exponent } = filesize(denominator, {
output: "object",
round: 1,
Expand All @@ -62,7 +62,7 @@ export const BUILD_STEP_CONFIG: Record<
output: "object",
round: 1,
});
return `Uploading files (${progress}/${total} ${symbol})`;
return `Uploading files (${progress}/${total} ${symbol})...`;
},
renderComplete: () => `Publish complete`,
estimateDuration: 30_000,
Expand All @@ -82,8 +82,8 @@ export const BUILD_STEP_CONFIG: Record<
renderProgress: ({ stepProgress }) => {
const { numerator, denominator } = stepProgress.snapshot;
return denominator
? `Running visual tests (${numerator}/${denominator})`
: `Running visual tests`;
? `Running visual tests (${numerator}/${denominator})...`
: `Running visual tests...`;
},
renderComplete: () => `Tested your stories`,
estimateDuration: 60_000,
Expand Down
8 changes: 4 additions & 4 deletions src/components/ActionButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const themeColors = ({ theme, secondary, status }: { theme: Theme } & ActionButt
return {
color: theme.color.defaultText,
backgroundColor: theme.background.app,
borderColor: theme.base === "dark" ? theme.color.darker : theme.color.medium,
borderColor: theme.base === "light" ? theme.color.medium : theme.color.darker,
"&:hover": {
color: theme.color.defaultText,
backgroundColor: darken(0.03, theme.background.app),
Expand Down Expand Up @@ -43,9 +43,9 @@ const themeColors = ({ theme, secondary, status }: { theme: Theme } & ActionButt
backgroundColor: theme.color.secondary,
borderWidth: 0,
borderColor:
theme.base === "dark"
? darken(0.1, theme.color.secondary)
: lighten(0.2, theme.color.secondary),
theme.base === "light"
? lighten(0.2, theme.color.secondary)
: darken(0.1, theme.color.secondary),
"&:hover": {
color: theme.color.lightest,
backgroundColor: darken(0.05, theme.color.secondary),
Expand Down
3 changes: 2 additions & 1 deletion src/components/BackButton.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { Link } from "@storybook/components";
import { styled } from "@storybook/theming";
import React from "react";

import { Link } from "./design-system";

const OpaqueLink = styled(Link)({
"&&": {
fontSize: 13,
Expand Down
10 changes: 7 additions & 3 deletions src/components/BrowserSelector.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { TooltipNote, WithTooltip } from "@storybook/components";
import { ChevronDownIcon } from "@storybook/icons";
import { styled } from "@storybook/theming";
import { styled, useTheme } from "@storybook/theming";
import React, { ComponentProps } from "react";

import { Browser, BrowserInfo, ComparisonResult } from "../gql/graphql";
Expand All @@ -25,7 +25,6 @@ const IconWrapper = styled.div(({ theme }) => ({
gap: 6,
height: 16,
margin: "6px 7px",
color: `${theme.color.defaultText}99`,
svg: {
verticalAlign: "top",
},
Expand All @@ -37,6 +36,7 @@ const Label = styled.span(({ theme }) => ({
"@container (min-width: 300px)": {
display: "inline-block",
},
color: theme.base === "light" ? `${theme.color.defaultText}99` : theme.color.light,
}));

type BrowserData = Pick<BrowserInfo, "id" | "key" | "name">;
Expand All @@ -54,6 +54,7 @@ export const BrowserSelector = ({
browserResults,
onSelectBrowser,
}: BrowserSelectorProps) => {
const theme = useTheme();
const aggregate = aggregateResult(browserResults.map(({ result }) => result));
if (!aggregate) return null;

Expand Down Expand Up @@ -92,7 +93,10 @@ export const BrowserSelector = ({
<TooltipMenu placement="bottom" links={links}>
{icon}
<Label>{selectedBrowser.name}</Label>
<ChevronDownIcon style={{ width: 10, height: 10 }} />
<ChevronDownIcon
size={10}
color={theme.base === "light" ? `${theme.color.defaultText}99` : theme.color.light}
/>
</TooltipMenu>
) : (
<IconWrapper>
Expand Down
12 changes: 7 additions & 5 deletions src/components/BuildProgressBarInline.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ const ProgressTextWrapper = styled(Text)({
flexDirection: "column",
gap: 10,
width: 200,
marginTop: 15,
});

const StyledBuildProgressLabel = styled(BuildProgressLabel)({
fontSize: 12,
});

export function BuildProgressInline({
Expand All @@ -19,16 +24,13 @@ export function BuildProgressInline({
localBuildProgress: LocalBuildProgress;
}) {
return (
<ProgressTextWrapper
as="div"
style={{ display: "flex", flexDirection: "column", gap: 10, width: 200 }}
>
<ProgressTextWrapper as="div">
<ProgressTrack>
{typeof localBuildProgress.buildProgressPercentage === "number" && (
<ProgressBar style={{ width: `${localBuildProgress.buildProgressPercentage}%` }} />
)}
</ProgressTrack>
<BuildProgressLabel localBuildProgress={localBuildProgress} />
<StyledBuildProgressLabel localBuildProgress={localBuildProgress} />
</ProgressTextWrapper>
);
}
4 changes: 3 additions & 1 deletion src/components/BuildProgressLabel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@ interface BuildProgressLabelProps {
export const BuildProgressLabel = ({
localBuildProgress,
withEmoji = false,

...props
}: BuildProgressLabelProps) => {
const { emoji, renderProgress } = BUILD_STEP_CONFIG[localBuildProgress.currentStep];
const label = renderProgress(localBuildProgress);
return (
<span>
<span {...props}>
{withEmoji && emoji} {label}
</span>
);
Expand Down
7 changes: 2 additions & 5 deletions src/components/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ export const Button = styled(BaseButton)<{
"@container (min-width: 800px)": {
padding: "8px 10px",
},
svg: {
marginRight: 6,
},
},
},
({ link, theme }) =>
Expand All @@ -30,8 +27,8 @@ export const Button = styled(BaseButton)<{
boxShadow: "none",
padding: 2,
fontWeight: "normal",
color: theme.color.defaultText,
opacity: 0.5,
color: theme.base === "light" ? theme.color.darkest : theme.color.lightest,
opacity: 0.6,
transition: "opacity 150ms ease-out",
"&:hover, &:focus": {
opacity: 0.9,
Expand Down
9 changes: 9 additions & 0 deletions src/components/ButtonStack.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { styled } from "@storybook/theming";

export const ButtonStack = styled.div(() => ({
display: "flex",
flexDirection: "column",
gap: 5,
alignItems: "center",
textAlign: "center",
}));
9 changes: 9 additions & 0 deletions src/components/Code.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { Code as SBCode } from "@storybook/components";
import { styled } from "@storybook/theming";

export const Code = styled(SBCode)(({ theme }) => ({
color: theme.base === "light" ? theme.color.darker : theme.color.lighter,
border: `1px solid ${theme.appBorderColor}`,
fontSize: "12px",
padding: "2px 3px",
}));
2 changes: 1 addition & 1 deletion src/components/Eyebrow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { styled } from "@storybook/theming";

export const Eyebrow = styled.div(({ theme }) => ({
background: theme.background.app,
borderBottom: `1px solid ${theme.appBorderColor}`,
padding: "10px 15px",
lineHeight: "20px",
color: theme.color.defaultText,
borderBottom: `1px solid ${theme.appBorderColor}`,
}));
2 changes: 1 addition & 1 deletion src/components/FooterMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export const FooterMenu = () => {
? [
{
id: "visit",
title: "Visit Project on Chromatic",
title: "Visit project on Chromatic",
icon: <ShareAltIcon aria-hidden />,
href: projectId
? `https://www.chromatic.com/builds?appId=${projectId?.split(":")[1]}`
Expand Down
8 changes: 5 additions & 3 deletions src/components/Heading.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { styled } from "@storybook/theming";

export const Heading = styled.h1({
margin: 0,
export const Heading = styled.h1(({ theme }) => ({
marginTop: 0,
marginBottom: 4,
fontSize: "1em",
fontWeight: "bold",
});
color: theme.base === "light" ? theme.color.defaultText : theme.color.lightest,
}));
13 changes: 11 additions & 2 deletions src/components/ModeSelector.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { TooltipNote, WithTooltip } from "@storybook/components";
import { ChevronDownIcon, DiamondIcon } from "@storybook/icons";
import { styled } from "@storybook/theming";
import { styled, useTheme } from "@storybook/theming";
import React from "react";

import { ComparisonResult, TestMode } from "../gql/graphql";
Expand All @@ -17,6 +17,9 @@ const IconWrapper = styled.div(({ theme }) => ({
color: `${theme.color.defaultText}99`,
svg: {
verticalAlign: "top",
path: {
fill: theme.base === "light" ? `${theme.color.defaultText}99` : theme.color.light,
},
},
}));

Expand All @@ -26,6 +29,7 @@ const Label = styled.span(({ theme }) => ({
"@container (min-width: 300px)": {
display: "inline-block",
},
color: theme.base === "light" ? `${theme.color.defaultText}99` : theme.color.light,
}));

type ModeData = Pick<TestMode, "name">;
Expand All @@ -45,10 +49,15 @@ export const ModeSelector = ({
onSelectMode,
selectedMode,
}: ModeSelectorProps) => {
const theme = useTheme();
const aggregate = aggregateResult(modeResults.map(({ result }) => result));
if (!aggregate) return null;

let icon = <DiamondIcon />;
let icon = (
<DiamondIcon
color={theme.base === "light" ? `${theme.color.defaultText}99` : theme.color.light}
/>
);
if (!isAccepted && aggregate !== ComparisonResult.Equal && modeResults.length >= 2) {
icon = <StatusDotWrapper status={aggregate}>{icon}</StatusDotWrapper>;
}
Expand Down
8 changes: 6 additions & 2 deletions src/components/SidebarToggleButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,15 @@ const Button = styled(IconButton)(
!active &&
css({
"&:hover": {
color: theme.color.defaultText,
color: theme.base === "light" ? theme.color.defaultText : theme.color.light,
},
})
);

const Label = styled.span(({ theme }) => ({
color: theme.base === "light" ? theme.color.defaultText : theme.color.light,
}));

interface SidebarToggleButtonProps {
count: number;
onEnable: () => void;
Expand Down Expand Up @@ -55,7 +59,7 @@ export const SidebarToggleButton = React.memo(function SidebarToggleButton({
<Badge status="warning" data-badge={filter}>
{count}
</Badge>
<span>{pluralize("Change", count)}</span>
<Label>{pluralize("Change", count)}</Label>
</Button>
);
});
8 changes: 5 additions & 3 deletions src/components/SidebarTopButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { StatusDotWrapper } from "./StatusDot";
export const TooltipContent = styled.div(({ theme }) => ({
width: 220,
padding: 3,
color: theme.color.defaultText,
color: theme.base === "light" ? theme.color.defaultText : theme.color.light,

"& > div": {
margin: 7,
Expand All @@ -21,7 +21,8 @@ export const TooltipContent = styled.div(({ theme }) => ({
export const ProgressTrack = styled.div(({ theme }) => ({
height: 5,
background: theme.background.hoverable,
borderRadius: 1,
borderRadius: 5,
overflow: "hidden",
}));

export const ProgressBar = styled(ProgressTrack)(({ theme }) => ({
Expand Down Expand Up @@ -72,6 +73,7 @@ export const SidebarIconButton = styled(IconButton)<ComponentProps<typeof IconBu
color: theme.textMutedColor,
marginTop: 0,
zIndex: 1,
marginRight: 4,
})
);

Expand Down Expand Up @@ -107,7 +109,7 @@ export const SidebarTopButton = ({
}
>
<SidebarIconButton aria-label="Stop tests" onClick={() => stopBuild()}>
<StopAltIcon style={{ width: 10 }} />
<StopAltIcon style={{ width: 10, margin: 2 }} />
<ProgressCircle xmlns="http://www.w3.org/2000/svg">
<circle />
</ProgressCircle>
Expand Down
Loading
Loading