diff --git a/docs/app/Examples/elements/List/Content/ListDescriptionExample.js b/docs/app/Examples/elements/List/Content/ListDescriptionExample.js index 74435f2fc2..94d86fba09 100644 --- a/docs/app/Examples/elements/List/Content/ListDescriptionExample.js +++ b/docs/app/Examples/elements/List/Content/ListDescriptionExample.js @@ -17,6 +17,15 @@ export default class ListDescriptionExample extends Component { header='Nashville' description='This city is located in the state of Tennessee' /> + + + + Daniel Louise + + This is an example of using sub-components. + + + ) } diff --git a/docs/app/Examples/elements/List/Content/ListHeaderExample.js b/docs/app/Examples/elements/List/Content/ListHeaderExample.js index 896cc32895..9581691d3c 100644 --- a/docs/app/Examples/elements/List/Content/ListHeaderExample.js +++ b/docs/app/Examples/elements/List/Content/ListHeaderExample.js @@ -8,6 +8,16 @@ export default class ListHeaderExample extends Component { + + + + Chapter 4 + + + This is an example of a sub-component. + + + ) } diff --git a/docs/app/Examples/elements/List/Content/ListIconExample.js b/docs/app/Examples/elements/List/Content/ListIconExample.js index a4783a06ce..c18a3d9a95 100644 --- a/docs/app/Examples/elements/List/Content/ListIconExample.js +++ b/docs/app/Examples/elements/List/Content/ListIconExample.js @@ -21,6 +21,12 @@ export default class ListIconExample extends Component { This item uses child text, check the code. + + + + This is an example of using sub-components + + ) } diff --git a/docs/app/Examples/elements/List/Types/ListBulletedExample.js b/docs/app/Examples/elements/List/Types/ListBulletedExample.js index 487192bdcc..4b6137d472 100644 --- a/docs/app/Examples/elements/List/Types/ListBulletedExample.js +++ b/docs/app/Examples/elements/List/Types/ListBulletedExample.js @@ -4,7 +4,7 @@ import { List } from 'stardust' export default class ListBulletedExample extends Component { render() { return ( - + diff --git a/docs/app/Examples/elements/List/Types/ListLinkExample.js b/docs/app/Examples/elements/List/Types/ListLinkExample.js index 46934a3ca3..97207793e0 100644 --- a/docs/app/Examples/elements/List/Types/ListLinkExample.js +++ b/docs/app/Examples/elements/List/Types/ListLinkExample.js @@ -8,7 +8,7 @@ export default class ListLinkExample extends Component { const link3 = Services const link4 = Careers return ( - + diff --git a/docs/app/Examples/elements/List/Types/ListOrderedExample.js b/docs/app/Examples/elements/List/Types/ListOrderedExample.js index 8ddd107e87..03fdf40f6c 100644 --- a/docs/app/Examples/elements/List/Types/ListOrderedExample.js +++ b/docs/app/Examples/elements/List/Types/ListOrderedExample.js @@ -4,7 +4,7 @@ import { List } from 'stardust' export default class ListOrderedExample extends Component { render() { return ( - + diff --git a/docs/app/Examples/elements/List/Variations/ListAnimatedExample.js b/docs/app/Examples/elements/List/Variations/ListAnimatedExample.js index f1880e9083..f8434e80ad 100644 --- a/docs/app/Examples/elements/List/Variations/ListAnimatedExample.js +++ b/docs/app/Examples/elements/List/Variations/ListAnimatedExample.js @@ -8,7 +8,7 @@ export default class ListAnimatedExample extends Component { const avatar2 = const avatar3 = return ( - + diff --git a/docs/app/Examples/elements/List/Variations/ListCelledExample.js b/docs/app/Examples/elements/List/Variations/ListCelledExample.js index 4294c9fee2..a54beb0e3a 100644 --- a/docs/app/Examples/elements/List/Variations/ListCelledExample.js +++ b/docs/app/Examples/elements/List/Variations/ListCelledExample.js @@ -8,7 +8,7 @@ export default class ListCelledExample extends Component { const avatar2 = const avatar3 = return ( - + diff --git a/docs/app/Examples/elements/List/Variations/ListDividedExample.js b/docs/app/Examples/elements/List/Variations/ListDividedExample.js index 6bb3ed42f1..ffafd434c7 100644 --- a/docs/app/Examples/elements/List/Variations/ListDividedExample.js +++ b/docs/app/Examples/elements/List/Variations/ListDividedExample.js @@ -8,7 +8,7 @@ export default class ListDividedExample extends Component { const avatar2 = const avatar3 = return ( - + diff --git a/docs/app/Examples/elements/List/Variations/ListHorizontalExample.js b/docs/app/Examples/elements/List/Variations/ListHorizontalExample.js index 903fe308bb..5fdb8e5af0 100644 --- a/docs/app/Examples/elements/List/Variations/ListHorizontalExample.js +++ b/docs/app/Examples/elements/List/Variations/ListHorizontalExample.js @@ -8,7 +8,7 @@ export default class ListHorizontalExample extends Component { const image2 = const image3 = return ( - + diff --git a/docs/app/Examples/elements/List/Variations/ListInvertedExample.js b/docs/app/Examples/elements/List/Variations/ListInvertedExample.js index 91ee47b705..f23ec3e04d 100644 --- a/docs/app/Examples/elements/List/Variations/ListInvertedExample.js +++ b/docs/app/Examples/elements/List/Variations/ListInvertedExample.js @@ -5,7 +5,7 @@ export default class ListInvertedExample extends Component { render() { return ( - + diff --git a/docs/app/Examples/elements/List/Variations/ListRelaxedExample.js b/docs/app/Examples/elements/List/Variations/ListRelaxedExample.js index c57e7c38ce..b18abec5e3 100644 --- a/docs/app/Examples/elements/List/Variations/ListRelaxedExample.js +++ b/docs/app/Examples/elements/List/Variations/ListRelaxedExample.js @@ -8,7 +8,7 @@ export default class ListRelaxedExample extends Component { const avatar2 = const avatar3 = return ( - + diff --git a/docs/app/Examples/elements/List/Variations/ListSelectionExample.js b/docs/app/Examples/elements/List/Variations/ListSelectionExample.js index edcf26b3a5..086ae7a71f 100644 --- a/docs/app/Examples/elements/List/Variations/ListSelectionExample.js +++ b/docs/app/Examples/elements/List/Variations/ListSelectionExample.js @@ -8,7 +8,7 @@ export default class ListSelectionExample extends Component { const avatar2 = const avatar3 = return ( - + diff --git a/docs/app/Examples/elements/List/Variations/ListSizeBigExample.js b/docs/app/Examples/elements/List/Variations/ListSizeBigExample.js index f0794e8171..cbc1dc8f1a 100644 --- a/docs/app/Examples/elements/List/Variations/ListSizeBigExample.js +++ b/docs/app/Examples/elements/List/Variations/ListSizeBigExample.js @@ -8,7 +8,7 @@ export default class ListSizeBigExample extends Component { const christianAvatar = const danielAvatar = return ( - + diff --git a/docs/app/Examples/elements/List/Variations/ListSizeHugeExample.js b/docs/app/Examples/elements/List/Variations/ListSizeHugeExample.js index 7c22e2baa0..617b6825d6 100644 --- a/docs/app/Examples/elements/List/Variations/ListSizeHugeExample.js +++ b/docs/app/Examples/elements/List/Variations/ListSizeHugeExample.js @@ -8,7 +8,7 @@ export default class ListSizeHugeExample extends Component { const christianAvatar = const danielAvatar = return ( - + diff --git a/docs/app/Examples/elements/List/Variations/ListSizeLargeExample.js b/docs/app/Examples/elements/List/Variations/ListSizeLargeExample.js index ebe8364c3f..a35b16d426 100644 --- a/docs/app/Examples/elements/List/Variations/ListSizeLargeExample.js +++ b/docs/app/Examples/elements/List/Variations/ListSizeLargeExample.js @@ -8,7 +8,7 @@ export default class ListSizeLargeExample extends Component { const christianAvatar = const danielAvatar = return ( - + diff --git a/docs/app/Examples/elements/List/Variations/ListSizeMassiveExample.js b/docs/app/Examples/elements/List/Variations/ListSizeMassiveExample.js index 51be451dd3..943c7f8b73 100644 --- a/docs/app/Examples/elements/List/Variations/ListSizeMassiveExample.js +++ b/docs/app/Examples/elements/List/Variations/ListSizeMassiveExample.js @@ -8,7 +8,7 @@ export default class ListSizeMassiveExample extends Component { const christianAvatar = const danielAvatar = return ( - + diff --git a/docs/app/Examples/elements/List/Variations/ListSizeMediumExample.js b/docs/app/Examples/elements/List/Variations/ListSizeMediumExample.js new file mode 100644 index 0000000000..7ef7590947 --- /dev/null +++ b/docs/app/Examples/elements/List/Variations/ListSizeMediumExample.js @@ -0,0 +1,18 @@ +import React, { Component } from 'react' +import { List, Image } from 'stardust' +import faker from 'faker' + +export default class ListSizeLargeExample extends Component { + render() { + const helenAvatar = + const christianAvatar = + const danielAvatar = + return ( + + + + + + ) + } +} diff --git a/docs/app/Examples/elements/List/Variations/ListSizeMiniExample.js b/docs/app/Examples/elements/List/Variations/ListSizeMiniExample.js index c64118a255..4d48ba282f 100644 --- a/docs/app/Examples/elements/List/Variations/ListSizeMiniExample.js +++ b/docs/app/Examples/elements/List/Variations/ListSizeMiniExample.js @@ -8,7 +8,7 @@ export default class ListSizeMiniExample extends Component { const christianAvatar = const danielAvatar = return ( - + diff --git a/docs/app/Examples/elements/List/Variations/ListSizeSmallExample.js b/docs/app/Examples/elements/List/Variations/ListSizeSmallExample.js index d1592fd1c0..e5e2d1be88 100644 --- a/docs/app/Examples/elements/List/Variations/ListSizeSmallExample.js +++ b/docs/app/Examples/elements/List/Variations/ListSizeSmallExample.js @@ -8,7 +8,7 @@ export default class ListSizeSmallExample extends Component { const christianAvatar = const danielAvatar = return ( - + diff --git a/docs/app/Examples/elements/List/Variations/ListSizeTinyExample.js b/docs/app/Examples/elements/List/Variations/ListSizeTinyExample.js index 5ac87dfa14..8f438e90af 100644 --- a/docs/app/Examples/elements/List/Variations/ListSizeTinyExample.js +++ b/docs/app/Examples/elements/List/Variations/ListSizeTinyExample.js @@ -8,7 +8,7 @@ export default class ListSizeTinyExample extends Component { const christianAvatar = const danielAvatar = return ( - + diff --git a/docs/app/Examples/elements/List/Variations/ListVariationsExamples.js b/docs/app/Examples/elements/List/Variations/ListVariationsExamples.js index 20a436b02d..e0b269a9ab 100644 --- a/docs/app/Examples/elements/List/Variations/ListVariationsExamples.js +++ b/docs/app/Examples/elements/List/Variations/ListVariationsExamples.js @@ -57,6 +57,7 @@ export default class ListVariationsExamples extends Component { /> + diff --git a/docs/app/Examples/elements/List/Variations/ListVeryRelaxedExample.js b/docs/app/Examples/elements/List/Variations/ListVeryRelaxedExample.js index 18f6839238..e5d2e1cf24 100644 --- a/docs/app/Examples/elements/List/Variations/ListVeryRelaxedExample.js +++ b/docs/app/Examples/elements/List/Variations/ListVeryRelaxedExample.js @@ -9,7 +9,7 @@ export default class ListVeryRelaxedExample extends Component { const avatar3 = return ( - + diff --git a/src/elements/Content/Content.js b/src/elements/Content/Content.js new file mode 100644 index 0000000000..c96515be64 --- /dev/null +++ b/src/elements/Content/Content.js @@ -0,0 +1,33 @@ +import React, { PropTypes } from 'react' +import cx from 'classnames' +import META from '../../utils/Meta' + +function Content(props) { + const { + children, className, ...rest, + } = props + + const classes = cx( + 'content', + className + ) + + return ( +
{children}
+ ) +} + +Content._meta = { + name: 'Content', + type: META.type.element, +} + +Content.propTypes = { + /** Primary content of the List */ + children: PropTypes.node, + + /** Classes to add to the list className. */ + className: PropTypes.string, +} + +export default Content diff --git a/src/elements/Description/Description.js b/src/elements/Description/Description.js new file mode 100644 index 0000000000..bd1b307e3f --- /dev/null +++ b/src/elements/Description/Description.js @@ -0,0 +1,34 @@ +import React, { PropTypes } from 'react' +import cx from 'classnames' +import META from '../../utils/Meta' + +function Description(props) { + const { + children, className, ...rest, + } = props + + const classes = cx( + 'description', + className + ) + + return ( +
{children}
+ ) +} + +Description._meta = { + library: META.library.semanticUI, + name: 'Description', + type: META.type.element, +} + +Description.propTypes = { + /** Primary content of the List */ + children: PropTypes.node, + + /** Classes to add to the list className. */ + className: PropTypes.string, +} + +export default Description diff --git a/src/elements/Icon/Icon.js b/src/elements/Icon/Icon.js index 93bb7f61cf..e3b7c024da 100644 --- a/src/elements/Icon/Icon.js +++ b/src/elements/Icon/Icon.js @@ -16,8 +16,8 @@ export default class Icon extends Component { render() { const { className } = this.props const classes = cx( - className, 'icon', + className ) return ( diff --git a/src/elements/List/ItemHeader.js b/src/elements/List/ItemHeader.js new file mode 100644 index 0000000000..a57e23f55d --- /dev/null +++ b/src/elements/List/ItemHeader.js @@ -0,0 +1,38 @@ +import React, { PropTypes } from 'react' +import cx from 'classnames' +import META from '../../utils/Meta' + +/** + * I'm not sure a seperate file is necessary or if there's a better way. + * Also not sure this is where this file would go. + */ + +function ItemHeader(props) { + const { + children, className, ...rest, + } = props + + const classes = cx( + 'header', + className + ) + + return ( +
{children}
+ ) +} + +ItemHeader._meta = { + name: 'ItemHeader', + type: META.type.element, +} + +ItemHeader.propTypes = { + /** Primary content of the List */ + children: PropTypes.node, + + /** Classes to add to the list className. */ + className: PropTypes.string, +} + +export default ItemHeader diff --git a/src/elements/List/List.js b/src/elements/List/List.js index 4ded1341ea..a8e45cfa0c 100644 --- a/src/elements/List/List.js +++ b/src/elements/List/List.js @@ -1,32 +1,116 @@ -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 * as sui from '../../utils/semanticUtils' +import { + getUnhandledProps, + useValueAndKey, + useKeyOrValueAndKey, + useKeyOnly, +} from '../../utils/propUtils' import ListItem from './ListItem' +import Icon from '../Icon/Icon' +import Image from '../Image/Image' +import ItemHeader from './ItemHeader' +import Content from '../Content/Content' +import Description from '../Description/Description' -export default class List extends Component { - static propTypes = { - children: PropTypes.node, - className: PropTypes.string, - } - - static _meta = { - library: META.library.semanticUI, - name: 'List', - type: META.type.element, - } - - static Item = ListItem - - render() { - const classes = classNames( - 'ui', - this.props.className, - 'list' - ) - return ( -
- {this.props.children} -
- ) - } +function List(props) { + const { + size, aligned, bulleted, link, ordered, animated, celled, divided, + horizontal, inverted, relaxed, selection, children, className, + } = props + + const classes = cx( + 'ui', + size, + useValueAndKey(aligned, 'aligned'), + useKeyOnly(bulleted, 'bulleted'), + useKeyOnly(link, 'link'), + useKeyOnly(ordered, 'ordered'), + useKeyOnly(animated, 'animated'), + useKeyOnly(celled, 'celled'), + useKeyOnly(divided, 'divided'), + useKeyOnly(horizontal, 'horizontal'), + useKeyOnly(inverted, 'inverted'), + useKeyOrValueAndKey(relaxed, 'relaxed'), + useKeyOnly(selection, 'selection'), + 'list', + className + ) + + const rest = getUnhandledProps(List, props) + + return ( +
+ {children} +
+ ) +} + +List.Item = ListItem +List.ItemIcon = Icon +List.ItemImage = Image +List.ItemHeader = ItemHeader +List.ItemContent = Content +List.ItemDescription = Description + +List._meta = { + library: META.library.semanticUI, + name: 'List', + type: META.type.element, + props: { + size: sui.sizes, + aligned: sui.verticalAlignments, + relaxed: 'very', + }, +} + +List.propTypes = { + /** Primary content of the List */ + children: PropTypes.node, + + /** Classes to add to the list className. */ + className: PropTypes.string, + + /** List can be a variety of sizes */ + size: PropTypes.oneOf(List._meta.props.size), + + /** List can be aligned vertically top, middle, bottom */ + aligned: PropTypes.oneOf(List._meta.props.aligned), + + /** List can be bulleted */ + bulleted: PropTypes.bool, + + /** List can be formatted for navigation links */ + link: PropTypes.bool, + + /** List can be ordered numerically */ + ordered: PropTypes.bool, + + /** List can animate to set the current item apart from the list */ + animated: PropTypes.bool, + + /** List can divide its items into cells */ + celled: PropTypes.bool, + + /** List can show divisions between content */ + divided: PropTypes.bool, + + /** List can be formatted to have items appear horizontally */ + horizontal: PropTypes.bool, + + /** List can be inverted to appear on a dark background */ + inverted: PropTypes.bool, + + /** List can relax its padding to provide more negative space */ + relaxed: PropTypes.oneOf( + List._meta.props.relaxed, + PropTypes.bool + ), + + /** A selection list formats list items as possible choices */ + selection: PropTypes.bool, } + +export default List diff --git a/src/utils/semanticUtils.js b/src/utils/semanticUtils.js index b7b9544efd..02d395c018 100644 --- a/src/utils/semanticUtils.js +++ b/src/utils/semanticUtils.js @@ -15,4 +15,5 @@ export const colors = [ ] export const sizes = ['mini', 'tiny', 'small', 'medium', 'large', 'big', 'huge', 'massive'] export const textAlignments = ['left', 'center', 'right', 'justified'] +export const verticalAlignments = ['top', 'middle', 'bottom'] export const floats = ['left', 'right'] diff --git a/test/specs/elements/List/List-test.js b/test/specs/elements/List/List-test.js new file mode 100644 index 0000000000..074a36a4f3 --- /dev/null +++ b/test/specs/elements/List/List-test.js @@ -0,0 +1,34 @@ +import React from 'react' + +import List from 'src/elements/List/List' +import * as common from 'test/specs/commonTests' + +describe('List', () => { + common.isConformant(List) + common.rendersChildren(List) + common.hasUIClassName(List) + + common.propValueOnlyToClassName(List, 'size') + common.propKeyAndValueToClassName(List, 'aligned') + + common.propKeyOnlyToClassName(List, 'bulleted') + common.propKeyOnlyToClassName(List, 'link') + common.propKeyOnlyToClassName(List, 'ordered') + common.propKeyOnlyToClassName(List, 'animated') + common.propKeyOnlyToClassName(List, 'celled') + common.propKeyOnlyToClassName(List, 'divided') + common.propKeyOnlyToClassName(List, 'horizontal') + common.propKeyOnlyToClassName(List, 'inverted') + common.propKeyOnlyToClassName(List, 'selection') + + /** + * The correct test for 'relaxed' would be something that + * tests for useKeyOrValueAndKey which doesn't seem to be + * available. + */ + + it('renders a
element', () => { + shallow() + .should.have.tagName('div') + }) +})