Replies: 3 comments 5 replies
-
Thanks, makes a lot of sense. We'll consider this internally. @hadihallak do you know if there's a current work around for this, even if it means storying some types product-side? Thanks |
Beta Was this translation helpful? Give feedback.
-
Been thinking about this some more over the last few days and I don't think this is actually possible in TypeScript (without defining a function for generics) 😢 This may be trickier than I anticipated |
Beta Was this translation helpful? Give feedback.
-
I meet your problem at this time. When I trying to preview Component with variant, like: // button.tsx
const Button = styled('button', {
variants: {
mode: {
mode1: {},
mode2: {}
}
}
} // button.stories.tsx
import { Button } from './button'
export default {
component: Button,
} Storybook can't auto generate args, so I should do it manually.. |
Beta Was this translation helpful? Give feedback.
-
At @monographhq we've recently started exploring the convention of storing our Stitches.js styles in separate
.css.ts
files (similar to vanilla-extract)We do this to:
Allowing for styles to be referenced privately/internally
e.g. mapping over
variants
anddefaultVariants
to set options for "controls" dynamicallyThe Problem
Stitches.js offers the
CSS
type for handling basic styles, but as it stands there's no way to obtain the object syntax type (the argument type forcss()
or the second argument type forstyled
) – a combination of theCSS
type + handling ofvariants
,defaultVariants
andcompoundVariants
I attempted using TypeScript's built in
Parameters<typeof styled>
but had no luck 😢 (it returnsnever
)Proposed solution
It would be awesome if Stitches could provide a helper type (like
CSS
for handling the style object type)In this example I suggest
StyleObject
, but perhapsComponent
may make more sense?If this is a little too much to consider right now, I'd really appreciate any guidance on how to achieve this in the meantime 🙏
cc @dknisley @expandrew
Beta Was this translation helpful? Give feedback.
All reactions