Skip to content

Commit

Permalink
feat(StatusPill): add component
Browse files Browse the repository at this point in the history
  • Loading branch information
Mnau-mnau committed Sep 21, 2023
1 parent d5dc6b1 commit 4588756
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 0 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 19 additions & 0 deletions src/components/StatusPill/StatusPill.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import React from 'react';
import { Meta, Story } from '@storybook/react/types-6-0';

import StatusPill from './StatusPill';
import { Inline } from '../layout';

export default {
title: 'components/StatusPill',
component: StatusPill,
} as Meta;

export const Default: Story = () => (
<Inline gap="lg">
<StatusPill color="good" label="Good" />
<StatusPill color="bad" label="Bad" />
<StatusPill color="neutral" label="Neutral" />
<StatusPill color="inactive" label="Inactive" />
</Inline>
);
43 changes: 43 additions & 0 deletions src/components/StatusPill/StatusPill.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import React from 'react';
import Styled from 'styled-components';
import PropTypes from 'prop-types';

import { StatusDot } from '../StatusDot/index';
import { StatusPillProps } from './StatusPill.types';
import PillLabel from '../Pill/PillLabel';
import { SpaceSizes } from '../../theme';
import { Inline, Padbox } from '../layout';
import { PaddingTypes } from '../layout/Padbox/Padbox.enums';
import { getColor, getRadii, pxToRem } from '../../utils';

const StyledPillWrapper = Styled(Padbox)`
display: inline-block;
height: ${pxToRem(24)};
min-width: 0;
border-radius: ${getRadii('round')};
border: 1px solid ${getColor('neutral.200')};
background-color: ${getColor('neutral.0')};
padding-right: ${pxToRem(6)};
padding-top: ${pxToRem(3)};
`;

const StatusPill: React.FC<StatusPillProps> = ({
color = 'inactive',
label,
}) => (
<StyledPillWrapper
paddingSize={SpaceSizes.xs}
paddingType={PaddingTypes.squish}
>
<Inline align="center" gap="sm">
<StatusDot color={color} />
<PillLabel>{label}</PillLabel>
</Inline>
</StyledPillWrapper>
);

StatusPill.propTypes = {
label: PropTypes.string.isRequired,
color: PropTypes.string,
};
export default StatusPill;
6 changes: 6 additions & 0 deletions src/components/StatusPill/StatusPill.types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { StatusDotColors } from '../StatusDot';

export interface StatusPillProps {
color?: keyof typeof StatusDotColors;
label: string;
}
1 change: 1 addition & 0 deletions src/components/StatusPill/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default as StatusPill } from './StatusPill';

0 comments on commit 4588756

Please sign in to comment.