forked from Semantic-Org/Semantic-UI-React
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Alexander Fedyashov
committed
Jul 12, 2016
1 parent
9beb4a9
commit 95cfe48
Showing
3 changed files
with
95 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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,73 @@ | ||
import _ from 'lodash' | ||
import React, { PropTypes } from 'react' | ||
import cx from 'classnames' | ||
|
||
import * as sui from '../../utils/semanticUtils' | ||
import { customPropTypes, getUnhandledProps, useKeyOnly, useKeyOrValueAndKey } from '../../utils/propUtils' | ||
import META from '../../utils/Meta' | ||
|
||
function Rail(props) { | ||
const { attached, className, close, children, dividing, internal, position, size } = props | ||
const classes = cx( | ||
'ui', | ||
position, | ||
useKeyOnly(attached, 'attached'), | ||
useKeyOrValueAndKey(close, 'close'), | ||
useKeyOnly(dividing, 'dividing'), | ||
useKeyOnly(internal, 'internal'), | ||
size, | ||
className, | ||
'rail', | ||
) | ||
const rest = getUnhandledProps(Rail, props) | ||
|
||
return <div className={classes} {...rest}>{ children }</div> | ||
} | ||
|
||
Rail._meta = { | ||
library: META.library.semanticUI, | ||
name: 'Rail', | ||
type: META.type.element, | ||
props: { | ||
close: ['very'], | ||
position: sui.floats, | ||
size: _.without(sui.sizes, 'mini', 'small', 'medium', 'big'), | ||
}, | ||
} | ||
|
||
Rail.propTypes = { | ||
/** Show that the Rail is attached. */ | ||
attached: PropTypes.bool, | ||
|
||
/** Classes that will be added to the Rail className. */ | ||
className: PropTypes.string, | ||
|
||
/** Show that the Rail is close. */ | ||
close: PropTypes.oneOfType([ | ||
PropTypes.bool, | ||
PropTypes.oneOf(Rail._meta.props.close), | ||
]), | ||
|
||
/** Primary content of the Rail. */ | ||
children: customPropTypes.ofComponentTypes([ | ||
'Segment', | ||
]), | ||
|
||
/** Show that the Rail is dividing. */ | ||
dividing: PropTypes.bool, | ||
|
||
/** Show that the Rail is internal. */ | ||
internal: PropTypes.bool, | ||
|
||
/** Show that the Rail is inverted. */ | ||
inverted: PropTypes.bool, | ||
|
||
/** Shows Rail's position. */ | ||
position: PropTypes.oneOf(Rail._meta.props.position).isRequired, | ||
|
||
/** Size of the Rail. */ | ||
size: PropTypes.oneOf(Rail._meta.props.size), | ||
} | ||
|
||
export default Rail | ||
|
This file contains 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 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,21 @@ | ||
import React from 'react' | ||
|
||
import Rail from 'src/elements/Rail/Rail' | ||
import * as common from 'test/specs/commonTests' | ||
|
||
describe('Rail', () => { | ||
common.isConformant(Rail) | ||
common.hasUIClassName(Rail) | ||
common.propValueOnlyToClassName(Rail, 'position') | ||
common.propKeyOnlyToClassName(Rail, 'attached') | ||
common.propKeyOrValueToClassName(Rail, 'close') | ||
common.propKeyOnlyToClassName(Rail, 'dividing') | ||
common.propKeyOnlyToClassName(Rail, 'internal') | ||
common.propValueOnlyToClassName(Rail, 'size') | ||
common.rendersChildren(Rail) | ||
|
||
it('renders an div element', () => { | ||
shallow(<Rail />) | ||
.should.have.tagName('div') | ||
}) | ||
}) |