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

Feature/config provider #614

Open
wants to merge 8 commits into
base: feature/ant5
Choose a base branch
from
Open

Conversation

interim17
Copy link
Contributor

@interim17 interim17 commented Nov 20, 2024

Time estimate or Size

small

Problem

Advances #601 Closes #603 #604

With antd bumped to v5, ant-vars.less is deprecated and replaced by ConfigProvider.

This PR is for making the switch and capturing the styles that were being handled by less.

It is not a comprehensive fix of styling. Migrating lines from ant-vars.less is not sufficient to make things look right, and completing that process is out of scope.

Solution

  • delete ant.var.less
  • wrap App with ConfigProvider and define SimulariumTheme with global and component tokens to mostly replace the styles applied in ant-vars.less
  • TS base color variables updated to match CSS vars, semantic variable names grouped according to light and dark theme to reflect that same distinction in current CSS although there is only one simulariumTheme used in ConfigProvider

We can decide about having different antd theme algorithms going forward.

I think reasonable approval criteria here are:

  • the ConfigProvider styles is being applied
  • nothing seems garishly out of place in terms of component tokens or file organization.

The point here is to get rid of ant-vars.less, migrate the gist of what styles it was still handling, and establish the ConfigProvider

@interim17 interim17 marked this pull request as ready for review November 21, 2024 00:10
@interim17 interim17 requested a review from a team as a code owner November 21, 2024 00:10
@interim17 interim17 requested review from meganrm and frasercl and removed request for a team November 21, 2024 00:10
@interim17 interim17 marked this pull request as draft November 21, 2024 00:43
@interim17 interim17 marked this pull request as ready for review November 21, 2024 07:04
<RouterSwitch />
</BrowserRouter>
</Layout>
<ConfigProvider theme={simulariumTheme} wave={{ disabled: true }}>
Copy link
Contributor

Choose a reason for hiding this comment

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

what is wave?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

wave controls some animations that are hard to turn off individually

inputPlaceholderColor: WARM_GRAY,
inputBorderColor: WARM_GRAY,
inputBgColor: OFF_WHITE,
inputHoverColor: BABY_PURPLE,
Copy link
Contributor

Choose a reason for hiding this comment

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

Overall this is nice, but some of the repetition here is more detailed than I think is necessary. For instance, I would have a single light AppBgColor, and then assign it below for both colorBgContainer and inputBgColor because you're always going to want those two to change together, instead of having a 1:1 of the token names in here. Similarly I would have a single pageBgColor: WHITE_SIX and use it for the base and the layout. I'm also surprised you have to define the inputHoverColor separately, doesn't it already get the primaryColor?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok I will do some consolidating!

menuDarkSelectedColor: PURE_WHITE,

// Button
buttonPrimaryColor: BABY_PURPLE,
Copy link
Contributor

Choose a reason for hiding this comment

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

again, doesn't this already get set by setting colorPrimary?

tabsInkBarColor: DARK_FOUR,
tabsItemHoverColor: DARK_FOUR,
tabsItemActiveColor: DARK_FOUR,
tabsItemSelectedColor: DARK_FOUR,
Copy link
Contributor

Choose a reason for hiding this comment

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

combine these into one variable tabsInteractionColor or something

sliderRailHoverBg: WARM_GRAY,
sliderTrackBg: WHITE_THREE,
sliderHandleColor: WHITE_THREE,
sliderDotBorderColor: WHITE_THREE,
Copy link
Contributor

Choose a reason for hiding this comment

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

also combine all these into one sliderColor

Copy link
Contributor

@meganrm meganrm left a comment

Choose a reason for hiding this comment

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

looks good, I think you should reduce your variables in your mappings though. The goal is when we change a color, we can change the fewest lines of code possible. I think it's a safe assumption that if things are currently the same color as each other we'll want to keep them the same color. So your theme definitions can have a lot fewer variables than the antd theme, and just reuse them (which you're doing in some places already)

@interim17 interim17 requested a review from meganrm November 28, 2024 00:07
// Layout
layoutSiderBg: DARK,
layoutTriggerBg: DARK,
layoutTriggerColor: BABY_PURPLE,
Copy link
Contributor

Choose a reason for hiding this comment

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

Same thing as before: you positive you need to set this separately when you already have primary color set to baby purple?

const APP_BG_COLOR = OFF_WHITE;
const TABS_INTERACTION_COLOR = DARK_FOUR;
const SLIDER_COLOR = WHITE_THREE;
const CHECKBOX_BG_COLOR = WHITE_SIX;
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: just call this LAYOUT_BG and use it for colorBgBase and colorBgLayout below. or don't have both of those in your light theme and just set them in the actual theme.

const darkTheme = {
// Layout
layoutSiderBg: DARK,
layoutTriggerBg: DARK,
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: combine these into one variable

headerPadding: 0,
siderBg: darkTheme.layoutSiderBg,
triggerBg: darkTheme.layoutTriggerBg,
triggerColor: darkTheme.layoutTriggerColor,
Copy link
Contributor

Choose a reason for hiding this comment

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

if you do need to define this, I would just use colorPrimary instead of making a new variable here, which makes it less clear that this just is the primary color


// Dropdown
dropdownBgColor: CHARCOAL_GRAY,
dropdownTextColor: TRANSPARENT_WHITE,
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: call it FADED_WHITE because transparent sounds like it's going to be invisible

Copy link
Contributor

@meganrm meganrm left a comment

Choose a reason for hiding this comment

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

looks good, I left a few more suggestions but nothing blocking

Copy link
Contributor

@frasercl frasercl left a comment

Choose a reason for hiding this comment

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

Looks good!

const CHECKBOX_BG_COLOR = WHITE_SIX;

// Light Theme Tokens (Global defaults, Modal, Radio)
const lightTheme = {
Copy link
Contributor

Choose a reason for hiding this comment

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

I've gotten confused working with this repo in the past by assuming that "light theme" and "dark theme" were different modes for the whole UI that could be switched between dynamically, rather than design concepts that statically apply to different UI elements (light theme for landing page, dark theme for viewer controls, etc.). Consider adding a few extra words to this comment to help out confused devs like my past self.

Also: even given that these "themes" apply to different UI elements, I'm a bit surprised that more effort isn't taken to unify the shapes of these objects, but that's out of scope for this PR anyways.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hate to say it but I think I have found an even better shiny new way of organizing these variables, so this may code might not last that long. This uses styled-components so is pending some buy-in from reviewer and Megan but I like it and its pointed at this branch. It gets rid of the light and dark theme naming you see here.
#616

I agree that the light/dark theme is confusing, and I am also hoping to get rid of the light-theme.css file in favor of some CSS-in-JS and actually using themes for theming when things are called themes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: 👓 In Review / Blocked
Development

Successfully merging this pull request may close these issues.

3 participants