-
Notifications
You must be signed in to change notification settings - Fork 8
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
92f1844
commit 68026a2
Showing
3 changed files
with
98 additions
and
6 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,34 @@ | ||
import { Icon, IconName } from '../icon/Icon.component'; | ||
|
||
import { | ||
STATUS_WARNING, | ||
STATUS_CRITICAL, | ||
STATUS_HEALTH, | ||
} from '../tablev2/TableUtils'; | ||
|
||
export enum StatusCluster { | ||
HEALTHY = 'healthy', | ||
WARNING = 'warning', | ||
CRITICAL = 'critical', | ||
UNKNOWN = 'unknown', | ||
} | ||
|
||
export const StatusIcon = ({ status }: { status: StatusCluster }) => { | ||
const icon: { status: string; name: IconName } = (() => { | ||
switch (status) { | ||
case STATUS_HEALTH: | ||
return { status: 'statusHealthy', name: 'Check-circle' }; | ||
|
||
case STATUS_WARNING: | ||
return { status: 'statusWarning', name: 'Times-circle' }; | ||
|
||
case STATUS_CRITICAL: | ||
return { status: 'statusCritical', name: 'Times-circle' }; | ||
|
||
default: | ||
return { status: 'textTertiary', name: 'Info' }; | ||
} | ||
})(); | ||
|
||
return <Icon color={icon.status} name={icon.name} />; | ||
}; |
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,57 @@ | ||
import { Meta, StoryObj } from '@storybook/react'; | ||
import React from 'react'; | ||
import { | ||
StatusCluster, | ||
StatusIcon, | ||
} from '../src/lib/components/statusicon/StatusIcon.component'; | ||
import { Wrapper } from './common'; | ||
import styled from 'styled-components'; | ||
import { Stack, Text } from '../src/lib'; | ||
|
||
const TextWrapper = styled(Wrapper)` | ||
min-height: 0; | ||
`; | ||
|
||
type Story = StoryObj<typeof StatusIcon>; | ||
|
||
export default { | ||
title: 'Components/statusIcon', | ||
component: StatusIcon, | ||
argTypes: { | ||
status: { | ||
control: { | ||
disable: true, | ||
}, | ||
}, | ||
children: { | ||
control: { | ||
disable: true, | ||
}, | ||
}, | ||
}, | ||
}; | ||
|
||
export const Playground = { | ||
render: ({}: any) => { | ||
return ( | ||
<TextWrapper> | ||
<Stack> | ||
<Text>Healthy status </Text> | ||
<StatusIcon status={StatusCluster.HEALTHY} />{' '} | ||
</Stack> | ||
<Stack> | ||
<Text>Warning status </Text> | ||
<StatusIcon status={StatusCluster.WARNING} /> | ||
</Stack> | ||
<Stack> | ||
<Text>Critical status </Text> | ||
<StatusIcon status={StatusCluster.CRITICAL} /> | ||
</Stack> | ||
<Stack> | ||
<Text>Unknown status </Text> | ||
<StatusIcon status={StatusCluster.UNKNOWN} /> | ||
</Stack> | ||
</TextWrapper> | ||
); | ||
}, | ||
}; |