-
Notifications
You must be signed in to change notification settings - Fork 997
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[frontend] update style of draft chip & top bar
- Loading branch information
1 parent
d834636
commit becbb7d
Showing
7 changed files
with
111 additions
and
36 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
59 changes: 59 additions & 0 deletions
59
opencti-platform/opencti-front/src/private/components/common/draft/DraftBlock.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,59 @@ | ||
import { useTheme } from '@mui/styles'; | ||
import Typography from '@mui/material/Typography'; | ||
import React, { FunctionComponent, ReactNode } from 'react'; | ||
import { getDraftModeColor } from './DraftChip'; | ||
import type { Theme } from '../../../../components/Theme'; | ||
import { hexToRGB } from '../../../../utils/Colors'; | ||
import { useFormatter } from '../../../../components/i18n'; | ||
|
||
interface DraftBlockProps { | ||
title?: string | ||
body?: ReactNode | ||
sx?: Record<string, React.CSSProperties> | ||
} | ||
|
||
const DraftBlock: FunctionComponent<DraftBlockProps> = ({ title, body, sx }) => { | ||
const { t_i18n } = useFormatter(); | ||
const theme = useTheme<Theme>(); | ||
const draftColor = getDraftModeColor(theme); | ||
|
||
return ( | ||
<div | ||
style={{ | ||
border: `1px solid ${hexToRGB(draftColor, 0.5)}`, | ||
color: draftColor, | ||
display: 'flex', | ||
flexDirection: 'column', | ||
minHeight: theme.spacing(4), | ||
padding: theme.spacing(1), | ||
paddingTop: theme.spacing(0.5), | ||
borderRadius: theme.spacing(0.5), | ||
...(sx?.root ?? {}), | ||
}} | ||
> | ||
<Typography | ||
variant="h4" | ||
style={{ | ||
color: draftColor, | ||
marginTop: theme.spacing(-1.1), | ||
marginBottom: 0, | ||
background: theme.palette.background.default, | ||
paddingLeft: theme.spacing(1), | ||
paddingRight: theme.spacing(1), | ||
fontSize: 10, | ||
height: 10, | ||
textTransform: 'uppercase', | ||
fontFamily: '"Geoligica", sans-serif', | ||
fontWeight: 700, | ||
width: 'fit-content', | ||
...(sx?.title ?? {}), | ||
}} | ||
> | ||
{title ?? t_i18n('Draft Mode')} | ||
</Typography> | ||
{body} | ||
</div> | ||
); | ||
}; | ||
|
||
export default DraftBlock; |
40 changes: 40 additions & 0 deletions
40
opencti-platform/opencti-front/src/private/components/common/draft/DraftChip.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,40 @@ | ||
import React from 'react'; | ||
import { useTheme } from '@mui/styles'; | ||
import Tooltip from '@mui/material/Tooltip'; | ||
import { SimplePaletteColorOptions } from '@mui/material'; | ||
import type { Theme } from '../../../../components/Theme'; | ||
import { useFormatter } from '../../../../components/i18n'; | ||
|
||
export const getDraftModeColor = (theme: Theme) => { | ||
const draftModeColor = (theme.palette.warning as SimplePaletteColorOptions)?.main ?? theme.palette.primary.main; | ||
return draftModeColor; | ||
}; | ||
|
||
export const DraftChip = ({ style }: { style?: React.CSSProperties }) => { | ||
const { t_i18n } = useFormatter(); | ||
const theme = useTheme<Theme>(); | ||
const draftColor = getDraftModeColor(theme); | ||
return ( | ||
<div | ||
style={{ | ||
fontSize: 'xx-small', | ||
textTransform: 'uppercase', | ||
fontWeight: 500, | ||
height: 14, | ||
display: 'inline-flex', | ||
justifyContent: 'center', | ||
alignItems: 'center', | ||
marginTop: theme.spacing(0.25), | ||
marginLeft: theme.spacing(0.5), | ||
padding: `${theme.spacing(1)} ${theme.spacing(0.5)}`, | ||
borderRadius: theme.borderRadius, | ||
border: `1px solid ${draftColor}`, | ||
color: draftColor, | ||
backgroundColor: 'transparent', | ||
...style, | ||
}} | ||
> | ||
{t_i18n('Draft')} | ||
</div> | ||
); | ||
}; |
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
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