You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Been using sheetify for a while now, and feel there's some rough edges still. In this issue I try and outline which problems I've been experiencing, and suggest solutions on how to fix 'em. Comments and suggestions super welcome; if we need to break stuff this is the place to mention it
problems
insert-css as a peer dep is hella annoying and probably makes for a not-so-great user experience - using sheetify right now doesn't "just work" and yeah it would be cool if it did
from my usage of sheetify, i really want to pass in style variables (as in say from require('./styles')) to each style declaration (#54, #97). unfortunately it's not easy unless we move to doing runtime inline styles instead of compiled string compilation, sooo yeah. 😄
@ahdinosaur yeah a simpler way would be to declare css variables in a :root element in some index file, and then import all other files. Order in sheetify is guaranteed so you could run a transform over the whole bundle which would then resolve the vars. Gets you vars across the board - not convinced we should do fancy interpolation stuffs / runtime parsing as that complicates stuff a bunch
when using it like you suggest above, doesn't that encourage the use of a lot of global variables?
What if i have many components that were authored by different people, which used the same name for their variables, maybe even set those variables... how can i make sure my global css variable won't override or be overridden by a component that uses and sets it too?
constcss=require('sheetify')varx=css`:root {--main-bg-color: brown; /* will be auto-suffixed */ }`/* can be in another file */css` .foo {background-color:var(${x[':root/--main-bg-color']}); }`
then maybe somewhere in a root component that uses a lot of other components, maybe sheetify can offer the sum of all variables that have been defined in all the levels of nested components, so i can generate a style tag that sets all the values for all the variables... like maybe
varcss=require('sheetify')varyo=require('yo-yo')Object.keys(css.vars()).forEach(x=>console.log(x))// to see what is available for theming// then later - remove the line above and replace it with something like:css.vars()[':root/--main-bg-color']='pink'
That wouldn't work as sheetify always returns a prefix. Having multiple
return types based on content feels off - besides Im not really seeing the
added value in the example. I understand globals are not ideal but then
again if variable name conflicts start to become an issue it might be time
to rethink what you're trying to do with CSS anyway haha.
oh, didnt know sheetify is prefixing - guess that's fine too.
I try to build components which are white labeled pages made up of footer components and header components, made up of smaller components. If those components are written by different people or maybe by different me over time... i might not always remember what kind of css variables or names i used in all those different components, like: button, searchbar, signup form, image slider, menubar, and so on...
But once i pull all of them in to build a landing page component, how do i theme it?
I think that's were the basic idea from above comes from. Of course, how to express that in syntax is secondary to me.
I would appreciate some thoughts on how to deal with "complex" components made up of many sub components that i would like to theme and customize. I think i might not remember all the details, but something like css.vars() is a question from me to the component, so that it basically tells me all the stuff i can customize... ...maybe
yeah so you might be looking for something closer to styled-elements which
does all this during runtime - personally I don't think having theming
convenience is beneficial for components; being able to append classes and
later prune them is much more flexible I've found (e.g. the approach we're
taking with base-elements https://github.com/yoshuawuyts/base-elements) -
hope this somewhat answers your question!
oh, didnt know sheetify is prefixing - guess that's fine too.
I try to build components which are white labeled pages made up of footer
components and header components, made up of smaller components. If those
components are written by different people or maybe by different me over
time... i might not always remember what kind of css variables or names i
used in all those different components, like: button, searchbar, signup
form, image slider, menubar, and so on...
But once i pull all of them in to build a landing page component, how do i
theme it?
I think that's were the basic idea from above comes from. Of course, how
to express that in syntax is secondary to me.
I would appreciate some thoughts on how to deal with "complex" components
made up of many sub components that i would like to theme and customize. I
think i might not remember all the details, but something like css.vars()
is a question from me to the component, so that it basically tells me all
the stuff i can customize... ...maybe
—
You are receiving this because you modified the open/close state.
Activity
ahdinosaur commentedon Nov 9, 2016
hey @yoshuawuyts, sounds good to me. 👍
from my usage of
sheetify, i really want to pass in style variables (as in say fromrequire('./styles')) to each style declaration (#54, #97). unfortunately it's not easy unless we move to doing runtime inline styles instead of compiled string compilation, sooo yeah. 😄yoshuawuyts commentedon Nov 9, 2016
@ahdinosaur yeah a simpler way would be to declare css variables in a
:rootelement in some index file, and then import all other files. Order in sheetify is guaranteed so you could run a transform over the whole bundle which would then resolve the vars. Gets you vars across the board - not convinced we should do fancy interpolation stuffs / runtime parsing as that complicates stuff a bunchyoshuawuyts commentedon Nov 9, 2016
e.g.
Kriesse commentedon Nov 11, 2016
@yoshuawuyts The above example looks good to me 👍
ahdinosaur commentedon Nov 13, 2016
@yoshuawuyts you're right that's way simpler, thanks for the suggestion. ✨
[-][roadmap] sheetify v4[/-][+][roadmap] sheetify v6[/+]yoshuawuyts commentedon Nov 16, 2016
Patches are done; can release
sheetify@6when these are merged:yay!
serapath commentedon Nov 16, 2016
when using it like you suggest above, doesn't that encourage the use of a lot of global variables?
What if i have many components that were authored by different people, which used the same name for their variables, maybe even set those variables... how can i make sure my global css variable won't override or be overridden by a component that uses and sets it too?
serapath commentedon Nov 16, 2016
what about
then maybe somewhere in a root component that uses a lot of other components, maybe sheetify can offer the sum of all variables that have been defined in all the levels of nested components, so i can generate a style tag that sets all the values for all the variables... like maybe
yoshuawuyts commentedon Nov 16, 2016
That wouldn't work as sheetify always returns a prefix. Having multiple
return types based on content feels off - besides Im not really seeing the
added value in the example. I understand globals are not ideal but then
again if variable name conflicts start to become an issue it might be time
to rethink what you're trying to do with CSS anyway haha.
On Wed, Nov 16, 2016, 17:35 Alexander Praetorius notifications@github.com
wrote:
yoshuawuyts commentedon Nov 16, 2016
Released as
v6.0.0🎉serapath commentedon Nov 19, 2016
oh, didnt know sheetify is prefixing - guess that's fine too.
I try to build components which are white labeled pages made up of footer components and header components, made up of smaller components. If those components are written by different people or maybe by different me over time... i might not always remember what kind of css variables or names i used in all those different components, like: button, searchbar, signup form, image slider, menubar, and so on...
But once i pull all of them in to build a landing page component, how do i theme it?
I think that's were the basic idea from above comes from. Of course, how to express that in syntax is secondary to me.
I would appreciate some thoughts on how to deal with "complex" components made up of many sub components that i would like to theme and customize. I think i might not remember all the details, but something like
css.vars()is a question from me to the component, so that it basically tells me all the stuff i can customize... ...maybeyoshuawuyts commentedon Nov 19, 2016
yeah so you might be looking for something closer to styled-elements which
does all this during runtime - personally I don't think having theming
convenience is beneficial for components; being able to append classes and
later prune them is much more flexible I've found (e.g. the approach we're
taking with base-elements https://github.com/yoshuawuyts/base-elements) -
hope this somewhat answers your question!
On Sat, Nov 19, 2016 at 5:11 AM Alexander Praetorius <
notifications@github.com> wrote: