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

Conver sass math to css calc #25

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

JonatasAmaral
Copy link

What

Convert all sass math to css calc()

Why

It allow us to pass css custom properties ( --variable) to all size related variables

$thumb-height: var(--thumb-size);
$track-shadow-size: var(--shadow-size);

what facilitates "state based" and responsive styling override

...

input[type="range"] {
    --thumb-size: 20px;
    --shadow-size: 3px;

    &:hover {
        --shadow-size: 6px;
    }

    @media(min-width: 470px) {
        --thumb-size: 26px;
    }
}

That's why i think it worth bring it up, at least for a discussion.

Caviats

This approach may get errors with "unit less" zeros involved in calculations

$track-border-width: 0; // error "silently" breaks the range input

So it is mandatory to set some unit an zeroing a variable out

$track-border-width: 0px; // works 

@andrewbaxter
Copy link

Another reason is so you can mix units (like em and px).

@JonatasAmaral
Copy link
Author

Yeah, that's a nice feat too

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