Skip to content

Commit

Permalink
more detailed tooltip
Browse files Browse the repository at this point in the history
  • Loading branch information
Tristan-WorkGH committed Dec 14, 2023
1 parent 39cbaaa commit bd3d00c
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 7 deletions.
91 changes: 84 additions & 7 deletions src/components/TopBar/AboutDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@ import {
Grid,
Stack,
Tooltip,
tooltipClasses,
Typography,
useMediaQuery,
useTheme,
Zoom,
} from '@mui/material';
import { LoadingButton } from '@mui/lab';
import {
Expand Down Expand Up @@ -323,10 +325,8 @@ const AboutDialog = ({
key={`module-${idx}`}
type={module.type}
name={module.name}
version={
module.gitTag ||
module.version
}
version={module.version}
gitTag={module.gitTag}
license={module.license}
/>
))}
Expand Down Expand Up @@ -380,6 +380,27 @@ const style = {
alignSelf: 'flex-end',
flexShrink: 0,
},
tooltip: (theme) => ({
[`& .${tooltipClasses.tooltip}`]: {
border: '1px solid #dadde9',
boxShadow: theme.shadows[1],
},
}),
tooltipDetails: {
display: 'grid',
gridTemplateColumns: 'max-content auto',
margin: 0,
dt: {
gridColumnStart: 1,
'&:after': {
content: '" :"',
},
},
dd: {
gridColumnStart: 2,
paddingLeft: '0.5em',
},
},
};

const ModuleTypesIcons = {
Expand All @@ -388,7 +409,7 @@ const ModuleTypesIcons = {
other: <QuestionMark sx={style.icons} fontSize="small" />,
};

const Module = ({ type, name, version, license }) => {
const Module = ({ type, name, version, gitTag, license }) => {
return (
<Grid
item
Expand All @@ -401,7 +422,62 @@ const Module = ({ type, name, version, license }) => {
},
}}
>
<Tooltip title={(name || '<?>') + ' ' + (version || '')}>
<Tooltip
TransitionComponent={Zoom}
enterDelay={3500}
enterNextDelay={350}
leaveDelay={200}
placement="bottom-start"
arrow
sx={style.tooltip}
title={
<>
<Typography variant="body1">{name || '<?>'}</Typography>
<Box component="dl" sx={style.tooltipDetails}>
<Typography variant="body2" component="dt">
<FormattedMessage id="about-dialog/label-type" />
</Typography>
<Typography variant="body2" component="dd">
<FormattedMessage
id={`about-dialog/module-tooltip-${
'app'.localeCompare(type, undefined, {
sensitivity: 'base',
}) === 0
? 'app'
: 'server'.localeCompare(
type,
undefined,
{ sensitivity: 'base' }
) === 0
? 'server'
: 'other'
}`}
/>
</Typography>
{version && (
<>
<Typography variant="body2" component="dt">
<FormattedMessage id="about-dialog/version" />
</Typography>
<Typography variant="body2" component="dd">
{version}
</Typography>
</>
)}
{gitTag && (
<>
<Typography variant="body2" component="dt">
<FormattedMessage id="about-dialog/git-version" />
</Typography>
<Typography variant="body2" component="dd">
{gitTag}
</Typography>
</>
)}
</Box>
</>
}
>
<Stack
direction="row"
justifyContent="flex-start"
Expand All @@ -419,7 +495,7 @@ const Module = ({ type, name, version, license }) => {
noWrap
sx={style.version}
>
{version || null}
{gitTag || version || null}
</Typography>
</Stack>
</Tooltip>
Expand All @@ -430,5 +506,6 @@ Module.propTypes = {
type: PropTypes.string,
name: PropTypes.string,
version: PropTypes.string,
gitTag: PropTypes.string,
license: PropTypes.string,
};
4 changes: 4 additions & 0 deletions src/components/translations/top-bar-en.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ const top_bar_en = {
'about-dialog/license': 'License',
'about-dialog/modules-section': 'Modules details',
'about-dialog/git-version': 'Tag',
'about-dialog/label-type': 'Type',
'about-dialog/module-tooltip-app': 'application',
'about-dialog/module-tooltip-server': 'server',
'about-dialog/module-tooltip-other': 'other',
};

export default top_bar_en;
4 changes: 4 additions & 0 deletions src/components/translations/top-bar-fr.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ const top_bar_fr = {
'about-dialog/license': 'Licence',
'about-dialog/modules-section': 'Détails des modules',
'about-dialog/git-version': 'Tag',
'about-dialog/label-type': 'Type',
'about-dialog/module-tooltip-app': 'application',
'about-dialog/module-tooltip-server': 'serveur',
'about-dialog/module-tooltip-other': 'autre',
};

export default top_bar_fr;

0 comments on commit bd3d00c

Please sign in to comment.