-
Notifications
You must be signed in to change notification settings - Fork 7
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
feat: Dark Mode #718
feat: Dark Mode #718
Conversation
@@ -108,3 +108,12 @@ storybook-static | |||
|
|||
# OS Files | |||
.DS_Store | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Turns out I'm on the latest version of yarn
which hasn't been used by this project yet so I was getting tons of added files from yarn
's cache. This ensures the latest yarn
doesn't cause git
annoyances in the future 😄
@@ -39,12 +38,13 @@ export const StyledCallout = styled(Alert, { | |||
// any buttom margin | |||
const titleBottomMargin = props.collapsed ? "margin-bottom: 0;" : ""; | |||
|
|||
// TODO: Theme shouldn't be saying it might be null |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Type issue, needs to be addressed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So this TODO is a little right and a little wrong, looking at it again.
The props
here are listed as CalloutProps
, which extends from the CommonThemeProps
where theme
is undefined.
At runtime, theme
would never be undefined, so that's why I dropped the initial TODO here.
I'm sure we could do a bit of type juggling we could do to make it defined, but I think we'd want to do that in other components that are extending CommonThemeProps
directly.
Given this PR is more targeted at making dark mode work, I'm inclined to live with the untrue ?
on theme
for now.
packages/components/src/core/LoadingIndicator/index.stories.tsx
Outdated
Show resolved
Hide resolved
@@ -75,8 +75,64 @@ const defaultThemeColors = { | |||
}, | |||
}; | |||
|
|||
export const defaultAppTheme: AppTheme = { | |||
colors: defaultThemeColors, | |||
const darkThemeColors = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gross ChatGPT generated ones, will be replaced.
@@ -94,7 +94,7 @@ export const Title - styled(Typography)` | |||
```ts | |||
import { css, SerializedStyles } from "@emotion/react"; | |||
import { styled } from '@mui/material/styles'; | |||
import { getColors, getCorners } from "@czi-sds/components"; | |||
import { getColors, getSpaces } from "@czi-sds/components"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just fixing a typo in the README
/** | ||
* Default theme, uses light mode with no option to change it. | ||
* | ||
* @deprecated Use the `theme` to get a flexible light/dark mode theme function |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we don't deprecate it, some folks may never be interested in light/dark so why complicate their lives?
Alternatively, deprecate but give the new one a default theme of "light". 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great question! Yeah I also feel that maybe don't deprecate it and just default to "light" sounds less intrusive 😄 👍
- Updated DialogTitle to use palette.text colors - Updated Tabs to use palette.text colors
900?: string; | ||
800?: string; | ||
700?: string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we don't want all Color
types to be able to climb this high we could make an ExtendedColor
interface
that extends Color
and adds these three. Then it can be applied only where these values would be desired.
color: black; | ||
${(props) => { | ||
return ` | ||
color: ${props.theme.palette.text.primary}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just thinking about this a bit... Typography
should be theme-aware for the text.primary
color. I think we might be able to get away with removing color
entirely!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for paving the way for our components to be runtime theme aware 💡 !!
Yeah using semantic text.primary
sounds like best practice to me too 👍 !
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool, going to remove the color entirely for Title
then. Keeping for Subtitle
since that won't be a secondary color by default!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks SUPER good! Thanks so much for going through the code to find places where we can start adopting runtime theme swapping!
These examples will definitely help us overhaul the rest of the stories and components in Q2 👏
Really appreciate it!
Just some minor questions/feedbacks, otherwise LGTM 🚀 !!
@@ -51,7 +51,9 @@ export const StyledTabs = styled(TempTabs, { | |||
return ` | |||
margin-top: ${isLarge ? spaces?.l : spaces?.m}px; | |||
margin-bottom: ${isLarge ? spaces?.xl : spaces?.m}px; | |||
border-bottom: ${underlined ? `2px solid ${colors?.gray[200]};` : "none"}; | |||
border-bottom: ${ | |||
underlined ? `2px solid ${props.theme.palette.divider};` : "none" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
super nice!
colors: lightThemeColors, | ||
...sharedAppTheme, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we swap the order here, so we ensure colors: lightThemeColors,
will overwrite sharedAppTheme.colors
if sharedAppTheme
happens to have colors
at runtime 😄 ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point! Even though I've said sharedAppTheme
omits colors
, that doesn't mean it'll actually happen.
The joys of TypeScript lol
Swapping!
/** | ||
* Default theme, uses light mode with no option to change it. | ||
* | ||
* @deprecated Use the `theme` to get a flexible light/dark mode theme function |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great question! Yeah I also feel that maybe don't deprecate it and just default to "light" sounds less intrusive 😄 👍
* @deprecated Use the `theme` to get a flexible light/dark mode theme function | ||
*/ | ||
export const defaultTheme = createThemeAdaptor( | ||
makeThemeOptions(chooseTheme("light"), "light") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
feels like potentially defaultTheme()
could call theme()
under the hood?
Something like:
export const defaultTheme = theme("light");
What do you think 🙆♂️ ?
divider: appTheme.colors.gray[200], | ||
background: { | ||
default: common.white, | ||
secondary: appTheme.colors.gray[100], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this was added by @hthomas-czi during the hackathon, it's throwing a type error because we don't have it on TypeBackground
.
@hthomas-czi Is a secondary background still something that's needed? There's paper
that we could be using that already exists, so we'll have three background colors if we do use secondary
.
If it's needed, it's easy to add to the type. I just want to check 😁
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this was added by @hthomas-czi during the hackathon, it's throwing a type error because we don't have it on
TypeBackground
.@hthomas-czi Is a secondary background still something that's needed? There's
paper
that we could be using that already exists, so we'll have three background colors if we do usesecondary
.If it's needed, it's easy to add to the type. I just want to check 😁
Hey @lanesawyer! Sorry for the delay responding. For some horrible reason, I don't receive notifications for GitHub mentions.
I'll leave it up to you, but Paper
doesn't fully address the reason I added a secondary background. They're equivalent in dark mode. But in light mode, Paper
is always white, while background[secondary]
is light gray in light mode. This maintains a consistent appearance between modes.
Thanks!
@tihuan Feedback addressed! I have an outstanding question for @hthomas-czi, but overall this PR should be pretty close to ready. Also one more question, should we add details about the theme to the README in this PR, or update the README once the colors and polish are completed so people won't start thinking it's ready? Finally, I guess my PR doesn't trigger the workflow. Probably want to approve those to run so we can check that I didn't miss anything. Running the linter locally, I got a bunch of errors saying |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome! Thanks for addressing the feedback quickly, Lane 🫡 LGTM!
CC: @masoudmanson in case I missed something 😎🙏
Thanks again!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow, @lanesawyer, this is truly fantastic!
A massive thank you for tackling the heavy lifting and crafting such a robust PR for us. Really appreciate it.
The PR looks great to me. I'll be continuing to update components and collaborate with the design team to fine-tune the colors and appearance of the components.
This is so exciting! 🥳
Finally, I feel right at home as a programmer. We got a dark theme
😱😍
@lanesawyer, Thanks a ton for your work on the dark theme! Since a lot has changed since your PR, and there were too many conflicts, I created a new PR to pick up where you left off. You can check it out here: Dark Mode Implementation Really appreciate your contributions! 🎉🥳 |
Woooo love to see it! Thanks for running with what I had and finishing it all up. That final PR is a big one! Excited to start playing with the official dark mode once it's shipped 😄 |
Dark Mode
Structural Element (Base, Gene, DNA, Chromosome or Cell)
Github issue: #XXXX
Copy isuue descirption here
Remaining Work
Checklist
defaultTheme.ts
used wherever possible