Skip to content

Conversation

@edwardloveall
Copy link
Contributor

@edwardloveall edwardloveall commented Jan 12, 2025

Supporting #2732

This converts all sass color variables (and a couple other variables) to use native css variables instead.

There's a lot here! If you'd prefer, I can figure out how to break this up into smaller parts; maybe one per var or something. It also doesn't get rid of all sass variables. I could go even farther and do that if we want. Just let me know.

Almost all variables are split into their own commit for easier review.

I also made sure you can still override variables and I'm happy to report that I followed the existing steps and it worked great.

A related consideration is I know administrate is in its 1.0-beta phase. Is this a breaking change worth making this late in the process? It will surely break current sass variable overrides as those no longer exist to be overridden.

Finally, this is also a very large step in the direction away from sass. While there would still be some work to do to fully remove sass, it's a lot more possible if you'd want to do that (in a separate PR).

@nickcharlton
Copy link
Member

Thanks! Yeah, it's a bit big!

It also doesn't get rid of all sass variables. I could go even farther and do that if we want.

…have you seen a path to removing Sass entirely? That'd be fun.

@edwardloveall
Copy link
Contributor Author

Thanks! Yeah, it's a bit big!

Cool, I'll work on breaking it up.

…have you seen a path to removing Sass entirely? That'd be fun.

I think so. I haven't done a full audit or anything but css has come a long way. I think the blocking factor would be which old browsers does administrate need to support.

@edwardloveall edwardloveall force-pushed the el-css-vars branch 2 times, most recently from 543aa98 to e5a78ea Compare February 28, 2025 01:13
@edwardloveall edwardloveall marked this pull request as draft February 28, 2025 01:14
@edwardloveall edwardloveall changed the title Convert stylesheet colors to use css vars Convert stylesheets to use css vars Feb 28, 2025
@edwardloveall edwardloveall changed the title Convert stylesheets to use css vars Convert stylesheets to use css custom properties Feb 28, 2025
@edwardloveall
Copy link
Contributor Author

edwardloveall commented Feb 28, 2025

Alright here's a start with a much smaller scope. I see two ways forward:

  • I ship just this PR and follow up with about 20 (give or take 10) of a similar size converting a couple vars at a time.
  • I keep going on this branch so it's one var per commit until we've done em all, but at least you can review one commit at a time.

Preference? I lean toward the one branch thing since it's less branch juggling for me, but you probably have more to keep track of as maintainer so I think this is up to you.

@nickcharlton
Copy link
Member

One branch is better, I think, especially if it's easier for you.


&:hover {
color: mix($black, $action-color, 25%);
color: var(--action-color-active);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This changed ever so slightly. There were two selectors that used $action-color as their base. This one mixes in 25% $black and &:not(.link):hover in buttons.scss mixes in 20% $black. I went with the 20% in both places so we only had one "it's like $action-color but tinted" variable because button backgrounds are more prominant than text hovers.

@edwardloveall edwardloveall marked this pull request as ready for review March 18, 2025 22:22
Copy link
Contributor Author

Choose a reason for hiding this comment

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

As noted in the commit message, this is quite a bit bigger than it's scss counterpart. I was seeing if I could really remove all sass variables, and I did! Also, in about a year it's probably pretty safe to use color-mix and this gets way smaller (as seen in the comment at the start of the file).

@edwardloveall
Copy link
Contributor Author

edwardloveall commented Mar 18, 2025

Alright, this is ready. I tried to call out a couple places that are a bit messy or surprising. However, this replaces all sass variables with css variables. It's slightly more verbose because sass can still do more than css at this point, but give it about a year and color-mix will be considered baseline widely available and it's probably pretty safe to switch.

(also, updated the PR description)

@nickcharlton
Copy link
Member

Nice, this looks great!

I'm going to sit on it for a little bit, as I work out where it fits inside the release.

What else would we want to do for removing Sass?

@edwardloveall
Copy link
Contributor Author

edwardloveall commented Mar 20, 2025

Of the top of my head, assuming you're threshold for browser support is baseline widely available:

  • Remove nesting (newly available)
  • Remove @mixin/@includes. I think there are two small ones.
  • Rename the files
  • Ensure css @import does the job we need it to do.
  • Update docs

@madhums
Copy link

madhums commented Sep 16, 2025

Is this on track with version 1.0.0 release?

@madhums
Copy link

madhums commented Nov 11, 2025

Can we merge this? :)

@nickcharlton
Copy link
Member

It looks like we've got some conflicts to fix, which @edwardloveall might be best placed to do.

Then as long as we check off the last few things on the list above, we'll be in a good place to merge it.

I'd like to move away from sass so that we can fully embrace css custom
properties and variables.
[color-mix](https://developer.mozilla.org/en-US/docs/Web/CSS/color_value
/color-mix) and [relative
colors](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_colors/Rela
tive_colors) are not yet [baseline widely
available](https://developer.mozilla.org/en-US/docs/Glossary/Baseline/Co
mpatibility) so I'm deciding to inline them.

This inlines just one: a base border color in its hover state.
These are quite a bit more verbose due to the lack of css mixins and
color functions. Once we feel like we can support color-mix, we can
remove all the duplicate css.
sass has a function called [rgb], and so does [css]. If I try to use
the css rgb in a sass context, sass tries to use it first. If I'm using
the [relative color syntax], sass complains that I'm passing too many
arguments. One way around this is to use a css property to define
whatever I need and then use that instead.

[rgb]: https://sass-lang.com/documentation/modules/#rgb
[css]: https://developer.mozilla.org/en-US/docs/Web/CSS/color_value/rgb
[relative color syntax]: https://developer.mozilla.org/en-US/docs/Web/CSS/color_value/rgb#using_relative_colors_with_rgb
We want to make way for a grey between grey-0 and the old grey-1
@edwardloveall
Copy link
Contributor Author

Rebased.

Then as long as we check off the last few things on the list above, we'll be in a good place to merge it.

What do you think about merging this as-is? The list above was for completely removing sass. I could take it on in this PR, but there's a lot here already and all the changes are similar to each other.

@nickcharlton
Copy link
Member

Thank you!

Oh! Right, yes. I misread. Excellent. Yeah, we shouldn't do that in this PR for sure. I'll read over this again and then I think we can merge it.

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.

3 participants