-
Notifications
You must be signed in to change notification settings - Fork 7
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
Resources component #77
base: master
Are you sure you want to change the base?
Changes from 16 commits
3c5aece
0d3bbe4
937a172
a4f8219
a9046c8
3f8f976
29f3b78
b7ecd35
f5600b2
8373318
d2864ff
18a7a8c
abf301d
61a8469
90ea799
f55ed33
47f1f15
738fe15
87a0959
ca73d6a
18167cb
18d8d51
72bb030
c74d9ea
ad60d1d
3e71a8c
370e772
ead2d0e
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,79 @@ | ||
// (C) Copyright 2014-2015 Hewlett Packard Enterprise Development LP | ||
|
||
var React = require('react'); | ||
var jsxToString = require('jsx-to-string'); | ||
var DocsArticle = require('../../DocsArticle'); | ||
var Resources = require('../../modules/Resources'); | ||
|
||
Resources.displayName = 'Resources'; | ||
|
||
var inline = "<Resources ... />"; | ||
|
||
var ResourcesDoc = React.createClass({ | ||
|
||
contextTypes: { | ||
routePrefix: React.PropTypes.string.isRequired | ||
}, | ||
|
||
_renderCode(name, jsx) { | ||
return ( | ||
<div> | ||
<h3>{name}</h3> | ||
<div className="example"> | ||
{jsx} | ||
</div> | ||
<pre><code className="html hljs xml"> | ||
{jsxToString(jsx)} | ||
</code></pre> | ||
</div> | ||
); | ||
}, | ||
|
||
render: function() { | ||
var simpleResources = ( | ||
<Resources | ||
tiles={[ | ||
{ | ||
thumbnail: '/docs/img/resource-img-1.png', | ||
title: 'Brochure', | ||
description: 'Enable workplace productivity HPE Transformation Workshop' | ||
}, | ||
{ | ||
thumbnail: '/docs/img/resource-img-2.png', | ||
title: 'Solution Brief', | ||
description: 'Digital Context Aware Solutions' | ||
}, | ||
{ | ||
thumbnail: '/docs/img/resource-img-3.png', | ||
title: 'Video -1:41', | ||
description: 'Real Academia de Bellas Artes Ehances Experience with Mobile App' | ||
} | ||
]} | ||
/> | ||
); | ||
|
||
return ( | ||
<DocsArticle title="Resources" colorIndex="neutral-3"> | ||
|
||
<p>The Resources module.</p> | ||
<pre><code className="html hljs xml">{inline}</code></pre> | ||
|
||
<section> | ||
<h2>Resources Options</h2> | ||
<dl> | ||
<dt><code>tiles {`[{thumbnail: , title: , description: }, ...]`}</code></dt> | ||
<dd>An array of resource tiles.</dd> | ||
</dl> | ||
</section> | ||
|
||
<section> | ||
<h2>Examples</h2> | ||
|
||
{this._renderCode('Default', simpleResources)} | ||
</section> | ||
</DocsArticle> | ||
); | ||
} | ||
}); | ||
|
||
module.exports = ResourcesDoc; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
// (C) Copyright 2014-2015 Hewlett Packard Enterprise Development LP | ||
|
||
import React, { Component, PropTypes } from 'react'; | ||
import classnames from 'classnames'; | ||
import Box from 'grommet/components/Box'; | ||
import Heading from 'grommet/components/Heading'; | ||
import Tiles from 'grommet/components/Tiles'; | ||
import Paragraph from 'grommet/components/Paragraph'; | ||
import ResourcesTile from './ResourcesTile'; | ||
|
||
const CLASS_ROOT = 'resources'; | ||
|
||
export default class Resources extends Component { | ||
render () { | ||
const { header, subHeader, tiles } = this.props; | ||
|
||
const classes = classnames( | ||
CLASS_ROOT, | ||
this.props.className | ||
); | ||
|
||
let subHeaderMarkup; | ||
if (subHeader) { | ||
subHeaderMarkup = ( | ||
<Paragraph className={`${CLASS_ROOT}__subheader`} size="large"> | ||
{subHeader} | ||
</Paragraph> | ||
); | ||
} | ||
|
||
const resourceTiles = tiles.map((tile, key) => { | ||
return <ResourcesTile key={key} {...tile} />; | ||
}); | ||
|
||
return ( | ||
<Box className={classes} pad={{vertical: 'medium'}}> | ||
<Heading tag="h3">{header}</Heading> | ||
{subHeaderMarkup} | ||
<Tiles flush={false} pad="none"> | ||
{resourceTiles} | ||
</Tiles> | ||
</Box> | ||
); | ||
} | ||
}; | ||
|
||
Resources.propTypes = { | ||
header: PropTypes.string, | ||
subHeader: PropTypes.string, | ||
tiles: PropTypes.arrayOf(PropTypes.shape({ | ||
thumbnail: PropTypes.string, | ||
title: PropTypes.string, | ||
description: PropTypes.string | ||
})).isRequired | ||
}; | ||
|
||
Resources.defaultProps = { | ||
header: 'Resources' | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// (C) Copyright 2014-2015 Hewlett Packard Enterprise Development LP | ||
|
||
import React, { Component, PropTypes } from 'react'; | ||
import classnames from 'classnames'; | ||
import Box from 'grommet/components/Box'; | ||
import Heading from 'grommet/components/Heading'; | ||
import Tile from 'grommet/components/Tile'; | ||
import Paragraph from 'grommet/components/Paragraph'; | ||
|
||
const CLASS_ROOT = 'resources-tile'; | ||
|
||
export default class ResourcesTile extends Component { | ||
render () { | ||
const { thumbnail, title, description } = this.props; | ||
|
||
const classes = classnames( | ||
CLASS_ROOT, | ||
this.props.className | ||
); | ||
|
||
const thumbnailStyles = { | ||
backgroundImage: `url(${thumbnail})` | ||
}; | ||
|
||
return ( | ||
<Tile className={classes} direction="row" responsive={false} align="start"> | ||
<Box | ||
className={`${CLASS_ROOT}__thumbnail`} | ||
style={thumbnailStyles} | ||
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. You should be able to use the |
||
flex={false} | ||
/> | ||
<Box pad={{horizontal: 'medium', vertical: 'small'}}> | ||
<Heading tag="h6" margin="none" uppercase={true}>{title}</Heading> | ||
<Paragraph margin="none">{description}</Paragraph> | ||
</Box> | ||
</Tile> | ||
); | ||
} | ||
}; | ||
|
||
ResourcesTile.propTypes = { | ||
title: PropTypes.string.isRequired, | ||
description: PropTypes.string.isRequired, | ||
thumbnail: PropTypes.string.isRequired | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
.resources-tile { | ||
background-color: #fff; | ||
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. Try to always use Grommet variables for colors, such as |
||
|
||
&__thumbnail { | ||
width: 100px; | ||
height: 100px; | ||
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. Is it possible to use an existing Grommet variable for these, such as |
||
} | ||
|
||
.heading--uppercase { | ||
letter-spacing: normal; | ||
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 noticed that you're overriding the letter-spacing for the uppercase heading in several places. Is this something that has been discussed with the designers? In the long run, I think it would be preferable to either get the designers to agree to the existing letter-spacing as it currently is on Grommet, or talk to them about getting the existing letter-spacing style removed from Grommet, so we're not ending up with inconsistencies between the toolkit and any other Grommet elements that could hypothetically be used on the same page. 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. Checking in with Eric on this one. |
||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
.resources { | ||
|
||
&__subheader.paragraph { | ||
margin-top: 0; | ||
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. If you wrap the |
||
} | ||
|
||
.tiles { | ||
@include media-query(lap-and-up) { | ||
margin: -12px; | ||
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. Can you use |
||
|
||
> .tile { | ||
flex-basis: 411px; | ||
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 have a feeling the Grommet core team will question this, since this seems like a really odd size. Even if none of the existing Grommet size variables work for this, is it possible for this to be a multiple of |
||
} | ||
} | ||
} | ||
} |
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.
Can we list out the ResourcesTile's options here in details, similar to how the Tags/Tag components documentation in Grommet core?