-
Notifications
You must be signed in to change notification settings - Fork 130
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
Experimental style changes #110
Conversation
The reason we went with I like the change of style units. But maybe we should keep things like |
How is this used? I did not see it.
I can make a PR for this 👍 |
@MinusGix Any use case you can think of for unset? |
Do you like |
@jrmoulton How do you like |
I like it but I don't like that you have to import the extension trait every time you want to use it. It's also looks more noisy than using functions the _px functions but when I look at it with syntax highlighting it actually looks nice. width(100.pct());
size(100.px(), 50.pct()) Even though I've never needed it, it's nice that it's easier to mix and match units. Hmmm. I think I'm in favor of it but the issue of needing to import the extension trait seems annoying. Maybe worth it though |
Closing, style unit changes are in #112 |
I explored the code base and tried some things
Style simplification
Style
(previouslyComputedStyle
) holds the concrete values (noStyleValue
), andStyleFn
s are just closures which modify the style.So starting with
Style::default()
all boxedStyleFn
s are used in the following order, this is mostly as before:This could also have been done with
Option
instead ofStyleValues
, but I originally planned an API like.style([padding(10),flex(), ...])
, where each is a style modifying closure. Could also still change it to be like this.I must admit I do not really know whether this is better, we loose the ability to unset styles, but everything seems to still work as before. Also it is a bit simpler, and fewer lines of code.
Style Units
I created newtype wrapper
Px
for pixel values andPct
for percent values.Px
is chosen by default with multipleFrom<x>
implementations. Style functions which can work with both take an enum (impl Into<PxOrPct>
).Instead of style functions like
width_px
andwidth_pct
there is now onlywidth
Short style functions
I added some shorter aliases like
p
forpadding
,mx
formargin_horiz
, and so on. Inspired by tailwind.Multiple box shadows
Just as in CSS (still missing inset styles). This required a different style API.
I realize these are more controversial changes, no pressure to merge as is. If you want some of these changes I can rollback the rest, or create individual PRs. Also not all comments and examples are updated, I wanted to open the PR first.
I plan to have a look at the animation system, and change some things. At least I have fun coding this, thanks for the project.