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

Commit

Permalink
Merge pull request #186 from Tripwire/fix/large-card
Browse files Browse the repository at this point in the history
fix(LargeCard): document Gutter
  • Loading branch information
cdaringe authored Apr 30, 2018
2 parents cadfa6d + 2ade22f commit d6343b9
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 6 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 16 additions & 0 deletions src/components/native/LargeCard/LargeCardGutter.examples.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#### Large Card Gutters

```js
<div style={{height: '150px'}}>
<LargeCard showCard>
{/* preferred - use a constant */}
<LargeCard.Gutter color={LargeCard.Gutter.STATE_COLOR_MAP.CRITICAL} />
<LargeCard.Gutter color={LargeCard.Gutter.STATE_COLOR_MAP.WARNING} />
<LargeCard.Gutter color={LargeCard.Gutter.STATE_COLOR_MAP.NORMAL} />
{/* not preferred - avoid picking your own colors */}
<LargeCard.Gutter color='salmon' />
<LargeCard.Gutter color='#efefef' />
<LargeCard.Gutter color='#abc' />
</LargeCard>
</div>
```
25 changes: 19 additions & 6 deletions src/components/native/LargeCard/LargeCardGutter.jsx
Original file line number Diff line number Diff line change
@@ -1,22 +1,29 @@
import Flexbox from 'flexbox-react'
import React from 'react'
import palette from '../../../palette'
import PropTypes from 'prop-types'
import filterAttributesFromProps from '../../../util/externalAttributeFilter'

const STATE_COLOR_MAP = {
CRITICAL: 'critical',
WARNING: 'warning',
NORMAL: 'normal',
BLUE: 'blue' // @deprecated
}
const LargeCardGutter = (props) => {
const externalAttributes = filterAttributesFromProps(props)
let color = ''
switch (props.color) {
case 'critical':
case STATE_COLOR_MAP.CRITICAL:
color = palette.red
break
case 'warning':
case STATE_COLOR_MAP.WARNING:
color = palette.yellow
break
case 'normal':
case STATE_COLOR_MAP.NORMAL:
color = palette.blue
break
case 'blue':
case STATE_COLOR_MAP.BLUE:
color = palette.blue
break
default:
Expand All @@ -25,7 +32,7 @@ const LargeCardGutter = (props) => {
return (
<Flexbox
{...externalAttributes}
className={`fullview__left_border ${props.className}`}
className={`fullview__left_border ${props.className || ''}`}
width='9px'
style={{ backgroundColor: color }} />
)
Expand All @@ -36,7 +43,13 @@ LargeCardGutter.defaultProps = {
}

LargeCardGutter.propTypes = {

/** color of gutter. use `LargeCardGutter.STATE_COLOR_MAP` or any standard web color string */
color: PropTypes.oneOf(
Object.values(STATE_COLOR_MAP).concat(
PropTypes.string
)
)
}
LargeCardGutter.STATE_COLOR_MAP = STATE_COLOR_MAP

export default LargeCardGutter

0 comments on commit d6343b9

Please sign in to comment.