Skip to content
This repository has been archived by the owner on Sep 10, 2024. It is now read-only.

Support ergonomic merging styles into child components #43

Open
JAStanton opened this issue Apr 13, 2017 · 1 comment
Open

Support ergonomic merging styles into child components #43

JAStanton opened this issue Apr 13, 2017 · 1 comment

Comments

@JAStanton
Copy link

const STYLES = dapper.compile({
  root: {
    position: 'relative',
  },
  child: {
    position: 'absolute',
    top: 0,
    left: 0,
  },
});

class Parent extends Component {
  
  styles = dapper.reactTo(this, STYLES);

  render() {
    return (
      <div className={this.styles.root}>
        <Child className={this.styles.child} />
      </div>
    );
  }
}

const STYLES2 = dapper.compile({
  root: {
    color: 'red',
  },
});

class Child extends Component {

   styles = dapper.reactTo(this, STYLES2);

  render() {
    return (
      <div className={this.styles.root} />
    );
  }

}

I would expect Child styles to compile to:

.dapper-child-a {
  color: 'red',
  position: 'absolute',
  top: 0,
  left: 0,
}
@RylanH
Copy link
Contributor

RylanH commented Apr 13, 2017

Does add ergonomics for sure, and I'd agree it would be good once we implement #39.

Downside are:

  • there is no guarantee someone defined he prop in the TS typings or propTypes
  • its a bit "magic"

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

No branches or pull requests

2 participants