Skip to content

Commit

Permalink
feat(StatusDot): add component
Browse files Browse the repository at this point in the history
  • Loading branch information
Mnau-mnau committed Sep 20, 2023
1 parent ae79151 commit d5dc6b1
Show file tree
Hide file tree
Showing 5 changed files with 59 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.
6 changes: 6 additions & 0 deletions src/components/StatusDot/StatusDot.enums.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export const StatusDotColors = {
good: 'good',
bad: 'bad',
neutral: 'neutral',
inactive: 'inactive',
} as const;
19 changes: 19 additions & 0 deletions src/components/StatusDot/StatusDot.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 StatusDot from './StatusDot';
import { Inline } from '../layout';

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

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

import { getRadii, pxToRem } from '../../utils';

const StatusDotColors = {
good: '100, 244, 81',
bad: '242, 46, 67',
neutral: '84, 129, 217',
inactive: '216, 216, 216',
};

const StatusDotComponent = Styled.div`
width: ${pxToRem(12)};
height: ${pxToRem(12)};
border-radius: ${getRadii('round')};
background-color: rgba(${({ color }) => StatusDotColors[color]});
border: 2px solid white;
box-shadow: 0 0 12px 0px rgba(${({ color }) =>
`${StatusDotColors[color]}, 0.5`});
`;

const StatusDot = ({ color }) => (
<StatusDotComponent color={color} role="presentation" />
);

StatusDot.propTypes = {
color: PropTypes.string,
};

export default StatusDot;
2 changes: 2 additions & 0 deletions src/components/StatusDot/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export { default as StatusDot } from './StatusDot';
export { StatusDotColors } from './StatusDot.enums';

0 comments on commit d5dc6b1

Please sign in to comment.