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

CSS: Introduction of new CSS variables #39091

Draft
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

louismaximepiton
Copy link
Member

@louismaximepiton louismaximepiton commented Aug 22, 2023

Description

PR can be split by commit if needed

Several implementations

I used many ways to introduce this variables, I don't know if you prefer one or another:

  • One way that we do with our components: declare a CSS variable that defaults to Sass variable and use CSS variable instead (in tables).
  • The other way is using the defaulting behavior of var() function. It can be seen in action in the forms.

Actual changes

Tried to be as concise as possible for each variable introduced. The bundle size slightly increased but if we change every Sass variable into a CSS var, the bundle would explode. For instance, the CSS variables introduced here only cover the changing properties.

Motivation & Context

Use more CSS variables and be more handful for users.

Type of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Refactoring (non-breaking change)
  • Breaking change (fix or feature that would change existing functionality)

Checklist

  • I have read the contributing guidelines
  • My code follows the code style of the project (using npm run lint)
  • My change introduces changes to the documentation
  • I have updated the documentation accordingly
  • I have added tests to cover my changes
  • All new and existing tests passed

Live previews

Related issues

Should close some items in #35319.
Closes #38202.

@AgentSmith0
Copy link

What about also introducing a new CSS variable for link decorations?
This would close #36293.

@louismaximepiton
Copy link
Member Author

louismaximepiton commented Aug 23, 2023

Prefered a separate PR #39098 to unsure that #36293 will be embeded in next release.

@@ -978,7 +980,9 @@ $form-switch-border-radius: $form-switch-width !default;
$form-switch-transition: background-position .15s ease-in-out !default;

$form-switch-focus-color: $input-focus-border-color !default;
$form-switch-focus-bg-image: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'><circle r='3' fill='#{$form-switch-focus-color}'/></svg>") !default;
// fusv-disable
$form-switch-focus-bg-image: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'><circle r='3' fill='#{$form-switch-focus-color}'/></svg>") !default; // Deprecated in 5.3.2
Copy link
Member Author

Choose a reason for hiding this comment

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

Maybe it should be in a different PR to well separate things.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: In Progress
Development

Successfully merging this pull request may close these issues.

It should be possible to customize .form-control:focus (border-color & box-shadow) using CSS variables.
3 participants