What about SASS-like stuff
See original GitHub issueHi there, I’ve made some extension for my projects. Do you think it’s useful? Here is description
Extension
Extend style-components with object of following shape
{
vars: {
variableName: 'Variable string value'
},
mixins: {
flex: (flex) => `flex: ${flex}`
}
}
Here is usage example
Extension
variables are the strings, like padding: #minSpace;
mixins are the functions, like @flex(1 1 auto);
mixin accepts varible as argument, like @margin(#minSpace)
mixin accepts multiple arguments, like @tint(#primaryRed, -10%)
styled.init({
vars: {
minSpace: '0.5em',
primaryRed: 'red',
'd:f': 'display: flex',
'ff:rn': 'display: flex; flex-flow: row nowrap',
'ff:cn': 'display: flex; flex-flow: column nowrap',
'jc:sb': 'justify-content: space-between',
'f:a': 'flex: auto'
},
mixins: {
flex: (flex) => `flex: ${flex}`,
margin: (margin) => `margin: ${margin}`,
tint: (color, value) => coolTintColorFunctionFromOutside(color, value)
},
});
Invocation
const Wrapper = styled.div`
padding: #minSpace;
#ff:cn;
#jc:sb;
@flex(1 1 auto);
@margin(#minSpace);
background-color: @tint(#red, -10%);
`;
Issue Analytics
- State:
- Created 7 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Sass like Isla | Baby wearing, Isla, Sass - Pinterest
Sass like Isla. 100% cotton onesies with sass Inspired by family and finding the beauty in chaos. Babywear that brings out our little...
Read more >Sass Like Isla - Facebook
Sass Like Isla. 156 likes. 100% cotton baby onesies and Tees with personality. Inspired by my gorgeous but temperamental daughter, seeing the beauty...
Read more >Throwin sass like confetti ❤︎ #HowYaLikeThat presave in ...
Throwin sass like confetti ❤︎ #HowYaLikeThat presave in comments! ... the only thing a #rambler needs, is a suitcase & a gun ...
Read more >Throw Sass Like Confetti Sassy Shirt Confetti Shirt Sassy - Etsy
Instant download items don't accept returns, exchanges or cancellations. Please contact the seller about any problems with your order.
Read more >Throw Sass Like Confetti Zip Hoodie : Clothing, Shoes ... - Amazon.com
To calculate the overall star rating and percentage breakdown by star, we don't use a simple average. Instead, our system considers things like...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
In my opinion the better way would be to have JS care about variables and mixins. What speaks against using JS for all this for you?
This way nobody has to learn a new pseudo CSS language and we don’t have to bload the styled-components with things JS does very good.
@VicStor I’m sorry, but I meant globals as in variables in a global namespace.
injectGlobal
is an exception to what we normally do and we’re very clear about this in the docs:It’s only for reset-like / normalize-like stylesheets.
The thing with adding sth like this is, while you’re getting rid of import-statements for some variables, you’re adding globals and changing the expected css syntax. I mean, stylis even supports
~~foo
andvar(~~foo)
similar to css’s--foo
andvar(--foo)
, but it’s all custom and adds more mental overhead.I’m not that concerned about the mental overhead however, but I’m more concerned that adding something like this would mean that we’re departing from being a pure css-in-js approach.
For reference:
Thanks btw, I always appreciate a good discussion 😃