Skip to content

Commit

Permalink
Merge pull request #820 from securityscorecard/Mnau-mnau@UXD-1240
Browse files Browse the repository at this point in the history
feat(StatusDot): add component
  • Loading branch information
Mnau-mnau authored Sep 22, 2023
2 parents 88b8a1b + 9804dad commit f1739ab
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .betterer/.betterer.results
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ exports[`no more deprecated components`] = {
"../src/components/FlexContainer/index.ts:1246547685": [
[0, 0, 59, "\'./FlexContainer\' import is restricted from being used by a pattern. FlexContainer is deprecated. Please use Layout primitives instead.", "3330215570"]
],
"../src/components/index.ts:3740729044": [
"../src/components/index.ts:3052257943": [
[18, 0, 32, "\'./FlexContainer\' import is restricted from being used by a pattern. FlexContainer is deprecated. Please use Layout primitives instead.", "726759703"]
]
}`
Expand Down
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/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>
);
34 changes: 34 additions & 0 deletions src/components/StatusDot/StatusDot.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
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',
} as const;

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

const StatusDot = ({
color = 'inactive',
}: {
color: keyof typeof StatusDotColors;
}) => <StatusDotComponent color={color} role="presentation" />;

StatusDot.propTypes = {
color: PropTypes.oneOf(Object.keys(StatusDotColors)),
};

export default StatusDot;
1 change: 1 addition & 0 deletions src/components/StatusDot/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default as StatusDot } from './StatusDot';
1 change: 1 addition & 0 deletions src/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export * from './Signal';
export * from './SingleDatePicker';
export * from './SortableList';
export * from './Spinner';
export * from './StatusDot';
export * from './Stepper';
export * from './Table';
export * from './Tabs';
Expand Down

0 comments on commit f1739ab

Please sign in to comment.