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

SX: change imports/exports to allow composability #1352

Merged
merged 1 commit into from
Nov 18, 2020
Merged

Conversation

mrtnzlml
Copy link
Member

I would like to propose a change of the default export which would allow us to merge external SX stylesheets. For example, here is a base component:

import sx from '@adeira/sx';

type Props = {|
  +xstyle: {|
    +marginTop: number,
  |},
|};

const styles = sx.create({ default: { fontSize: 16 } });

function MyBaseComponent(props: Props) {
  return <div className={sx(styles.default, props.xstyle)} />;
}

And another wrapping component which is sending down some custom styles:

const styles = sx.create({ spacing: { marginTop: 4 } });

function MyCustomComponent() {
  return <MyBaseComponent xstyle={styles.spacing} />;
}

We are currently unable to achieve such behavior without this change.

This change is inspired by StyleX, see: https://youtu.be/9JZHodNR184

Copy link
Contributor

@tbergquist-godaddy tbergquist-godaddy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@mrtnzlml mrtnzlml force-pushed the sx-composability branch 2 times, most recently from 59e7b54 to 8af1d9b Compare November 18, 2020 15:44
I would like to propose a change of the default export which would allow us to merge external SX stylesheets. For example, here is a base component:

```
import sx from '@adeira/sx';

type Props = {|
  +xstyle: {|
    +marginTop: number,
  |},
|};

const styles = sx.create({ default: { fontSize: 16 } });

function MyBaseComponent(props: Props) {
  return <div className={sx(styles.default, props.xstyle)} />;
}
```

And another wrapping component which is sending down some custom styles:

```
const styles = sx.create({ spacing: { marginTop: 4 } });

function MyCustomComponent() {
  return <MyBaseComponent xstyle={styles.spacing} />;
}
```

We are currently unable to achieve such behavior without this change.

This change is inspired by StyleX, see: https://youtu.be/9JZHodNR184
@mrtnzlml mrtnzlml merged commit cb9c47b into master Nov 18, 2020
@mrtnzlml mrtnzlml deleted the sx-composability branch November 18, 2020 15:55
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

Successfully merging this pull request may close these issues.

2 participants