-
Notifications
You must be signed in to change notification settings - Fork 4
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
6ed199a
commit b4ab278
Showing
6 changed files
with
73 additions
and
128 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
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
40 changes: 7 additions & 33 deletions
40
.../orchestrator-ui-components/src/components/WfoTable/WfoBasicTable/WfoStatusColorField.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 |
---|---|---|
@@ -1,46 +1,20 @@ | ||
import React from 'react'; | ||
import { EuiFlexItem, tint } from '@elastic/eui'; | ||
import { useOrchestratorTheme } from '../../../hooks'; | ||
import { defaultOrchestratorTheme } from '../../../theme'; | ||
import { WFO_STATUS_COLOR_FIELD } from '../utils/columns'; | ||
|
||
type ThemeType = typeof defaultOrchestratorTheme; | ||
|
||
const toStatusColorFieldColor = (color: string) => tint(color, 0.3); | ||
|
||
export type WfoStatusColorFieldProps = { | ||
colorMappings: { [key: string]: string[] }; | ||
state: string; | ||
color: string; | ||
}; | ||
|
||
export const STATUS_COLOR_FIELD_COLUMN_PROPS = { | ||
field: WFO_STATUS_COLOR_FIELD, | ||
name: '', | ||
width: '1', | ||
}; | ||
|
||
export const WfoStatusColorField = ({ | ||
colorMappings, | ||
state, | ||
}: WfoStatusColorFieldProps) => { | ||
const { theme } = useOrchestratorTheme(); | ||
let color: keyof ThemeType['colors'] = | ||
'lightShade' as keyof ThemeType['colors']; | ||
|
||
for (const [colorName, states] of Object.entries(colorMappings)) { | ||
if (states.includes(state)) { | ||
color = colorName as keyof ThemeType['colors']; | ||
break; | ||
} | ||
} | ||
const toStatusColorFieldColor = (color: string) => tint(color, 0.3); | ||
|
||
export const WfoStatusColorField = ({ color }: WfoStatusColorFieldProps) => { | ||
return ( | ||
<EuiFlexItem | ||
css={{ | ||
paddingInline: theme.base / 4, | ||
paddingBlock: theme.base + 4, | ||
backgroundColor: toStatusColorFieldColor(theme.colors[color]), | ||
backgroundColor: toStatusColorFieldColor(color), | ||
height: '100%', | ||
width: '100%', | ||
}} | ||
/> | ||
></EuiFlexItem> | ||
); | ||
}; |
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