Skip to content
This repository has been archived by the owner on Mar 4, 2020. It is now read-only.

Commit

Permalink
feat(ItemLayout): added ItemLayout component (#60)
Browse files Browse the repository at this point in the history
* -added item layout component identical to the list item implementation

* -added changelog and fixed examples

* -added CSS props for the parts of the Item layout
-updated ListItem component to work with the ItemLayout

* -merging changes

* -fixed test

* -added end media to the examples containing knobs in the item layout component

* -fixed issue with the header item layout font size

* -moved styling from ItemLayout to ListItem
-removed important prop from ItemLayout

* -removed console logs

* -removed unused variables from the list item variables

* -removed some comments

* -ensuring proper propagating of the styles
  • Loading branch information
mnajdova authored and levithomason committed Aug 20, 2018
1 parent 74ffff2 commit bf5313b
Show file tree
Hide file tree
Showing 29 changed files with 617 additions and 141 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm

### Features
- Add `color` variables to Header and Header.Description @kuzhelov ([#72](https://github.com/stardust-ui/react/pull/72))
- Add `ItemLayout` component @mnajdova ([#60](https://github.com/stardust-ui/react/pull/60))

<!--------------------------------[ v0.2.6 ]------------------------------- -->
## [v0.2.6](https://github.com/stardust-ui/react/tree/v0.2.6) (2018-08-09)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import React from 'react'
import { ItemLayout } from '@stardust-ui/react'

const ItemLayoutExampleContent = () => (
<ItemLayout content="Program the sensor to the SAS alarm through the haptic SQL card!" />
)

export default ItemLayoutExampleContent
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import React from 'react'
import { ItemLayout } from '@stardust-ui/react'

const ItemLayoutExampleContentMediaShorthand = () => (
<ItemLayout
content="Program the sensor to the SAS alarm through the haptic SQL card!"
contentMedia="7:26:56 AM"
/>
)

export default ItemLayoutExampleContentMediaShorthand
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import React from 'react'
import { ItemLayout } from '@stardust-ui/react'

const ellipsis = <span>&hellip;</span>

const ItemLayoutExampleEndMediaShorthand = () => (
<ItemLayout
content="Program the sensor to the SAS alarm through the haptic SQL card!"
endMedia={ellipsis}
/>
)

export default ItemLayoutExampleEndMediaShorthand
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import React from 'react'
import { ItemLayout } from '@stardust-ui/react'

const ItemLayoutExampleHeader = () => <ItemLayout header="Irving Kuhic" />

export default ItemLayoutExampleHeader
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import React from 'react'
import { ItemLayout } from '@stardust-ui/react'

const ItemLayoutExampleHeaderContentShorthand = () => (
<ItemLayout
header="Irving Kuhic"
content="Program the sensor to the SAS alarm through the haptic SQL card!"
/>
)

export default ItemLayoutExampleHeaderContentShorthand
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import React from 'react'
import { ItemLayout } from '@stardust-ui/react'

const ItemLayoutExampleHeaderMediaShorthand = () => (
<ItemLayout header="Irving Kuhic" headerMedia="7:26:56 AM" />
)

export default ItemLayoutExampleHeaderMediaShorthand
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import React from 'react'
import { ItemLayout, Image } from '@stardust-ui/react'

const ItemLayoutExampleMediaShorthand = () => (
<ItemLayout
media={<Image src="public/images/avatar/small/nom.jpg" avatar />}
header="Dante Schneider"
headerMedia="5:22:40 PM"
content="The GB pixel is down, navigate the virtual interface!"
/>
)

export default ItemLayoutExampleMediaShorthand
45 changes: 45 additions & 0 deletions docs/src/examples/components/ItemLayout/Content/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import React from 'react'
import ComponentExample from 'docs/src/components/ComponentDoc/ComponentExample'
import ExampleSection from 'docs/src/components/ComponentDoc/ExampleSection'

const Content = () => (
<ExampleSection title="Content">
<ComponentExample
title="Content"
description="Item layout can contain content."
examplePath="components/ItemLayout/Content/ItemLayoutExampleContent"
/>
<ComponentExample
title="Header"
description="Item layout can contain a header."
examplePath="components/ItemLayout/Content/ItemLayoutExampleHeader"
/>
<ComponentExample
title="Header & Content"
description="Item layout can contain a header and content."
examplePath="components/ItemLayout/Content/ItemLayoutExampleHeaderContent"
/>
<ComponentExample
title="Media"
description="Item layout can contain a piece of media."
examplePath="components/ItemLayout/Content/ItemLayoutExampleMedia"
/>
<ComponentExample
title="Header Media"
description="Item layout can contain a header with its own media."
examplePath="components/ItemLayout/Content/ItemLayoutExampleHeaderMedia"
/>
<ComponentExample
title="Content Media"
description="Item layout can contain content with its own media."
examplePath="components/ItemLayout/Content/ItemLayoutExampleContentMedia"
/>
<ComponentExample
title="End Media"
description="Item layout can contain a piece of media at the end of the item."
examplePath="components/ItemLayout/Content/ItemLayoutExampleEndMedia"
/>
</ExampleSection>
)

export default Content
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import PropTypes from 'prop-types'
import React from 'react'

import Knobs from 'docs/src/components/Knobs/Knobs'

const LayoutExampleGapKnobs: any = props => {
const { onKnobChange, debug } = props

return (
<Knobs>
<Knobs.Boolean name="debug" value={debug} onChange={onKnobChange} />
</Knobs>
)
}

LayoutExampleGapKnobs.propTypes = {
onKnobChange: PropTypes.func.isRequired,
debug: PropTypes.bool,
}

LayoutExampleGapKnobs.defaultProps = {
debug: false,
}

export default LayoutExampleGapKnobs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import React from 'react'
import { ItemLayout, Image } from '@stardust-ui/react'

const ellipsis = <span>&hellip;</span>

const ItemLayoutExampleShorthand = ({ knobs }) => (
<ItemLayout
media={<Image src="public/images/avatar/small/matt.jpg" avatar />}
header="Irving Kuhic"
headerMedia="7:26:56 AM"
content="Program the sensor to the SAS alarm through the haptic SQL card!"
contentMedia="!!"
endMedia={ellipsis}
debug={knobs.debug}
/>
)

export default ItemLayoutExampleShorthand
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import PropTypes from 'prop-types'
import React from 'react'
import Knobs from 'docs/src/components/Knobs/Knobs'

const ItemLayoutExampleSelectionKnobs: any = props => {
const { onKnobChange, selection } = props

return (
<Knobs>
<Knobs.Boolean name="selection" value={selection} onChange={onKnobChange} />
</Knobs>
)
}

ItemLayoutExampleSelectionKnobs.propTypes = {
onKnobChange: PropTypes.func.isRequired,
selection: PropTypes.bool,
}

ItemLayoutExampleSelectionKnobs.defaultProps = {
selection: true,
}

export default ItemLayoutExampleSelectionKnobs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import React from 'react'
import { ItemLayout, Image } from '@stardust-ui/react'

const ItemLayoutExampleSelectionShorthand = ({ knobs }) => (
<ItemLayout
selection={knobs.selection}
media={<Image src="public/images/avatar/small/matt.jpg" avatar />}
header="Irving Kuhic"
headerMedia="7:26:56 AM"
content="Program the sensor to the SAS alarm through the haptic SQL card!"
/>
)

export default ItemLayoutExampleSelectionShorthand
20 changes: 20 additions & 0 deletions docs/src/examples/components/ItemLayout/Types/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import React from 'react'
import ComponentExample from 'docs/src/components/ComponentDoc/ComponentExample'
import ExampleSection from 'docs/src/components/ComponentDoc/ExampleSection'

const Types = () => (
<ExampleSection title="Types">
<ComponentExample
title="Default"
description="A default Item layout."
examplePath="components/ItemLayout/Types/ItemLayoutExample"
/>
<ComponentExample
title="Selection"
description="An item layout can be formatted to indicate that its items can be selected."
examplePath="components/ItemLayout/Types/ItemLayoutExampleSelection"
/>
</ExampleSection>
)

export default Types
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import PropTypes from 'prop-types'
import React from 'react'
import Knobs from 'docs/src/components/Knobs/Knobs'

const ItemLayoutExampleKnobs: any = props => {
const { onKnobChange, debug, truncateHeader, truncateContent, width } = props

return (
<Knobs>
<Knobs.Scalar name="width" value={width} onChange={onKnobChange} />
<Knobs.Boolean name="truncateHeader" value={truncateHeader} onChange={onKnobChange} />
<Knobs.Boolean name="truncateContent" value={truncateContent} onChange={onKnobChange} />
<Knobs.Boolean name="debug" value={debug} onChange={onKnobChange} />
</Knobs>
)
}

ItemLayoutExampleKnobs.propTypes = {
onKnobChange: PropTypes.func.isRequired,
debug: PropTypes.bool,
truncateContent: PropTypes.bool,
truncateHeader: PropTypes.bool,
width: PropTypes.string,
}

ItemLayoutExampleKnobs.defaultProps = {
debug: false,
truncateContent: true,
truncateHeader: true,
width: '25rem',
}

export default ItemLayoutExampleKnobs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import React from 'react'
import { ItemLayout, Image } from '@stardust-ui/react'

const ellipsis = <span>&hellip;</span>

const ItemLayoutExampleTruncateShorthand = ({ knobs }) => (
<div style={{ width: knobs.width }}>
<ItemLayout
debug={knobs.debug}
media={<Image src="public/images/avatar/small/nom.jpg" avatar />}
header="Dante Schneider - Super long title here"
headerMedia="5:22:40 PM"
content="The GB pixel is down, navigate the virtual interface!"
contentMedia="!!"
endMedia={ellipsis}
truncateHeader={knobs.truncateHeader}
truncateContent={knobs.truncateContent}
/>
</div>
)

export default ItemLayoutExampleTruncateShorthand
15 changes: 15 additions & 0 deletions docs/src/examples/components/ItemLayout/Variations/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import React from 'react'
import ComponentExample from 'docs/src/components/ComponentDoc/ComponentExample'
import ExampleSection from 'docs/src/components/ComponentDoc/ExampleSection'

const Variations = () => (
<ExampleSection title="Variations">
<ComponentExample
title="Truncate"
description="An item layout can truncate the header and content of items items."
examplePath="components/ItemLayout/Variations/ItemLayoutExampleTruncate"
/>
</ExampleSection>
)

export default Variations
14 changes: 14 additions & 0 deletions docs/src/examples/components/ItemLayout/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import React from 'react'
import Types from './Types'
import Content from './Content'
import Variations from './Variations'

const ItemLayoutExamples = () => (
<div>
<Types />
<Content />
<Variations />
</div>
)

export default ItemLayoutExamples
Loading

0 comments on commit bf5313b

Please sign in to comment.