-
Notifications
You must be signed in to change notification settings - Fork 4k
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
feat(List): update to v1 API #311
Changes from 1 commit
6197943
6c7a3d6
959aff4
e1f7042
0906e78
5d071df
fdd3113
268c3c8
1e86005
7e24d28
1bd5965
681fa30
057be3a
d83a3c0
202a8b9
cd7171d
bf48ba3
f9ddcd0
8245887
5b6519f
4e7f6c9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 ( | ||
<div className={classes} {...rest}>{children}</div> | ||
) | ||
} | ||
|
||
Content._meta = { | ||
name: 'Content', | ||
type: META.type.element, | ||
} | ||
|
||
Content.propTypes = { | ||
/** Primary content of the List */ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I realize my comment says List while it should say Content. I've noticed the typos in the Content and Description files and will fix. |
||
children: PropTypes.node, | ||
|
||
/** Classes to add to the list className. */ | ||
className: PropTypes.string, | ||
} | ||
|
||
export default Content |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 ( | ||
<div className={classes} {...rest}>{children}</div> | ||
) | ||
} | ||
|
||
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 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 ( | ||
<div className={classes} {...rest}>{children}</div> | ||
) | ||
} | ||
|
||
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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we want this file? Is this where it should be placed or perhaps under views/Item? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've left an analysis and proposal for "component parts" on this PR itself: https://github.com/TechnologyAdvice/stardust/pull/311#issuecomment-231006785 |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,11 @@ import { | |
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' | ||
|
||
function List(props) { | ||
const { | ||
|
@@ -44,6 +49,11 @@ function List(props) { | |
} | ||
|
||
List.Item = ListItem | ||
List.ItemIcon = Icon | ||
List.ItemImage = Image | ||
List.ItemHeader = ItemHeader | ||
List.ItemContent = Content | ||
List.ItemDescription = Description | ||
|
||
List._meta = { | ||
library: META.library.semanticUI, | ||
|
@@ -52,6 +62,7 @@ List._meta = { | |
props: { | ||
size: sui.sizes, | ||
aligned: sui.verticalAlignments, | ||
relaxed: 'very', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just a fix from an unrelated previous omission. It can either be a string (i.e. very) or a plain Boolean. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Correct, this should be an array though. relaxed: ['very'] |
||
}, | ||
} | ||
|
||
|
@@ -93,7 +104,10 @@ List.propTypes = { | |
inverted: PropTypes.bool, | ||
|
||
/** List can relax its padding to provide more negative space */ | ||
relaxed: PropTypes.bool, | ||
relaxed: PropTypes.oneOf( | ||
List._meta.props.relaxed, | ||
PropTypes.bool | ||
), | ||
|
||
/** A selection list formats list items as possible choices */ | ||
selection: PropTypes.bool, | ||
|
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.
When there is no image/icon do we want to require ItemContent? The current ListItem file suggests no.
ListItem.js:
if (media) content = <div className='content'>{content}</div>
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.
Correct, no content when there is no icon/image. Reference the SUI docs for the exact markup.
http://semantic-ui.com/elements/list
In the case of the Item view, adding content with no icon/image will actually break the vertically aligned variations.