-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(alarms): integrate alarms into KPI widget
- Loading branch information
1 parent
d60fe4e
commit b5fa347
Showing
11 changed files
with
300 additions
and
53 deletions.
There are no files selected for viewing
3 changes: 3 additions & 0 deletions
3
packages/react-components/src/components/alarm-state/alarm-state-text.css
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,3 @@ | ||
.alarm-state-text { | ||
display: flex; | ||
} |
104 changes: 104 additions & 0 deletions
104
packages/react-components/src/components/alarm-state/alarm-state-text.tsx
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,104 @@ | ||
import React from 'react'; | ||
import Box from '@cloudscape-design/components/box'; | ||
import Icon from '@cloudscape-design/components/icon'; | ||
import { | ||
colorBorderStatusError, | ||
colorBorderStatusSuccess, | ||
colorBorderStatusWarning, | ||
spaceScaledXxs, | ||
} from '@cloudscape-design/design-tokens'; | ||
|
||
import './alarm-state-text.css'; | ||
import { PascalCaseStateName } from '../../hooks/useAlarms/transformers'; | ||
|
||
type AlarmStateTextOptions = { | ||
state?: PascalCaseStateName; | ||
inheritFontColor?: boolean; | ||
}; | ||
|
||
export const alarmStateHasText = (state: PascalCaseStateName) => { | ||
return state === 'Active' || state === 'Normal' || state === 'Latched'; | ||
}; | ||
|
||
export const AlarmStateText = ({ | ||
state, | ||
inheritFontColor, | ||
}: AlarmStateTextOptions) => { | ||
let icon = null; | ||
let text = null; | ||
let styles: React.CSSProperties = { | ||
gap: spaceScaledXxs, | ||
textDecoration: 'none', | ||
}; | ||
|
||
let borderBottom = '1px dashed '; | ||
|
||
switch (state) { | ||
case 'Active': | ||
icon = ( | ||
<Icon | ||
name='notification' | ||
variant={inheritFontColor ? 'normal' : 'error'} | ||
/> | ||
); | ||
text = ( | ||
<Box color={inheritFontColor ? 'inherit' : 'text-status-error'}> | ||
Active alarm | ||
</Box> | ||
); | ||
borderBottom += inheritFontColor ? 'inherit' : colorBorderStatusError; | ||
styles = { | ||
...styles, | ||
borderBottom: borderBottom, | ||
}; | ||
break; | ||
case 'Normal': | ||
icon = ( | ||
<Icon | ||
name='status-positive' | ||
variant={inheritFontColor ? 'normal' : 'success'} | ||
/> | ||
); | ||
text = ( | ||
<Box color={inheritFontColor ? 'inherit' : 'text-status-success'}> | ||
Normal | ||
</Box> | ||
); | ||
borderBottom += inheritFontColor ? 'inherit' : colorBorderStatusSuccess; | ||
styles = { | ||
...styles, | ||
borderBottom: borderBottom, | ||
}; | ||
break; | ||
case 'Latched': | ||
icon = ( | ||
<Icon | ||
name='status-warning' | ||
variant={inheritFontColor ? 'normal' : 'warning'} | ||
/> | ||
); | ||
text = ( | ||
<Box color={inheritFontColor ? 'inherit' : 'text-status-warning'}> | ||
Latched alarm | ||
</Box> | ||
); | ||
borderBottom += inheritFontColor ? 'inherit' : colorBorderStatusWarning; | ||
styles = { | ||
...styles, | ||
borderBottom: borderBottom, | ||
}; | ||
break; | ||
} | ||
|
||
return ( | ||
<div | ||
data-testid='alarm-state-text' | ||
className='alarm-state alarm-state-text' | ||
> | ||
<div className='alarm-state-text' style={styles}> | ||
{icon} | ||
{text} | ||
</div> | ||
</div> | ||
); | ||
}; |
48 changes: 18 additions & 30 deletions
48
packages/react-components/src/components/data-quality/data-quality-text.tsx
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
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
Oops, something went wrong.