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

Theme refactor #358

Merged
merged 7 commits into from
May 10, 2021
Merged

Theme refactor #358

merged 7 commits into from
May 10, 2021

Conversation

KenanYusuf
Copy link
Contributor

@KenanYusuf KenanYusuf commented May 6, 2021

This PR refactors the existing way of theming the dev tools.

Changes include:

  • Splitting the single theme into a lightTheme and darkTheme
  • Updated colour palette to one from Figma file
  • Using context-specific naming for each theme property
    • The theory behind this is that it will encourage reuse of colours for similar bits of UI. For example, only two shades of grey will be used for text via theme.text.base and theme.textDimmed.base.
    • Each colour property has a base property, as well any other relevant shades, tints and modifiers. For example, the primary property: primary: { base: colors.purple, hover: tint(0.1, colors.purple), ...others } see theme.ts for full example
  • Updates syntax highlighting to have a unique theme for both dark & light modes
  • Added theme type support to styled components
    • Screenshot 2021-05-06 at 11 09 11
  • Added ability to toggle theme in cosmos to help developing the tools with both themes in mind
    • Screenshot 2021-05-06 at 11 09 45

All feedback on the approach and usage of colour welcome 🙏

Dark mode

Before After
dark-explore-before dark-explore-after
dark-events-before dark-events-after
dark-request-before dark-request-after

Light mode

Before After
light-explore-before light-explore-after
light-events-before light-events-after
light-request-before light-request-after

@KenanYusuf KenanYusuf marked this pull request as ready for review May 6, 2021 10:08
@@ -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};
Copy link
Contributor

@jmfulgham jmfulgham May 6, 2021

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.

Copy link
Contributor Author

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};

Copy link
Contributor

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 😅

Copy link
Contributor

@jmfulgham jmfulgham left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@ValGeorgiev ValGeorgiev left a 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

return (
<ThemeProvider {...props} theme={theme === "dark" ? darkTheme : lightTheme}>
<ThemeToggle
onClick={() => setTheme(theme === "dark" ? "light" : "dark")}
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, exactly!

Copy link
Contributor

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

Copy link
Contributor Author

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

Copy link
Contributor

@wgolledge wgolledge left a comment

Choose a reason for hiding this comment

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

Awesome stuff! 💯

return (
<ThemeProvider {...props} theme={theme === "dark" ? darkTheme : lightTheme}>
<ThemeToggle
onClick={() => setTheme(theme === "dark" ? "light" : "dark")}
Copy link
Contributor

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};
Copy link
Contributor

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}>
Copy link
Contributor

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";
Copy link
Contributor

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!

Comment on lines +35 to 62
"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",
},
Copy link
Collaborator

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};
Copy link
Collaborator

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 🔥

Copy link
Collaborator

@andyrichardson andyrichardson left a 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.

@KenanYusuf
Copy link
Contributor Author

@andyrichardson thanks for the comments! Will follow up with a PR to add the global theme toggle, that seems like a nicer solution 😁

@KenanYusuf KenanYusuf merged commit 5151119 into master May 10, 2021
@KenanYusuf KenanYusuf deleted the feature/theme-refactor branch May 10, 2021 09:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants