Comments (4)
This is amazing feedback @CodingDive, thank you so much ❤️
-
Yes, I completely agree. That was a pretty amazing feature. I am running this issue and hoping it will result in allowing it: microsoft/TypeScript#38106. Like, there are ways to get around it by doing things like:
css.marginTop(tokens => tokens.SPACE_70)
, which would give you the type info.... we could also docss.marginTop.SPACE_70
which would indeed also give you the type info I believe. The type info here would include typing formarginTop
being a function as well... though it is certainly more straight forward. I would look into that 😄 -
Yeah, exactly, the experience of getting going and configuring is awesome :)
-
Yeah, lets see where we are at now with the latest update, where types has been improved 😄
-
Yes, indeed, we are not doing anything currently on the defaults. We could expose a set of tokens though that would give you a smoother experience out of the box. Also supporting more token categories is absolutely possible. If you want to create a
tokens
configuration without thinking about current constraints that would be awesome... just create a GIST or something. Then that might end up as a default set of tokens in the library 😄 -
Ah, yes, I believe uppercasing it all is the best, though I think that tokens should probably be exposed as a property instead of a value to the function as explained above. Let me try this first and then you will get a very nice separation there. Just have to check out if we can bring in the typing :)
-
Yes! This surprised us as well! The reason it works like this is so that we inject the styling needed at the point of consumption... though this in theory seems smart, it might not necessarily be more performant. But yeah, in discussion, and will document this yes
Thanks so much again for the encouragement and feedback! 😃
from stitches.
Thank you so much for the detailed response.
having duplicate APIs has a high cost in maintenance, documentation and understanding the library.
I believe so too.
css.color.RED_500
css.color('RED_500', ':hover')
The only reasonable alternative I see is to go full token-based for props/values but not repeat the mistake of classsy-ui and pass the pseudo-selectors into a function.
css.color.RED_500,
css.on(':hover').color.RED_500,
When used with data-attributes and selectors see #7, we could optionally get some nice type support when passing in an enum of data-attributes.
enum LISTBOX_DATA {
DISABLED_OPTION: '[data-reach-listbox-option][aria-disabled="true"]',
}
// assuming we keep the 'on' function for solely pseudo-selectors and 'when' for data-attributes. Those two could also be merged as a single function whose value gets prepended before the property & token as is currently the case for the second argument.
css.when<LISTBOX_DATA>('DISABLED_OPTION').cursor('not-allowed')
This would just make it a bit nicer to work with data attributes as the atomic approach of stitches
would make me put most static data attributes into an enum anyhow. The point here is not necessarily the example and the generic enum argument gimmick, but show the potential possibilities of having an extra function for pseudo selectors. It would also certainly be more readable than the current argument order as addressed below.
css.color('RED_500', ':hover')
Another thing on my stitches API wishlist would be to make the ordering of the arguments agnostic since we are used to writing selectors => property & value
from left to right.
css.color(':hover', 'RED_500')
Is definitely easier to read for me but it's not a big deal either way. I just wanted to add it here since it would've been very difficult to fix this in classy-ui
, while I believe the function-based approach of stitches to be flexible enough to swap them around easily.
from stitches.
Okay, so I played around with the typing and we can indeed fix this. If we have added tokens you can write it as:
css.color.RED_500 // With all the type documentation
css.color('red') // Is still possible when you need to override
The problem is pseudo selectors, as you can not express those without a function:
css.color.RED_500
css.color('RED_500', ':hover')
Would have to be like this... hm... have to think on that 😄
from stitches.
Okay, discussed a bit and we need to wait with this. The reason is that having duplicate APIs has a high cost in maintenance, documentation and understanding the library. I certainly see the benefit of having a token documented to what CSS it produces, but at the same time... tokens are really there for you to NOT think about the underlying value. The underlying values should freely be able to change without you worrying about it.
So yeah, I still agree with you, it was amazing to have that information there... but yeah, here you have a current state of things at least 😄
Please discuss more if you want to!
from stitches.
Related Issues (20)
- Variants which contain numeric strings (e.g. "-12") and number keys (e.g. 12) are assigned a 'number' type when generating a union using the VariantProps type
- A Simplified Responsive Variants Api
- boxShadow isen't working when i use a color from my theme HOT 2
- Vendor prefix is stripped from WebkitBackgroundClip
- when using prefix, theme tokens in globalCSS aren't prefixed HOT 2
- Theme token not being parsed when overriding CSS prop (Next.js) HOT 1
- styled components not passing variants
- please consider using css string props like emotion HOT 2
- Is this project dead? HOT 2
- Container queries support HOT 2
- Chat about the future for stitches HOT 44
- When a responsive variant matches the @initial variant, the initial one is not applied. HOT 1
- reset function returned from createStitches is not in docs
- costum propreties like variants and sizes : example costum proprety
- export type of `css` function HOT 2
- (Feature request): Ability for child element to opt out of theme
- Dynamic props in styled
- Project Dead? HOT 1
- How to add `!important` automatically HOT 1
- Not compatible with `moduleResolution: "Bundler"`
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from stitches.