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

Theming: Add theme variable to set the preview background color #24575

Merged
merged 3 commits into from
Oct 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions code/lib/theming/src/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export const background = {
app: '#F6F9FC',
bar: color.lightest,
content: color.lightest,
preview: color.lightest,
gridCellSize: 10,
hoverable: transparentize(0.9, color.secondary), // hover state for items in a list

Expand Down
2 changes: 2 additions & 0 deletions code/lib/theming/src/convert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ export const convert = (inherit: ThemeVars = themes[getPreferredColorScheme()]):
colorSecondary,
appBg,
appContentBg,
appPreviewBg,
appBorderColor,
appBorderRadius,
fontBase,
Expand Down Expand Up @@ -116,6 +117,7 @@ export const convert = (inherit: ThemeVars = themes[getPreferredColorScheme()]):
app: appBg,
bar: barBg,
content: appContentBg,
preview: appPreviewBg,
gridCellSize: gridCellSize || background.gridCellSize,
hoverable: background.hoverable,
positive: background.positive,
Expand Down
1 change: 1 addition & 0 deletions code/lib/theming/src/themes/dark.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const theme: ThemeVars = {
// UI
appBg: '#222425',
appContentBg: '#1B1C1D',
appPreviewBg: color.lightest,
appBorderColor: 'rgba(255,255,255,.1)',
appBorderRadius: 4,

Expand Down
1 change: 1 addition & 0 deletions code/lib/theming/src/themes/light.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const theme: ThemeVars = {
// UI
appBg: background.app,
appContentBg: color.lightest,
appPreviewBg: color.lightest,
appBorderColor: color.border,
appBorderRadius: 4,

Expand Down
1 change: 1 addition & 0 deletions code/lib/theming/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export interface ThemeVarsColors {
// UI
appBg: string;
appContentBg: string;
appPreviewBg: string;
appBorderColor: string;
appBorderRadius: number;

Expand Down
6 changes: 3 additions & 3 deletions code/ui/manager/src/components/preview/iframe.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import React from 'react';
import { styled } from '@storybook/theming';
import { Zoom } from '@storybook/components';

const StyledIframe = styled.iframe({
backgroundColor: 'white',
const StyledIframe = styled.iframe(({ theme }) => ({
backgroundColor: theme.background.preview,
position: 'absolute',
display: 'block',
boxSizing: 'content-box',
Expand All @@ -13,7 +13,7 @@ const StyledIframe = styled.iframe({
border: '0 none',
transition: 'background-position 0s, visibility 0s',
backgroundPosition: '-1px -1px, -1px -1px, -1px -1px, -1px -1px',
});
}));

export interface IFrameProps {
id: string;
Expand Down
3 changes: 1 addition & 2 deletions code/ui/manager/src/components/preview/utils/components.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ export const IframeWrapper = styled.div(({ theme }) => ({
right: 0,
width: '100%',
height: '100%',
background: theme.background.content,
}));

export const LoaderWrapper = styled.div(({ theme }) => ({
Expand All @@ -44,6 +43,6 @@ export const LoaderWrapper = styled.div(({ theme }) => ({
left: 0,
bottom: 0,
right: 0,
background: theme.background.content,
background: theme.background.preview,
zIndex: 1,
}));
1 change: 1 addition & 0 deletions docs/snippets/common/your-theme.js.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export default create({
// UI
appBg: '#ffffff',
appContentBg: '#ffffff',
appPreviewBg: '#ffffff',
appBorderColor: '#585C6D',
appBorderRadius: 4,

Expand Down