Skip to content
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

Open
wants to merge 28 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
3c5aece
Merge branch 'master' into resources
epilande Jun 14, 2016
0d3bbe4
Set up Resource component
epilande Jun 15, 2016
937a172
Set up Resource Tile component
epilande Jun 15, 2016
a4f8219
Display thumbnail & add responsive styles
epilande Jun 15, 2016
a9046c8
Remove padding on Tiles
epilande Jun 15, 2016
3f8f976
Update example to use thumbnails from design
epilande Jun 15, 2016
29f3b78
Uppercase resource title
epilande Jun 15, 2016
b7ecd35
Fix spacing with subheader
epilande Jun 15, 2016
f5600b2
Merge branch 'master' into resources
epilande Jun 15, 2016
8373318
Change thumbnail prop to take URL
epilande Jun 15, 2016
d2864ff
Add Resources doc page
epilande Jun 15, 2016
18a7a8c
Add white background to resource tile
epilande Jun 15, 2016
abf301d
Merge branch 'master' into resources
epilande Jun 22, 2016
61a8469
Update examples, move Resources into accordion
epilande Jun 22, 2016
90ea799
Fix spacing issue with resource tile
epilande Jun 22, 2016
f55ed33
Fix typo
epilande Jun 22, 2016
47f1f15
Add ResourcesTile option docs
epilande Jun 23, 2016
738fe15
Set backgroundImage prop on box instead of inline style
epilande Jun 24, 2016
87a0959
Remove custom resources subheader style
epilande Jun 24, 2016
ca73d6a
Use existing Grommet variables
epilande Jun 24, 2016
18167cb
Merge branch 'master' into resources
epilande Jun 30, 2016
18d8d51
Merge branch 'master' into resources
epilande Aug 17, 2016
72bb030
Fix linting error & spacing issues
epilande Aug 17, 2016
c74d9ea
Merge branch 'master' into resources
epilande Aug 18, 2016
ad60d1d
Merge branch 'master' into resources
epilande Aug 18, 2016
3e71a8c
Handle resource tile click
epilande Aug 18, 2016
370e772
Update example & docs page
epilande Aug 18, 2016
ead2d0e
Add link to docs
epilande Aug 18, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/develop/Develop.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ var MarqueeDoc = require('./components/MarqueeDoc');
var WorldMapDoc = require('./components/WorldMapDoc');
var AccordionDoc = require('./components/AccordionDoc');
var CalloutDoc = require('./components/CalloutDoc');
var ResourcesDoc = require('./components/ResourcesDoc');

//hjjs configuration
var hljs = require('highlight.js/lib/highlight');
Expand Down Expand Up @@ -51,6 +52,7 @@ var CONTENTS = [
{route: 'develop_marquee', label: 'Marquee', component: MarqueeDoc},
{route: 'develop_accordion', label: 'Accordion', component: AccordionDoc},
{route: 'develop_callout', label: 'Callout', component: CalloutDoc},
{route: 'develop_resources', label: 'Resources', component: ResourcesDoc},
{route: 'develop_world-map', label: 'WorldMap', component: WorldMapDoc}
]
}
Expand Down
79 changes: 79 additions & 0 deletions src/develop/components/ResourcesDoc.js
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>
Copy link
Contributor

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?

<h2>Examples</h2>

{this._renderCode('Default', simpleResources)}
</section>
</DocsArticle>
);
}
});

module.exports = ResourcesDoc;
24 changes: 22 additions & 2 deletions src/examples/Examples.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ var PlayIcon = require('grommet/components/icons/base/Play');
var Heading = require('grommet/components/Heading');
var Paragraph = require('grommet/components/Paragraph');
var Marquee = require('../modules/Marquee');
var Callout = require('../modules/Callout');
var Accordion = require('../modules/Accordion');
var AccordionPanel = require('../modules/AccordionPanel');
var Callout = require('../modules/Callout');
var Resources = require('../modules/Resources');
var Header = require('./Header');

var Examples = React.createClass({
Expand Down Expand Up @@ -111,8 +112,27 @@ var Examples = React.createClass({
linkIcon={<PlayIcon />}
linkText="Watch Now"
/>
<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'
}
]}
/>
</AccordionPanel>
<AccordionPanel panelTitle="Software Licensings and Managment">
<AccordionPanel panelTitle="Software Licensings and Management">
<Heading tag="h3" margin="none">
Manage control, compliance and cost through our value-added
Licensing, Advisory Services and Software Asset Management.
Expand Down
Binary file added src/img/resource-img-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/img/resource-img-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/img/resource-img-3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
59 changes: 59 additions & 0 deletions src/modules/Resources.js
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'
};
45 changes: 45 additions & 0 deletions src/modules/ResourcesTile.js
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}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should be able to use the backgroundImage property to add the background image, instead of using inline styles.

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
};
4 changes: 3 additions & 1 deletion src/scss/_objects.callout.scss
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
}

&__content {
max-width: $size-small;
@include media-query(lap-and-up) {
max-width: $size-small;
}
}

.heading--uppercase {
Expand Down
2 changes: 2 additions & 0 deletions src/scss/_objects.modules.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
@import 'objects.accordion';
@import 'objects.accordion-panel';
@import 'objects.callout';
@import 'objects.resources';
@import 'objects.resources-tile';

.grommet.app {
position: relative;
Expand Down
12 changes: 12 additions & 0 deletions src/scss/_objects.resources-tile.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
.resources-tile {
background-color: #fff;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Try to always use Grommet variables for colors, such as $background-color here.


&__thumbnail {
width: 100px;
height: 100px;
Copy link
Contributor

Choose a reason for hiding this comment

The 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 $graphic-small-size (96px)?

}

.heading--uppercase {
letter-spacing: normal;
Copy link
Contributor

Choose a reason for hiding this comment

The 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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checking in with Eric on this one.

}
}
16 changes: 16 additions & 0 deletions src/scss/_objects.resources.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
.resources {

&__subheader.paragraph {
margin-top: 0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you wrap the Heading and .resources__subheader in a div, I believe you shouldn't need this style.

}

.tiles {
@include media-query(lap-and-up) {
margin: -12px;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you use halve($inuit-base-spacing-unit) here?


> .tile {
flex-basis: 411px;
Copy link
Contributor

Choose a reason for hiding this comment

The 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 $inuit-base-spacing-unit, at least?

}
}
}
}