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

Container Component updated to v1 API #277

Merged
merged 24 commits into from
Jun 26, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
27dc01c
Container Component updated to v1 API
jhchill666 Jun 24, 2016
a5441e5
Fixes lint errors
jhchill666 Jun 24, 2016
7631a91
Merge branch 'master' into feature/container
jhchill666 Jun 24, 2016
d64f2b2
eslint-disable max-len for long example paragraphs
jhchill666 Jun 24, 2016
84f9f53
eslint-disable max-len for long example paragraphs
jhchill666 Jun 24, 2016
9e2d9b4
Merge remote-tracking branch 'origin/feature/container' into feature/…
jhchill666 Jun 24, 2016
06fde8b
fixes lint errors
jhchill666 Jun 24, 2016
724759a
Function name amended to match Class name
jhchill666 Jun 24, 2016
bd4b8de
Function name amended to match Class name
jhchill666 Jun 24, 2016
241a022
Message relocated from example component to examples container
jhchill666 Jun 24, 2016
f420da9
<h2> element replaced with Stardust Header.H2
jhchill666 Jun 24, 2016
a083fd5
Message relocated from example component to examples container
jhchill666 Jun 24, 2016
bd628e3
Redundant ContainerComponent element removed in favour of tag inline
jhchill666 Jun 24, 2016
77b4bb5
Removes redundant Container class check - handled in base tests
jhchill666 Jun 24, 2016
0d50e12
Alignment constrained to alignment prop
jhchill666 Jun 24, 2016
edf673a
[Test] Alignment constrained to alignment prop
jhchill666 Jun 24, 2016
9bb4509
fixes lint errors
jhchill666 Jun 25, 2016
f31fe72
Merge branch 'master' into feature/container
jhchill666 Jun 25, 2016
ad81023
Image Component updated to v1 API
jhchill666 Jun 24, 2016
6330ca0
Image Component updated to v1 API
jhchill666 Jun 24, 2016
f2781cd
Merge branch 'master' into feature/container
jhchill666 Jun 26, 2016
2366b67
Implements useAlignedProp / common.implementAlignProp
jhchill666 Jun 26, 2016
8863f6d
Merge remote-tracking branch 'origin/feature/container' into feature/…
jhchill666 Jun 26, 2016
28f6d7f
Fixes lint errors
jhchill666 Jun 26, 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
14 changes: 14 additions & 0 deletions docs/app/Examples/elements/Container/ContainerExamples.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import React, { Component } from 'react'
import ContainerTypesExamples from './Types/ContainerTypesExamples'
import ContainerVariationsExamples from './Variations/ContainerVariationsExamples'

export default class ContainerExamples extends Component {
render() {
return (
<div>
<ContainerTypesExamples />
<ContainerVariationsExamples />
</div>
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/* eslint-disable max-len */

import React, { Component } from 'react'
import { Container } from 'stardust'

export default class ContainerContainerExample extends Component {
render() {
return (
<Container>
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa strong. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo. Nullam dictum felis eu pede link mollis pretium. Integer tincidunt. Cras dapibus. Vivamus elementum semper nisi. Aenean vulputate eleifend tellus. Aenean leo ligula, porttitor eu, consequat vitae, eleifend ac, enim. Aliquam lorem ante, dapibus in, viverra quis, feugiat a, tellus. Phasellus viverra nulla ut metus varius laoreet. Quisque rutrum. Aenean imperdiet. Etiam ultricies nisi vel augue. Curabitur ullamcorper ultricies nisi.</p>
</Container>
)
}
}
16 changes: 16 additions & 0 deletions docs/app/Examples/elements/Container/Types/ContainerTextExample.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/* eslint-disable max-len */

import React, { Component } from 'react'
import ComponentExample from 'docs/app/Components/ComponentDoc/ComponentExample'
import ExampleSection from 'docs/app/Components/ComponentDoc/ExampleSection'
import { Message } from 'stardust'

export default class ContainerTypesExamples extends Component {
render() {
return (
<ExampleSection title='Types'>
<ComponentExample
title='Container'
description='A standard container'
examplePath='elements/Container/Types/ContainerContainerExample'
/>
<ComponentExample
title='Text Container'
description='A container can reduce its maximum width to more naturally accomodate a single column of text'
examplePath='elements/Container/Types/ContainerTextExample'
>
<Message className='info'>
<p>A text container is a simpler markup alternative to using a grid with a single column, and is designed to have a reasonable maximum width for displaying flowing text</p>
</Message>
</ComponentExample>
</ExampleSection>
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/* eslint-disable max-len */

import React, { Component } from 'react'
import { Container, Divider } from 'stardust'

export default class ContainerAlignmentExample extends Component {
render() {
return (
<div>
<Container aligned='left'>
Left Aligned
</Container>
<Container aligned='center'>
Center Aligned
</Container>
<Container aligned='right'>
Right Aligned
</Container>
<Container aligned='justified'>
<b>Justified</b>
<Divider />
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa strong. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo. Nullam dictum felis eu pede link mollis pretium. Integer tincidunt. Cras dapibus. Vivamus elementum semper nisi. Aenean vulputate eleifend tellus. Aenean leo ligula, porttitor eu, consequat vitae, eleifend ac, enim. Aliquam lorem ante, dapibus in, viverra quis, feugiat a, tellus. Phasellus viverra nulla ut metus varius laoreet. Quisque rutrum. Aenean imperdiet. Etiam ultricies nisi vel augue. Curabitur ullamcorper ultricies nisi.</p>
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa strong. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo. Nullam dictum felis eu pede link mollis pretium. Integer tincidunt. Cras dapibus. Vivamus elementum semper nisi. Aenean vulputate eleifend tellus. Aenean leo ligula, porttitor eu, consequat vitae, eleifend ac, enim. Aliquam lorem ante, dapibus in, viverra quis, feugiat a, tellus. Phasellus viverra nulla ut metus varius laoreet. Quisque rutrum. Aenean imperdiet. Etiam ultricies nisi vel augue. Curabitur ullamcorper ultricies nisi.</p>
</Container>
</div>

)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/* eslint-disable max-len */

import React, { Component } from 'react'
import { Container, Header } from 'stardust'

export default class ContainerFluidExample extends Component {
render() {
return (
<div>
<Container fluid>
<Header.H2>Dogs Roles with Humans</Header.H2>
<p>Domestic dogs inherited complex behaviors, such as bite inhibition, from their wolf ancestors, which would have been pack hunters with complex body language. These sophisticated forms of social cognition and communication may account for their trainability, playfulness, and ability to fit into human households and social situations, and these attributes have given dogs a relationship with humans that has enabled them to become one of the most successful species on the planet today.</p>
<p>The dogs' value to early human hunter-gatherers led to them quickly becoming ubiquitous across world cultures. Dogs perform many roles for people, such as hunting, herding, pulling loads, protection, assisting police and military, companionship, and, more recently, aiding handicapped individuals. This impact on human society has given them the nickname "man's best friend" in the Western world. In some cultures, however, dogs are also a source of meat.</p>
</Container>
</div>

)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/* eslint-disable max-len */

import React, { Component } from 'react'
import ComponentExample from 'docs/app/Components/ComponentDoc/ComponentExample'
import ExampleSection from 'docs/app/Components/ComponentDoc/ExampleSection'
import { Message } from 'stardust'

export default class ContainerVariationsExamples extends Component {
render() {
return (
<ExampleSection title='Variations'>
<ComponentExample
title='Text Alignment'
description='A container can specify its text alignment'
examplePath='elements/Container/Variations/ContainerAlignmentExample'
/>
<ComponentExample
title='Fluid'
description='A fluid container has no maximum width'
examplePath='elements/Container/Variations/ContainerFluidExample'
>
<Message className='info'>
Fluid containers are useful for setting text alignment, or other variations on unstyled content
</Message>
</ComponentExample>
</ExampleSection>
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import ExampleSection from 'docs/app/Components/ComponentDoc/ExampleSection'
export default class DividerVariationsExamples extends Component {
render() {
return (
<ExampleSection title='Types'>
<ExampleSection title='Variations'>
<ComponentExample
title='Inverted'
description='A divider can have its colors inverted'
Expand Down
87 changes: 58 additions & 29 deletions src/elements/Container/Container.js
Original file line number Diff line number Diff line change
@@ -1,33 +1,62 @@
import React, { Component, PropTypes } from 'react'
import classNames from 'classnames'
import META from '../../utils/Meta'
import cx from 'classnames'
import React, { PropTypes } from 'react'
import META from '../../utils/Meta';
import {
getUnhandledProps,
useAlignedProp,
useKeyOnly,
} from '../../utils/propUtils'

/**
* A container that gives your content some side padding.
* A container limits content to a maximum width
*/
export default class Container extends Component {
static propTypes = {
children: PropTypes.node,
className: PropTypes.string,
}

static _meta = {
library: META.library.semanticUI,
name: 'Container',
type: META.type.element,
}

render() {
const classes = classNames(
'sd-container',
'ui',
this.props.className,
'container',
)
return (
<div {...this.props} className={classes}>
{this.props.children}
</div>
)
}
function Container(props) {
const {
text, aligned, fluid,
children, className,
} = props

const classes = cx('sd-container ui',
useKeyOnly(text, 'text'),
useAlignedProp(aligned),
useKeyOnly(fluid, 'fluid'),
'container',
className
)

const rest = getUnhandledProps(Container, props)

return (
<div className={classes} {...rest}>
{children}
</div>
)
}

Container._meta = {
library: META.library.semanticUI,
name: 'Container',
type: META.type.element,
props: {
aligned: ['left', 'center', 'right', 'justified'],
},
}

Container.propTypes = {
/** Primary content of the Container */
children: PropTypes.node,

/** Classes to add to the container className. */
className: PropTypes.string,

/** Reduce maximum width to more naturally accomodate text */
text: PropTypes.bool,

/** Align container content to left */
aligned: PropTypes.oneOf(Container._meta.props.aligned),

/** Container has no maximum with */
fluid: PropTypes.bool,
}

export default Container
20 changes: 20 additions & 0 deletions test/specs/elements/Container/Container-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import React from 'react'

import Container from 'src/elements/Container/Container'
import * as common from 'test/specs/commonTests'

describe('Container', () => {
common.isConformant(Container)
common.rendersChildren(Container)
common.hasUIClassName(Container)

common.propKeyOnlyToClassName(Container, 'text')
common.propKeyOnlyToClassName(Container, 'fluid')

common.implementsAlignedProp(Container)

it('renders a <div /> element', () => {
shallow(<Container />)
.should.have.tagName('div')
})
})