tss-react icon indicating copy to clipboard operation
tss-react copied to clipboard

Add support for StyledOptions, as a last argument of `withStyles` function

Open matyas-igor opened this issue 2 years ago • 1 comments

This is a proposal to add the same options object as styled emotion function has, as a last argument of withStyles function.

Motivation

Right now to not pass an argument down to component, I need to write:

const RightDrawer = withStyles(
  ({
    $width,
    ...props
  }: React.ComponentProps<typeof Drawer> & { $width: number }) => (
    <Drawer {...props} />
  ),
  (theme, props) => ({
    paper: {
      ...,
    },
  })
);

Instead, I would like to have:

const RightDrawer = withStyles(Drawer,
  (theme, props) => ({
    paper: {
      ...,
    },
  }),
  { shouldForwardProp: (propName: string) => !propName.startsWith("$") }
);

matyas-igor avatar May 09 '22 11:05 matyas-igor

Hi @matyas-igor,
I like this proposal.
I have no time to implement it in the short therm but if you submit a PR I will happily review and merge it.

garronej avatar May 09 '22 11:05 garronej

In the end I figured out it was imposible to type it correctly so I give up sorry.

garronej avatar Oct 04 '22 14:10 garronej