-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
137 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './job-meta'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import cx from 'classnames'; | ||
|
||
import css from './job-meta.module.css'; | ||
|
||
export const JobMeta = (props) => { | ||
const { | ||
as: Component, className, meta, ...restProps | ||
} = props; | ||
|
||
const rootClassName = cx(css.root, className); | ||
|
||
return ( | ||
<Component className={rootClassName} {...restProps}> | ||
{meta.map(({ title, content }, index) => { | ||
const key = index; | ||
|
||
return ( | ||
<div className={css.item} key={key}> | ||
{title && (<h2 className={css.itemTitle}>{title}</h2>)} | ||
{content.map((item) => ( | ||
<>{item}</> | ||
))} | ||
</div> | ||
); | ||
})} | ||
</Component> | ||
); | ||
}; | ||
|
||
JobMeta.propTypes = { | ||
/** Adopted child class name */ | ||
className: PropTypes.string, | ||
|
||
/** Contrnt */ | ||
meta: PropTypes.arrayOf(PropTypes.shape({ | ||
title: PropTypes.oneOfType([PropTypes.string, PropTypes.element]), | ||
content: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.string, PropTypes.element])), | ||
})).isRequired, | ||
|
||
/** Render component */ | ||
as: PropTypes.oneOfType([PropTypes.string, PropTypes.element]), | ||
}; | ||
|
||
JobMeta.defaultProps = { | ||
className: '', | ||
as: 'div', | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
.root { | ||
padding: var(--space-xsmall) var(--space-small); | ||
display: flex; | ||
} | ||
|
||
.item { | ||
flex: 1 1 100%; | ||
} | ||
|
||
.itemTitle { | ||
margin: 0; | ||
font-size: 1em; | ||
font-weight: bold; | ||
color: var(--color-gray-light); | ||
} | ||
|
||
.item + .item { | ||
margin-left: var(--space-xsmall); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import React from 'react'; | ||
import { storiesOf } from '@storybook/react'; | ||
|
||
import { getWrapperDecorator } from '../../stories'; | ||
import { JobMeta } from '.'; | ||
|
||
const stories = storiesOf('Components/JobMeta', module); | ||
stories.addDecorator(getWrapperDecorator()); | ||
|
||
stories.add('default', () => ( | ||
<JobMeta | ||
meta={[ | ||
{ | ||
title: '#123', | ||
content: [ | ||
<p>July 3th </p>, | ||
], | ||
}, | ||
{ | ||
title: '#122', | ||
content: [ | ||
<p>July 4th</p>, | ||
], | ||
}, | ||
]} | ||
/> | ||
)); |