-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8c3c371
commit 5b80c9f
Showing
5 changed files
with
226 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import React from 'react'; | ||
import { Status, StatusType } from './status'; | ||
import { mountWithTheme } from '../../test-utils/renderer'; | ||
|
||
const statusTypesArray: StatusType[] = ['enabled', 'disabled', 'blocked']; | ||
|
||
describe('Status', () => { | ||
statusTypesArray.forEach((type) => ( | ||
it(`matches snapshot (${type})`, () => { | ||
const tree = mountWithTheme(<Status type={type} label={type} />); | ||
|
||
expect(tree).toMatchSnapshot(); | ||
}) | ||
)); | ||
}); |
149 changes: 149 additions & 0 deletions
149
packages/react/src/components/status/status.test.tsx.snap
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import React, { VoidFunctionComponent } from 'react'; | ||
import styled from 'styled-components'; | ||
import { Theme } from '../../themes'; | ||
|
||
export type StatusType = 'enabled' | 'disabled' | 'blocked'; | ||
|
||
function getBackgroundColor(type: StatusType, theme: Theme): string { | ||
switch (type) { | ||
case 'enabled': | ||
return theme.notifications['success-1.1']; | ||
case 'disabled': | ||
return theme.greys.white; | ||
case 'blocked': | ||
return theme.notifications['error-2.1']; | ||
} | ||
} | ||
|
||
const Wrapper = styled.div<{ type: StatusType }>` | ||
align-items: center; | ||
display: flex; | ||
${({ type, theme }) => type === 'disabled' && `color: ${theme.greys['dark-grey']}`} | ||
`; | ||
|
||
const Circle = styled.div<{ type: StatusType }>` | ||
background-color: ${({ type, theme }) => getBackgroundColor(type, theme)}; | ||
border: ${({ type, theme }) => (type === 'disabled' ? `1px solid ${theme.greys['dark-grey']}` : 'none')}; | ||
border-radius: 50%; | ||
box-sizing: border-box; | ||
height: 10px; | ||
margin-right: calc(var(--spacing-base) * 1.5); | ||
width: 10px; | ||
`; | ||
|
||
interface Props { | ||
label: string; | ||
type: StatusType; | ||
} | ||
|
||
export const Status: VoidFunctionComponent<Props> = ({ label, type }) => ( | ||
<Wrapper type={type}> | ||
<Circle type={type} /> | ||
<span>{label}</span> | ||
</Wrapper> | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import React from 'react'; | ||
import { Status } from '@equisoft/design-elements-react'; | ||
import { Story } from '@storybook/react'; | ||
|
||
export default { | ||
component: Status, | ||
title: 'Data/Status', | ||
}; | ||
|
||
export const Normal: Story = () => ( | ||
<> | ||
<Status type="enabled" label="Enabled" /> | ||
<Status type="disabled" label="Disabled" /> | ||
<Status type="blocked" label="Blocked" /> | ||
</> | ||
); |