solid-styled-components icon indicating copy to clipboard operation
solid-styled-components copied to clipboard

styled: multiple arguments not working(?)

Open nksfrank opened this issue 3 years ago • 2 comments

I seem to have an issue with passing in multiple arguments to styled. From what I can tell by the types, it should be possible to do the following

const Component = styled('div')(
  {
    display: 'inline-flex',
    width: '100%',
    height: '100%',
    border: '1px solid #222'
  },
  (props) => props.hidden && ({ display: 'none' }),
  (props) => props.rounded && ({borderRadius: '.3em' })
  ({
    background: '#f2f2f2'
  })
)

but that doesn't actually call or apply the arguments past the first one. However, reading goober's manual they accept an array (https://github.com/cristianbote/goober#arrays) for using multiple arguments. passing in an array to styled works and all the styles are computed and applied as expected, but the types doesn't seem to like that. image

minimal reproducible example https://codesandbox.io/s/friendly-payne-ehyjo

nksfrank avatar Jan 23 '22 12:01 nksfrank

I see. Yeah I'd welcome any PRs to help with types. I was lifting Goober's types but the maintainer like myself is not the best at TS and sort of leaves it to the community. So they've been erratic and I eventually had to split off of theirs. But it sounds like we're missing stuff or have mismatched types at a minimum.

ryansolid avatar Jan 23 '22 21:01 ryansolid

I can put up a PR for this. I'm just wondering if 1) we want it to work the way Goober expects it. Wrapping the arguments with an array. or 2) do we want it to work like the types, where there arguments are variadic. mimicking the @emotion & styled-components package.

First is just a quick types fix. Second one would be a change to how we pass arguments in to goober's css, I'm assuming

nksfrank avatar Jan 24 '22 07:01 nksfrank

@ryansolid @nksfrank I've opened a PR to try to fix the type issue https://github.com/solidjs/solid-styled-components/pull/38

100terres avatar Oct 09 '22 03:10 100terres