-
Notifications
You must be signed in to change notification settings - Fork 4k
Divider Component updated to v1 API #268
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
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
b633094
Divider Component updated to v1 API
jhchill666 5c2d735
Added missing prop 'className' to classes
jhchill666 62bebe5
CircleCI failure resolutions
jhchill666 049535f
CircleCI failure resolutions
jhchill666 f49afbb
Removes Extra Semicolon
jhchill666 c4a15b2
Redundant `createFragment` removed and additional assertions added
jhchill666 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,30 +1,75 @@ | ||
| import React, { Component, PropTypes } from 'react' | ||
| import classNames from 'classnames' | ||
| import cx from 'classnames' | ||
| import React, { PropTypes } from 'react' | ||
| import META from '../../utils/Meta' | ||
| import { | ||
| getUnhandledProps, | ||
| useKeyOnly, | ||
| } from '../../utils/propUtils' | ||
|
|
||
| export default class Divider extends Component { | ||
| static propTypes = { | ||
| children: PropTypes.node, | ||
| className: PropTypes.string, | ||
| } | ||
|
|
||
| static _meta = { | ||
| library: META.library.semanticUI, | ||
| name: 'Divider', | ||
| type: META.type.element, | ||
| } | ||
|
|
||
| render() { | ||
| const classes = classNames( | ||
| 'sd-divider', | ||
| 'ui', | ||
| this.props.className, | ||
| 'divider' | ||
| ) | ||
| return ( | ||
| <div {...this.props} className={classes}> | ||
| {this.props.children} | ||
| </div> | ||
| ) | ||
| } | ||
| /** | ||
| * A divider visually segments content into groups | ||
| */ | ||
| function Divider(props) { | ||
| const { | ||
| horizontal, vertical, inverted, fitted, hidden, section, clearing, | ||
| children, className, | ||
| } = props | ||
|
|
||
| const classes = cx('sd-divider ui', | ||
| useKeyOnly(horizontal, 'horizontal'), | ||
| useKeyOnly(vertical, 'vertical'), | ||
| useKeyOnly(inverted, 'inverted'), | ||
| useKeyOnly(fitted, 'fitted'), | ||
| useKeyOnly(hidden, 'hidden'), | ||
| useKeyOnly(section, 'section'), | ||
| useKeyOnly(clearing, 'clearing'), | ||
| 'divider', | ||
| className | ||
| ) | ||
|
|
||
| const DividerComponent = 'div' | ||
| const rest = getUnhandledProps(Divider, props) | ||
|
|
||
| return ( | ||
| <DividerComponent className={classes} {...rest}> | ||
| {children} | ||
| </DividerComponent> | ||
| ) | ||
| } | ||
|
|
||
| Divider._meta = { | ||
| library: META.library.semanticUI, | ||
| name: 'Divider', | ||
| type: META.type.element, | ||
| } | ||
|
|
||
| Divider.propTypes = { | ||
| /** Primary content of the Divider */ | ||
| children: PropTypes.node, | ||
|
|
||
| /** Classes to add to the divider className. */ | ||
| className: PropTypes.string, | ||
|
|
||
| /** Divider can segment content horizontally */ | ||
| horizontal: PropTypes.bool, | ||
|
|
||
| /** Divider can segment content vertically */ | ||
| vertical: PropTypes.bool, | ||
|
|
||
| /** Divider can have it's colours inverted */ | ||
| inverted: PropTypes.bool, | ||
|
|
||
| /** Divider can be fitted without any space above or below it */ | ||
| fitted: PropTypes.bool, | ||
|
|
||
| /** Divider can divide content without creating a dividing line */ | ||
| hidden: PropTypes.bool, | ||
|
|
||
| /** Divider can provide greater margins to divide sections of content */ | ||
| section: PropTypes.bool, | ||
|
|
||
| /** Divider can clear the content above it */ | ||
| clearing: PropTypes.bool, | ||
| } | ||
|
|
||
| export default Divider |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| import React from 'react' | ||
|
|
||
| import Divider from 'src/elements/Divider/Divider' | ||
| import * as common from 'test/specs/commonTests' | ||
|
|
||
| describe('Divider', () => { | ||
| common.isConformant(Divider) | ||
| common.rendersChildren(Divider) | ||
| common.hasUIClassName(Divider) | ||
|
|
||
| common.propKeyOnlyToClassName(Divider, 'horizontal') | ||
| common.propKeyOnlyToClassName(Divider, 'vertical') | ||
| common.propKeyOnlyToClassName(Divider, 'inverted') | ||
| common.propKeyOnlyToClassName(Divider, 'fitted') | ||
| common.propKeyOnlyToClassName(Divider, 'hidden') | ||
| common.propKeyOnlyToClassName(Divider, 'section') | ||
| common.propKeyOnlyToClassName(Divider, 'clearing') | ||
|
|
||
| it('renders a <div /> element', () => { | ||
| shallow(<Divider />) | ||
| .should.have.tagName('div') | ||
| }) | ||
|
|
||
| it('adds the "divider" class', () => { | ||
| shallow(<Divider />) | ||
| .should.have.className('divider') | ||
| }) | ||
| }) | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's add common.rendersChildren and common.hasUIClassName.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are also common tests for the classNames, reference https://github.com/TechnologyAdvice/stardust/blob/master/test/specs/elements/Label/Label-test.js