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

[REDO] Add system props #158

Merged
merged 64 commits into from
Jul 27, 2018
Merged

[REDO] Add system props #158

merged 64 commits into from
Jul 27, 2018

Conversation

shawnbot
Copy link
Contributor

⚠️ This was originally done in #155 for v0.0.12-beta, but we decided to revert it and introduce the API changes in the next release, pending much-needed docs.

This introduces something approaching a "system" for shared props that are intended generate classes matching those generated in #147.

The mappers:

  • borderColor, e.g. borderColor='red' renders class='border-red'
  • borderRadius e.g. borderRadius={1} renders class='round-1', responsive
  • color, e.g. color='blue.4' renders class='color-blue-4'
  • display does display='flex'class='d-flex' and is responsive
  • flex implements all of the FlexContainer mappings (maybe it should be called flexContainer?)
  • fontSize does fontSize={0}class='f-0' (note the hyphen for consistency), responsive
  • margin, padding, and the composure of the two in spacing; all responsive w/edge variants
  • position, e.g. position='absolute' renders class='position-absolute', responsive

Here's how they're used right now:

import {composeWithPropTypes} from './props'
import {bg, color} from './mappers'

const mapProps = composeWithPropTypes(bg, color)

export default function MyComponent(props) {
  const {className, children, ...rest} = mapProps(props)
  return <div className={className}>{children}</div>
}

MyComponent.propTypes = {
  ...mapProps.propTypes
}

Also in this PR:

  • New jest test matchers that make it easier to test classname output
  • Inline styles from system.css thanks to the magic of preval
  • A new "Props" tab in the x0 docs that demos color, fontSize, margin, and padding props

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.

1 participant