shospodarets / css-vars Goto Github PK
View Code? Open in Web Editor NEWSass mixin to use CSS Custom Properties with Sass
Home Page: https://www.npmjs.com/package/css-vars
License: MIT License
Sass mixin to use CSS Custom Properties with Sass
Home Page: https://www.npmjs.com/package/css-vars
License: MIT License
Been dealing with SASS and it's lack of support for :root
and came across this awesome library; So far I'm really digging it, but ran into a few other intrinsic limitations with the .sass
syntax...
Namely: sass/sass#1088
Through that thread I found a user comment (sass/sass#1088 (comment)) which mentioned the map-merge
method which solves this issue nicely.
@import "[%PATH%]/css-vars/css-vars";
$rootvars: ()
$rootvars: map-merge($rootvars, ( '--sidebar-width': $sidebar-width ))
$rootvars: map-merge($rootvars, ( '--topnav-height': $topnav-height ))
$rootvars: map-merge($rootvars, ( '-moz-tab-size': 4 ))
$rootvars: map-merge($rootvars, ( 'tab-size': 4 ))
@include css-vars($rootvars)
This yields the cleanest way to manage the syntax for .sass
files and thought this might help other people in a similar situation.
Hi, thanks for this lib.
I was wondering if there is a way to use native vars with fallback to non-native attribute.
So let's say this
@include css-vars((
--main-color: #000,
));
body {
color: var(--main-color);
}
Will compile to this
body {
color: #000,
color: var(--main-color);
}
And if the browser will support css properties it will use the second value from variable, but if not it will fall-back to first condition.
Thanks
Hi, I just read the post on Smashing Magazine and want to give this a try. Here's the issue I met.
.cell__subtitle {
@include css-vars(( --margin-left: r(1) ));
display : inline-block;
margin-left: var(--margin-left);
font-size : 12px;
@include susy($tablet) {
display: block;
@include css-vars(( --margin-left: 0 ));
}
}
The margin-left: 0
didn't show in browser inspector, but when using this in native way, it worked.
I'm just trying to understand why I would even continue to use sass variables at all when it seems like native css variables are advantageous and supported...
Should I be able to do something like this?
@include css-var ((
--primary: black;
....
));
$primary: var(--primary);
because right now it looks like I can't do things like.
background-color: fade-out(var(--primary), 0.2);
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.