Skip to content

Commit

Permalink
Merge pull request #410 from StevenLangbroek/feat/clean-tag-terminology
Browse files Browse the repository at this point in the history
feat: rename blacklist to omitProps
  • Loading branch information
jxnblk committed Mar 22, 2019
2 parents 8c1c191 + 7816e7c commit b62e49e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
8 changes: 4 additions & 4 deletions packages/clean-tag/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,15 @@ Changes the underlying HTML element per component instance.
<Heading is='h1' />
```

## `blacklist` prop
## `omitProps` prop

Provide a custom blacklist of prop names.
Provide a custom list of prop keys to remove from the backing styled component.

The default blacklist is based on Styled System's propType definitions.
The default list is based on Styled System's propType definitions.

```js
<Heading
blacklist={[
omitProps={[
'fontSize',
'color'
]}
Expand Down
8 changes: 4 additions & 4 deletions packages/clean-tag/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const allPropTypes = Object.keys(styles)
.filter(key => typeof styles[key] === 'function')
.reduce((a, key) => Object.assign(a, styles[key].propTypes), {})

const blacklist = [ ...Object.keys(allPropTypes), 'theme' ]
const omitProps = [ ...Object.keys(allPropTypes), 'theme' ]

export const omit = (obj, keys) => {
const next = {}
Expand All @@ -19,17 +19,17 @@ export const omit = (obj, keys) => {

export const Tag = React.forwardRef(({
is: Tag = 'div',
blacklist = [],
omitProps = [],
...props
}, ref) => React.createElement(Tag, {
ref,
...omit(props, blacklist)
...omit(props, omitProps)
}))

Tag.displayName = 'Clean.div'

Tag.defaultProps = {
blacklist
omitProps: omitProps
}

tags.forEach(tag => {
Expand Down
6 changes: 3 additions & 3 deletions packages/clean-tag/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ test('exports html tags', t => {
t.is(header.type, 'header')
})

test('exported html tags only omit blacklisted props', t => {
test('exported html tags only omits props', t => {
const json = render(React.createElement(tag.h1, {
id: 'hello',
m: 2,
Expand All @@ -51,10 +51,10 @@ test('accepts an is prop to change the underlying element', t => {
t.is(json.type, 'header')
})

test('accepts a custom blacklist', t => {
test('accepts custom omitProps', t => {
const json = render(React.createElement(tag, {
hello: 'hi',
blacklist: [ 'hello' ]
omitProps: [ 'hello' ]
})).toJSON()
t.is(json.props.hello, undefined)
})
Expand Down

0 comments on commit b62e49e

Please sign in to comment.