Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unwrap styled() calls #209

Open
oliviertassinari opened this issue Aug 22, 2024 · 1 comment
Open

Unwrap styled() calls #209

oliviertassinari opened this issue Aug 22, 2024 · 1 comment
Assignees
Labels
performance priority: low To delay as much as possible status: waiting for maintainer These issues haven't been looked at yet by a maintainer

Comments

@oliviertassinari
Copy link
Member

oliviertassinari commented Aug 22, 2024

Summary

I wonder about the long-term potential of unwrapping the styled() calls into their primitive.

Examples

  • Tamagui
import { Text, styled } from '@tamagui/core'

export const Heading = styled(Text, {
  tag: 'h1',
  color: '$color',
  backgroundColor: '$background',

  variants: {
    size: {
      large: {
        fontSize: 22,
      },
      small: {
        fontSize: 16,
      },
    },
  },

gets converted to

export const App = props => <div className={_cn}>
    <h1 className={_cn2 + (_cn3 + (props.big ? _cn4 : _cn5))}>
      Lorem ipsum.
    </h1>
  </div>
  
const _cn5 = " _fos-16px"
const _cn4 = " _fos-22px"
const _cn3 = " _bg-180kg62 _col-b5vn3b _mt-0px _mr-0px _mb-0px _ml-0px _ww-break-word _bxs-border-box _ff-System _dsp-inline  "
const _cn2 = "  font_System"
const _cn = "  is_View _fd-column _miw-0px _mih-0px _pos-relative _bxs-border-box _fb-auto _dsp-flex _fs-0 _ai-stretch  _w-550px _pr-1aj14ca _pl-1aj14ca  _pr-_gtSm_lrpixp _pl-_gtSm_lrpixp"
SCR-20240822-qfzz

Motivation

Performance

Search keywords: -

@oliviertassinari oliviertassinari added performance status: waiting for maintainer These issues haven't been looked at yet by a maintainer priority: low To delay as much as possible labels Aug 22, 2024
@o-alexandrov
Copy link

This issue along with inability to understand when viewing JSX whether you are using a styled over a React component or a primitive HTML element are the two reasons why I vote to never use styled :D

  • passing className using css is a clear alternative

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
performance priority: low To delay as much as possible status: waiting for maintainer These issues haven't been looked at yet by a maintainer
Projects
None yet
Development

No branches or pull requests

3 participants