Skip to content

Commit

Permalink
fix(Pills): integrate flexbox and export PillsGroup
Browse files Browse the repository at this point in the history
  • Loading branch information
kaminskypavel committed Aug 26, 2020
1 parent 5d91821 commit 43a9c82
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 12 deletions.
6 changes: 3 additions & 3 deletions src/components/Pill/Pill.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from "react";
import Pill from ".";
import Pill, {PillsGroup} from ".";

export default {
title: "Components/Pill",
Expand All @@ -12,11 +12,11 @@ export default {
const Template: any = (args: any) => <Pill {...args} />;

export const GroupOfPills = () => (
<div>
<PillsGroup>
<Pill label="Days" active />
<Pill label="Weeks" />
<Pill label="Months" />
</div>
</PillsGroup>
);

export const ActivePill = Template.bind({});
Expand Down
22 changes: 15 additions & 7 deletions src/components/Pill/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,29 @@ type Props = {
label: string;
};

export const PillsGroup = styled.div`
display: flex;
justify-content: center;
align-items: center;
`;

const InnerText = styled.span`
//font-family: "Roboto", helvetica, arial, sans-serif;
//font-weight: 300;
//line-height: 1.5;
font-family: "Roboto", helvetica, arial, sans-serif;
font-weight: 400;
line-height: 19.5px;
font-size: 13px;
`;

const PillComponent = styled.a<Pick<Props, "disabled" | "active">>`
const PillComponent = styled.div<Pick<Props, "disabled" | "active">>`
border: none;
cursor: pointer;
padding: 5px 16px 5px 16px;
margin: 0 2px;
text-decoration: none;
border-radius: 16px;
display: flex;
justify-content: center;
align-items: center;
background-color: ${({active, disabled}) => {
if (disabled) {
Expand Down Expand Up @@ -56,9 +62,11 @@ const Pill: React.FunctionComponent<Props> = ({
disabled = false,
active = false
}) => (
<PillComponent active={active} disabled={disabled} onClick={onClick}>
<InnerText>{label}</InnerText>
</PillComponent>
<PillsGroup>
<PillComponent active={active} disabled={disabled} onClick={onClick}>
<InnerText>{label}</InnerText>
</PillComponent>
</PillsGroup>
);

export default Pill;
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
import AttentionBox from "./components/AttentionBox";
import Badge from "./components/Badge";
import Button from "./components/Button";
import Pill from "./components/Pill";
import Pill, {PillsGroup} from "./components/Pill";

export {Badge, Button, AttentionBox, Pill};
export {Badge, Button, AttentionBox, Pill, PillsGroup};

0 comments on commit 43a9c82

Please sign in to comment.