Skip to content

Commit 261ee02

Browse files
authored
[CHORE] Add green pill component (#53)
Also adds a 'squared' prop to make the pill have sharper corners.
1 parent 5026564 commit 261ee02

File tree

3 files changed

+26
-9
lines changed

3 files changed

+26
-9
lines changed

src/Pill/Pill.jsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@ import classNames from 'classnames';
44

55
import './Pill.scss';
66

7-
const Pill = ({ color, size, text }) => (
7+
const Pill = ({ color, size, squared, text }) => (
88
<div
99
className={
1010
classNames(
1111
'Pill',
12+
{ 'Pill--squared': squared },
1213
{ [`Pill--${color}`]: !!color },
1314
{ [`Pill--${size}`]: !!size },
1415
)
@@ -21,12 +22,14 @@ const Pill = ({ color, size, text }) => (
2122
Pill.propTypes = {
2223
color: PropTypes.string,
2324
size: PropTypes.string,
24-
text: PropTypes.string.isRequired,
25+
squared: PropTypes.bool,
26+
text: PropTypes.node.isRequired,
2527
};
2628

2729
Pill.defaultProps = {
2830
color: undefined,
2931
size: undefined,
32+
squared: false
3033
};
3134

3235
export default Pill;

src/Pill/Pill.scss

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
@import '../../scss/borders';
12
@import '../../scss/theme';
23

34
.Pill {
@@ -19,6 +20,11 @@
1920
color: $ux-orange-600;
2021
}
2122

23+
&--green {
24+
background-color: $ux-green-100;
25+
color: $ux-green-700;
26+
}
27+
2228
/////// SIZES
2329
// Seems like a fine default size
2430
border-radius: 2rem;
@@ -30,4 +36,8 @@
3036
font-size: .625rem;
3137
padding: .25rem .5rem;
3238
}
39+
40+
&--squared {
41+
border-radius: $ux-border-radius;
42+
}
3343
}

stories/Pill.stories.jsx

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react';
2-
import { withKnobs, text } from '@storybook/addon-knobs';
2+
import { withKnobs, text, select, boolean } from '@storybook/addon-knobs';
33

44
import Pill from 'src/Pill';
55

@@ -9,10 +9,14 @@ export default {
99
decorators: [withKnobs],
1010
};
1111

12-
export const Default = () => <Pill text={text('Pill Text', 'Test pill')} />;
12+
const colors = ['', 'blue', 'orange', 'green'];
13+
const sizes = ['', 'sm'];
1314

14-
export const Blue = () => <Pill color="blue" text={text('Pill Text', 'Test pill')} />;
15-
16-
export const Orange = () => <Pill color="orange" text={text('Pill Text', 'Test pill')} />;
17-
18-
export const Small = () => <Pill size="sm" text={text('Pill Text', 'Test pill')} />;
15+
export const Default = () => (
16+
<Pill
17+
text={text('Pill Text', 'Test pill')}
18+
color={select('Color', colors, '')}
19+
size={select('Size', sizes, '')}
20+
squared={boolean('Squared', false)}
21+
/>
22+
);

0 commit comments

Comments
 (0)