styled-components / xstyled

A utility-first CSS-in-JS framework built for React. 💅👩‍🎤⚡️
https://xstyled.dev
MIT License
2.28k stars 105 forks source link

Scale object in theme #283

Closed indiejoseph closed 3 years ago

indiejoseph commented 3 years ago

💬 Questions and Help

I wonder is there any way to do responsive scale in theme object, like how styled-system does https://styled-system.com/theme-specification#scale-objects.

{
...
  texts: {
    heading: {
      fontSize: { sx: '14px', md: '16px', lg: '18px' }, // does't work with xstyled
      // fontSize: ['14px', '16px', '18px'], with styled-system
    },
  }

<x.p text="heading" />

Thanks!

gregberge commented 3 years ago

Actually that's not the way it works but I will consider it! Thanks.

indiejoseph commented 3 years ago

Thanks! I wonder how did you handle it?

or something like:

<x.p text={{ xs: 'heading1', lg: 'heading2' }} />
gregberge commented 3 years ago

<x.p text={{ xs: 'heading1', lg: 'heading2' }} />

yeah

gregberge commented 3 years ago

I tested it and it already work, example:

const theme = {
  texts: { custom: { fontSize: { _: 10, md: 16 } } },
}