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

ThemeProp should not be optional

Open thegurneet opened this issue 3 years ago • 3 comments

The ThemeProp needs to be changed from optional to required if the ThemeProvider has theme as required.

This is causing props to be either DefaultTheme | undefined, when a theme is clearly defined.

Screenshot 2022-11-07 at 14 15 17 Screenshot 2022-11-07 at 14 16 55

thegurneet avatar Nov 07 '22 14:11 thegurneet

Anything on this?

specialdoom avatar Nov 30 '22 08:11 specialdoom

When using a function, I'm not sure there is a way to figure out automatically what is the type of theme (you might have not initialized the theme in the first place).

Ideally the type should be inferred when providing it as a generic type.

const myTheme = {
  color: {
    backgroundColor: '#123'
  }
}
const SomeText = styled("div")<{ theme: typeof myTheme }>``;

PS : Please do not provide only screenshots when opening an issue 🙏🏽

mlaopane avatar Dec 29 '22 09:12 mlaopane

The screenshot in this instance provided enough information.

`const SomeText = styled("div")<{ theme: typeof myTheme }>``

Defining the theme like this is wrong. For each no styled component I will have to define the theme as typeof myTheme.

The documentation solid-styled-components is based of: https://styled-components.com/docs/advanced

The theme is always defined by default, we simply extend onto it by giving it more props.

thegurneet avatar Jan 12 '23 16:01 thegurneet