-
Notifications
You must be signed in to change notification settings - Fork 12
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
Theme refactor #358
Theme refactor #358
Conversation
@@ -3,7 +3,7 @@ import styled from "styled-components"; | |||
export const Background = styled.div` | |||
overflow: hidden; | |||
position: fixed; | |||
background-color: ${(props) => props.theme.dark[0]}; | |||
background-color: ${(p) => p.theme.canvas.base}; |
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 keep this named props
just for readability sake? Not that big of a deal but that's what came to mind when I saw this.
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.
Yeah it's a good point! I noticed the majority of styled components used p
instead of props
so changed it for consistencies sake but I would also vouch for props
or even destructuring the object ${({ theme }) => theme.canvas.base};
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 weighing in on this, I think all of the above seem totally fine to me!
I'm surprised at how much time I've saved by just writing p => p.theme
instead of destructuring, it all adds up I guess 😅
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.
LGTM
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.
Thank you for doing this Kenan 🎉 Looks very good
src/panel/cosmos.decorator.tsx
Outdated
return ( | ||
<ThemeProvider {...props} theme={theme === "dark" ? darkTheme : lightTheme}> | ||
<ThemeToggle | ||
onClick={() => setTheme(theme === "dark" ? "light" : "dark")} |
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.
Nice, this is only for cosmos, isn't it? In the extension we are using chrome themes to detect if it's dark or white.
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.
Yeah, exactly!
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.
Potentially worth extracting this to a callback for some minor perf improvements
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.
@wgolledge thanks for the suggestion! Updated here: 54582a5
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 stuff! 💯
src/panel/cosmos.decorator.tsx
Outdated
return ( | ||
<ThemeProvider {...props} theme={theme === "dark" ? darkTheme : lightTheme}> | ||
<ThemeToggle | ||
onClick={() => setTheme(theme === "dark" ? "light" : "dark")} |
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.
Potentially worth extracting this to a callback for some minor perf improvements
@@ -3,7 +3,7 @@ import styled from "styled-components"; | |||
export const Background = styled.div` | |||
overflow: hidden; | |||
position: fixed; | |||
background-color: ${(props) => props.theme.dark[0]}; | |||
background-color: ${(p) => p.theme.canvas.base}; |
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 weighing in on this, I think all of the above seem totally fine to me!
I'm surprised at how much time I've saved by just writing p => p.theme
instead of destructuring, it all adds up I guess 😅
); | ||
}; | ||
export const App: FC = () => ( | ||
<ThemeProvider theme={isLightMode() ? lightTheme : darkTheme}> |
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.
🔥
@@ -1,344 +1,272 @@ | |||
import { lighten, darken, mix, tint, shade } from "polished"; | |||
import { tint, shade, mix } from "polished"; |
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.
This whole theme breakdown seems so much more readable/semantic to me!
"syntax": Object { | ||
"atom": "#e8e8e9", | ||
"attrName": "#33b3ff", | ||
"base": "#33b3ff", | ||
"boolean": "#9291db", | ||
"builtin": "#9291db", | ||
"className": "#44b9cb", | ||
"comment": "#6cc7a4", | ||
"constant": "#33b3ff", | ||
"description": "#a4a5a8", | ||
"enum": "#6cc7a4", | ||
"function": "#e8e8e9", | ||
"input": "#9291db", | ||
"interface": "#9291db", | ||
"invalid": "#F65151", | ||
"keyword": "#9291db", | ||
"meta": "#F65151", | ||
"null": "#a4a5a8", | ||
"number": "#6cc7a4", | ||
"operator": "#e8e8e9", | ||
"property": "#33b3ff", | ||
"punctuation": "#e8e8e9", | ||
"scalar": "#ed9b3d", | ||
"string": "#ed9b3d", | ||
"type": "#33b3ff", | ||
"union": "#44b9cb", | ||
"variable": "#33b3ff", | ||
}, |
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 like where you're going with this 👍
|
||
&:hover { | ||
color: ${(p) => (p.active ? p.theme.accent["+3"] : p.theme.light["-9"])}; | ||
color: ${(p) => | ||
p.active ? p.theme.primary.hover : p.theme.textDimmed.hover}; |
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.
Loving the colocation of color and it's variants 🔥
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 😍
Implementation looks spot on (imho) and the end result is 🔥 Accent color is spot on and the color contrast is a massive improvement!
Some thoughts:
- Introduction of hue to the dark theme is a welcome change - I'm tempted to think we could keep the hue but make the canvas slightly darker so the increase the contrast with the primary color (massively subjective - I don't have a suggested color and you've likely experimented with this already so no need to make a change)
- If you are interested, would be dope to add a global theme toggle to fixtures in a follow up PR see here
From the comments, it sounds like everyone is super stoked with these changes! Lets get them merged and HMU for the release process.
@andyrichardson thanks for the comments! Will follow up with a PR to add the global theme toggle, that seems like a nicer solution 😁 |
This PR refactors the existing way of theming the dev tools.
Changes include:
lightTheme
anddarkTheme
theme.text.base
andtheme.textDimmed.base
.base
property, as well any other relevant shades, tints and modifiers. For example, theprimary
property:primary: { base: colors.purple, hover: tint(0.1, colors.purple), ...others }
see theme.ts for full exampleAll feedback on the approach and usage of colour welcome 🙏
Dark mode
Light mode