Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@sfc-gh-pchiu
Copy link
Contributor

@sfc-gh-pchiu sfc-gh-pchiu commented Mar 26, 2025

Describe your changes

The secondary background color (theme.colors.secondaryBg, secondaryBackgroundColor ...) has historically been used all over the places as a simple way to differentiate an element from the app's background color.
This however made it difficult to articulate its purpose when defining custom theming options and we want to gradually revamp it into separated use cases more clearly.

This PR moved all hover (highlight) use cases of the theme.colors.secondaryBg to theme.colors.darkenedBgMix15 to make it more consistent with the rest of the theming (Note that they are not the exact same gray but are very similar)

GitHub Issue Link (if applicable)

Testing Plan

  • Manually repro'd each color change in light & dark themes

Contribution License Agreement

By submitting this pull request you agree that all contributions to this project are made under the Apache 2.0 license.

@snyk-io
Copy link
Contributor

snyk-io bot commented Mar 26, 2025

🎉 Snyk checks have passed. No issues have been found so far.

security/snyk check is complete. No issues have been found. (View Details)

license/snyk check is complete. No issues have been found. (View Details)

@github-actions
Copy link
Contributor

github-actions bot commented Mar 26, 2025

✅ PR preview is ready!

Name Link
📦 Wheel file https://core-previews.s3-us-west-2.amazonaws.com/pr-10930/streamlit-1.44.0-py3-none-any.whl
🕹️ Preview app pr-10930.streamlit.app (☁️ Deploy here if not accessible)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I did not change bgRowHovered on L122 since it's mixing the bg and secondaryBg colors dynamically. But we may want to revisit if this is the behavior we want.

@sfc-gh-pchiu sfc-gh-pchiu added security-assessment-completed Security assessment has been completed for PR change:feature PR contains new feature or enhancement implementation impact:users PR changes affect end users labels Mar 26, 2025
@sfc-gh-pchiu sfc-gh-pchiu changed the title move to dark mix for hovered, highlighted color [theming] Use dark mix for hovered color instead of secondary background color Mar 26, 2025
@sfc-gh-pchiu sfc-gh-pchiu changed the title [theming] Use dark mix for hovered color instead of secondary background color [theming] Use dark mix for hovered color instead of theme.colors.secondaryBg Mar 26, 2025
@sfc-gh-pchiu sfc-gh-pchiu marked this pull request as ready for review March 26, 2025 23:49
// Whatever color we use here as the hover state, we want to transparentize it
// to its full extend, so you can see the underlying color of the menu.
backgroundColor: transparentize(theme.colors.secondaryBg, 1),
backgroundColor: transparentize(theme.colors.darkenedBgMix15, 1),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

the color doesn't matter here with full transparency

Copy link
Collaborator

Choose a reason for hiding this comment

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

Can't we simiplfy this here and just use: `backgroundColor: "transparent"?

@lukasmasuch
Copy link
Collaborator

lukasmasuch commented Mar 27, 2025

Two other hover-related places that would also be good to update:

export const ThemedStyledDropdownListItem = styled(StyledDropdownListItem, {
  shouldForwardProp: isPropValid,
})(({ theme, $isHighlighted }) => {
  return {
    display: "flex",
    alignItems: "center",
    paddingTop: theme.spacing.none,
    paddingBottom: theme.spacing.none,
    paddingLeft: theme.spacing.lg,
    paddingRight: theme.spacing.lg,
    background: $isHighlighted ? theme.colors.darkenedBgMix15 : undefined,

    // Override the default itemSize set on the component's JSX
    // on mobile, so we can make list items taller and scrollable
    [`@media (max-width: ${theme.breakpoints.md})`]: {
      minHeight: theme.sizes.dropdownItemHeight,
      height: "auto !important",
    },
    "&:hover, &:active, &:focus-visible": {
      background: theme.colors.darkenedBgMix15,
    },
  }
})

And maybe also update this one to use darkenedBgMix15 instead of darkenedBgMix25:

@sfc-gh-pchiu sfc-gh-pchiu force-pushed the feat/at-revamp-hover-color branch from 837366a to e5b9ef7 Compare March 27, 2025 18:42
Copy link
Collaborator

@lukasmasuch lukasmasuch left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@sfc-gh-pchiu sfc-gh-pchiu merged commit 9757386 into develop Mar 27, 2025
33 checks passed
@sfc-gh-pchiu sfc-gh-pchiu deleted the feat/at-revamp-hover-color branch March 27, 2025 19:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

change:feature PR contains new feature or enhancement implementation impact:users PR changes affect end users security-assessment-completed Security assessment has been completed for PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants