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

Css property alternative api #51

Open
zmitry opened this issue Jul 6, 2019 · 0 comments
Open

Css property alternative api #51

zmitry opened this issue Jul 6, 2019 · 0 comments

Comments

@zmitry
Copy link

zmitry commented Jul 6, 2019

I have idea how to improve adoption and DX and I think using css prop instead of styled function should improve that quite a lot.
Here are few examples

const App = () => (
  <use.container
    css={css`
      h1 {
        font-size: 4rem;
      }
      Button {
        border: 1px solid ${red};
      }
      container {
        ///
      }
    `}
  >
    <h1>hello</h1>
    <Button>world</Button>
  </use.container>
)
const styles = css`
      h1 {
        font-size: 4rem;
      }
      Button {
        border: 1px solid ${red};
      }
      container {
        ///
      }
    `
const App = () => (
  <use.container css={styles}>
    <h1>hello</h1>
    <Button>world</Button>
  </use.container>
)
const styles = css`
  // should we treat top css as root classname
   padding-top: 20px;
   span {
     padding-right: 20px;
   }
`
const Title = () => (
  <h1 css={styles}>
    world <span> </span>
  </h1r>
)

composition

const commonStyles = css`
    padding-top: 20px;
   span {
     padding-right: 20px;
   }
`
const fileStyles = css`
   // some styles
`
const Title = ({ styles  }) => (
  <h1 css={[commonStyles, fileStyles, styles]}>
    world <span> hello </span>
  </h1r>
)

without root element

const styles = css`
   span {
     padding-right: 20px;
   }
`
const Title = ({ styles  }) => (
  <Fragment css={styles}>
    world <span> hello </span> !
  </Fragment>
)

Happy to hear you comments on that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant