Skip to content

Commit

Permalink
Add <Medallion /> component
Browse files Browse the repository at this point in the history
Component for displaying useful information alongside a label of some
form, usually inside a button
  • Loading branch information
Richard Palmer committed Apr 13, 2017
1 parent 630f269 commit 3dd58a5
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 0 deletions.
21 changes: 21 additions & 0 deletions components/Medallion/Medallion.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
.root {
border-radius: 4px;
display: inline-block;
box-sizing: border-box;
min-height: var(--size-regular);
line-height: var(--size-regular);
font-family: var(--font-avenir);
font-size: var(--size-sm-i);
text-align: center;
padding: var(--size-sm-iv) var(--size-sm-iii);
}

.light {
color: currentColor;
background-color: rgba(255, 255, 255, 0.2);
}

.dark {
color: currentColor;
background-color: rgba(0, 0, 0, 0.1);
}
29 changes: 29 additions & 0 deletions components/Medallion/Medallion.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import React, { PropTypes } from 'react';
import cx from 'classnames';

import css from './Medallion.css';

const Medallion = ({ className, variant, children, ...rest }) => (
<span
{ ...rest }
className={ cx(
css.root,
css[variant],
className,
) }
>
{ children }
</span>
);

Medallion.propTypes = {
className: PropTypes.string,
children: PropTypes.string,
variant: PropTypes.oneOf(['light', 'dark']),
};

Medallion.defaultProps = {
variant: 'light',
};

export default Medallion;
14 changes: 14 additions & 0 deletions components/Medallion/Medallion.story.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import React from 'react';
import { storiesOf } from '@kadira/storybook';
import { withKnobs, number } from '@kadira/storybook-addon-knobs';
import Medallion from './Medallion';

const stories = storiesOf('Medallion', module);
stories.addDecorator(withKnobs);

stories.add('Light Medallion', () => (
<Medallion>{ number('children', 2) }</Medallion>
))
.add('Dark Medallion', () => (
<Medallion variant="dark">{ number('children', 2) }</Medallion>
));
9 changes: 9 additions & 0 deletions components/Medallion/Medallion.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import React from 'react';
import { render } from 'react-dom';

import Medallion from './Medallion';

it('renders without crashing', () => {
const div = document.createElement('div');
render(<Medallion>label</Medallion>, div);
});

0 comments on commit 3dd58a5

Please sign in to comment.