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

Refactor Block border props #104

Merged
merged 7 commits into from
Jul 3, 2018
Merged

Conversation

shawnbot
Copy link
Contributor

@shawnbot shawnbot commented Jul 2, 2018

Updates to the Block (and Box) border-related props:

  1. border now only accepts a boolean or one or more edge names (top, right, bottom, or left).
  2. borderColor accepts one of the colors in our border-* utility class list.
  3. round is now borderRadius.

Here's what that looks like:

// Before
<Block border={[true, 'right']} />
<Block border={[true, 'red']} />
<Box round={2} />

// After
<Block border="right" />
<Block borderColor="red" />
<Box borderRadius={2} />

Notes

  • You (still) can't have two different border colors, i.e. one on the left and another on the right.
  • borderRadius values are multipliers as in margin and padding, not pixel values.

Fixes #74.

@shawnbot shawnbot requested a review from a team July 2, 2018 21:05
Copy link

@emplums emplums left a comment

Choose a reason for hiding this comment

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

Just left a few comments, otherwise 👍

src/Block.js Outdated
@@ -3,6 +3,20 @@ import PropTypes from 'prop-types'
import classnames from 'classnames'
import {mapWhitespaceProps, oneOrMoreOf, stylizer} from './props'

const borderColors = [
Copy link

Choose a reason for hiding this comment

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

Can we import these from the theme file instead? (And add them to the theme file if they aren't already there)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, good call! Done.

src/Block.js Outdated
'red-light',
'yellow'
]

const styleProps = ['width', 'minWidth', 'maxWidth', 'height', 'minHeight', 'maxHeight']
Copy link

Choose a reason for hiding this comment

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

Wonder if we want a constants file to start storing things like these? Can be done in a different PR


const {style} = stylize(rest)

return (
<Tag
className={classnames(
className,
getBorderClass(border),
getBorderClass(border, borderColor),
Copy link

Choose a reason for hiding this comment

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

Does passing borderColor here just insure that if someone passes a borderColor but no border prop, the border still gets applied?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep. The idea was that you would only have to pass, say, borderColor='green' to get a green border, rather than border borderColor='green', which feels redundant to me.

@@ -48,11 +77,13 @@ const Block = props => {

Block.propTypes = {
bg: PropTypes.string,
border: oneOrMoreOf(PropTypes.oneOfType([PropTypes.string, PropTypes.bool, PropTypes.number])),
border: PropTypes.oneOfType([PropTypes.bool, oneOrMoreOf(PropTypes.oneOf(['top', 'right', 'bottom', 'left']))]),
Copy link

Choose a reason for hiding this comment

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

Shouldn't this be border: PropTypes.oneOfType([PropTypes.bool, oneOrMoreOf(['top', 'right', 'bottom', 'left']))?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think so. This is saying, "either a boolean, one of these values, or an array of these values."

@shawnbot shawnbot merged commit 1f94a47 into release-0.0.7-beta Jul 3, 2018
@shawnbot shawnbot deleted the refactor-border-prop branch July 3, 2018 04:22
@shawnbot shawnbot mentioned this pull request Jul 20, 2018
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