reacttips-dev / stylex

Write CSS-in-JS with atomic support. Like Facebook's Stylex!

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Allow nested objects within stylex.create for importing purposes

Rynebenson opened this issue · comments

I would like to define styles once and import throughout my app.

[styles.js]
import { margin } from './margin'

const styles = stylex.create({
  margin
});

export default styles
[margin.js]
export const margin = {
  micro: {
    margin: 4
  },
  small: {
    margin: 8
  },
  top: {
    micro: {
      marginTop: 4
    },
    small: {
      marginTop: 8
    }
  }
}
[component.js]
import styles from './styles'

function Component() {
  return (
    <div className={stylex(styles.margin.small)}>
      <button className={stylex(styles.margin.top.micro)}>
        Click Me!
      </button>
    </div>
  )
}