Skip to content

Commit

Permalink
[ui] Themes (#18442)
Browse files Browse the repository at this point in the history
## Summary & Motivation

Introduce a system for theming the Dagster UI. All direct references to
color values are replaced by a set of functions that match semantic
color names to theme-based palette values.

The theme value is exposed via a User Setting.

Discussion here: #18439

## How I Tested These Changes

TS, lint, jest. Find all existing references to `LegacyColors`, hex
values, rgb/rgba values and replace them with color functions.

Navigate throughout the app in legacy, light, and dark modes. Verify
that colors look appropriate.

---------

Co-authored-by: Josh Braun <[email protected]>
  • Loading branch information
hellendag and braunjj authored Dec 3, 2023
1 parent b5bac82 commit e5bfb14
Show file tree
Hide file tree
Showing 307 changed files with 4,217 additions and 1,848 deletions.
10 changes: 6 additions & 4 deletions js_modules/dagster-ui/packages/app-oss/src/NUX/CommunityNux.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@ import {
Box,
Button,
Checkbox,
Colors,
Dialog,
ExternalAnchorButton,
Heading,
Icon,
Spinner,
TextInput,
colorAccentRed,
colorTextLight,
colorTextRed,
} from '@dagster-io/ui-components';
import {useStateWithStorage} from '@dagster-io/ui-core/hooks/useStateWithStorage';
import React from 'react';
Expand Down Expand Up @@ -101,7 +103,7 @@ const Form = ({dismiss, submit}: FormProps) => {
>
<Box flex={{direction: 'column', gap: 8, alignItems: 'start', justifyContent: 'start'}}>
<Heading>Join the Dagster community</Heading>
<Body style={{color: Colors.Gray700, marginBottom: '4px'}}>
<Body style={{color: colorTextLight(), marginBottom: '4px'}}>
Connect with thousands of other data practitioners building with Dagster. Share
knowledge, get help, and contribute to the open-source project.
</Body>
Expand All @@ -126,11 +128,11 @@ const Form = ({dismiss, submit}: FormProps) => {
}}
onBlur={() => setBlurred(true)}
placeholder="[email protected]"
strokeColor={!emailChanged || validEmail ? undefined : Colors.Red500}
strokeColor={!emailChanged || validEmail ? undefined : colorAccentRed()}
style={{width: '100%'}}
/>
{emailChanged && blurred && !validEmail ? (
<div style={{paddingBottom: '12px', color: Colors.Red500, fontSize: '12px'}}>
<div style={{paddingBottom: '12px', color: colorTextRed(), fontSize: '12px'}}>
Add your email to get updates from Dagster.
</div>
) : null}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const config = {
storyStoreV7: true,
},
docs: {
autodocs: true,
autodocs: false,
},
env: (config) => ({
...config,
Expand Down
18 changes: 15 additions & 3 deletions js_modules/dagster-ui/packages/ui-components/.storybook/preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {
GlobalSuggestStyle,
GlobalToasterStyle,
GlobalTooltipStyle,
Colors,
} from '../src';

import {MemoryRouter} from 'react-router-dom';
Expand All @@ -16,22 +15,29 @@ import * as React from 'react';
import {createGlobalStyle} from 'styled-components/macro';

import './blueprint.css';
import {
colorBackgroundDefault,
colorLinkDefault,
colorTextDefault,
colorTextLight,
} from '../src/theme/color';

const GlobalStyle = createGlobalStyle`
* {
box-sizing: border-box;
}
html, body {
color: ${Colors.Gray800};
background-color: ${colorBackgroundDefault()};
color: ${colorTextDefault()};
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
a,
a:hover,
a:active {
color: ${Colors.Link};
color: ${colorLinkDefault()};
}
body {
Expand All @@ -40,6 +46,8 @@ const GlobalStyle = createGlobalStyle`
}
body, input, select, textarea {
background-color: ${colorBackgroundDefault()};
color: ${colorTextDefault()};
font-family: ${FontFamily.default};
}
Expand All @@ -51,6 +59,10 @@ const GlobalStyle = createGlobalStyle`
font-family: ${FontFamily.monospace};
font-size: 16px;
}
input::placeholder {
color: ${colorTextLight()};
}
`;

// Global decorator to apply the styles to all stories
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,22 @@
import * as React from 'react';
import styled from 'styled-components';

import {
colorAccentBlue,
colorAccentGreen,
colorAccentRed,
colorAccentYellow,
colorBackgroundBlue,
colorBackgroundGreen,
colorBackgroundRed,
colorBackgroundYellow,
colorTextBlue,
colorTextGreen,
colorTextRed,
colorTextYellow,
} from '../theme/color';

import {Box} from './Box';
import {Colors} from './Colors';
import {Group} from './Group';
import {IconName, Icon} from './Icon';

Expand All @@ -23,36 +37,36 @@ export const Alert = (props: Props) => {
switch (intent) {
case 'warning':
return {
backgroundColor: Colors.Yellow50,
borderColor: Colors.Yellow500,
backgroundColor: colorBackgroundYellow(),
borderColor: colorAccentYellow(),
icon: 'warning',
iconColor: Colors.Yellow500,
textColor: Colors.Yellow700,
iconColor: colorAccentYellow(),
textColor: colorTextYellow(),
};
case 'error':
return {
backgroundColor: Colors.Red50,
borderColor: Colors.Red500,
backgroundColor: colorBackgroundRed(),
borderColor: colorAccentRed(),
icon: 'error',
iconColor: Colors.Red500,
textColor: Colors.Red700,
iconColor: colorAccentRed(),
textColor: colorTextRed(),
};
case 'success':
return {
backgroundColor: Colors.Green50,
borderColor: Colors.Green500,
backgroundColor: colorBackgroundGreen(),
borderColor: colorAccentGreen(),
icon: 'done',
iconColor: Colors.Green500,
textColor: Colors.Green700,
iconColor: colorAccentGreen(),
textColor: colorTextGreen(),
};
case 'info':
default:
return {
backgroundColor: Colors.Blue50,
borderColor: Colors.Blue500,
backgroundColor: colorBackgroundBlue(),
borderColor: colorAccentBlue(),
icon: 'info',
iconColor: Colors.Blue500,
textColor: Colors.Blue700,
iconColor: colorAccentBlue(),
textColor: colorTextBlue(),
};
}
}, [intent]);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,25 @@
import * as React from 'react';

import {Colors} from './Colors';
import {
colorAccentGray,
colorAccentReversed,
colorBackgroundDefault,
colorBackgroundDefaultHover,
colorTextDefault,
} from '../theme/color';

import {StyledButton, StyledButtonText} from './StyledButton';

interface CommonButtonProps {
icon?: React.ReactNode;
label?: React.ReactNode;
loading?: boolean;
rightIcon?: React.ReactNode;
iconColor?: string;
fillColor?: string;
fillColorHover?: string;
strokeColor?: string;
strokeColorHover?: string;
textColor?: string;
}

Expand All @@ -18,14 +28,17 @@ interface BaseButtonProps extends CommonButtonProps, React.ComponentPropsWithRef
export const BaseButton = React.forwardRef(
(props: BaseButtonProps, ref: React.ForwardedRef<HTMLButtonElement>) => {
const {
fillColor = Colors.White,
fillColor = colorBackgroundDefault(),
fillColorHover = colorBackgroundDefaultHover(),
disabled,
icon,
label,
loading,
rightIcon,
textColor = Colors.Dark,
strokeColor = Colors.Gray300,
iconColor = colorAccentReversed(),
textColor = colorTextDefault(),
strokeColor = colorAccentGray(),
strokeColorHover = colorAccentGray(),
...rest
} = props;

Expand All @@ -34,8 +47,11 @@ export const BaseButton = React.forwardRef(
{...rest}
as="button"
disabled={!!(disabled || loading)}
$iconColor={iconColor}
$fillColor={fillColor}
$fillColorHover={fillColorHover}
$strokeColor={strokeColor}
$strokeColorHover={strokeColorHover}
$textColor={textColor}
ref={ref}
>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import * as React from 'react';
import styled from 'styled-components';

import {Colors} from './Colors';
import {colorBackgroundDefault, colorTextDefault} from '../theme/color';

import {IconWrapper} from './Icon';
import {SpinnerWrapper} from './Spinner';

Expand Down Expand Up @@ -30,8 +31,8 @@ const BaseTagTooltipStyle: React.CSSProperties = {

export const BaseTag = (props: Props) => {
const {
fillColor = Colors.Gray10,
textColor = Colors.Gray900,
fillColor = colorBackgroundDefault(),
textColor = colorTextDefault(),
icon,
interactive = false,
rightIcon,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import styled, {css} from 'styled-components';

import {colorKeylineDefault} from '../theme/color';
import {assertUnreachable} from '../util/assertUnreachable';

import {Colors} from './Colors';
import {BorderSetting, BorderSide, DirectionalSpacing, FlexProperties} from './types';

interface Props {
Expand Down Expand Up @@ -50,8 +50,8 @@ const directionalSpacingToCSS = (property: string, spacing: DirectionalSpacing)

const borderSettingToCSS = (border: BorderSide | BorderSetting) => {
const borderValue =
typeof border === 'string' ? {side: border, width: 1, color: Colors.KeylineGray} : border;
const {side, width = 1, color = Colors.KeylineGray} = borderValue;
typeof border === 'string' ? {side: border, width: 1, color: colorKeylineDefault()} : border;
const {side, width = 1, color = colorKeylineDefault()} = borderValue;

switch (side) {
case 'all':
Expand Down
Loading

2 comments on commit e5bfb14

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deploy preview for dagit-storybook ready!

✅ Preview
https://dagit-storybook-bo2ofxvsr-elementl.vercel.app

Built with commit e5bfb14.
This pull request is being automatically deployed with vercel-action

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deploy preview for dagit-core-storybook ready!

✅ Preview
https://dagit-core-storybook-perp684r2-elementl.vercel.app

Built with commit e5bfb14.
This pull request is being automatically deployed with vercel-action

Please sign in to comment.