-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🔧 Refactor some components and improve styling
- Loading branch information
1 parent
5e64ff9
commit 7a943cc
Showing
13 changed files
with
295 additions
and
193 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
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
109 changes: 109 additions & 0 deletions
109
frontend/src/components/OnboardingComponents/TopBarPopover.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,109 @@ | ||
// SPDX-FileCopyrightText: 2024 German Aerospace Center (DLR) | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
import React, {useMemo} from 'react'; | ||
import Popover from '@mui/material/Popover'; | ||
import Box from '@mui/material/Box'; | ||
import IconButton from '@mui/material/IconButton'; | ||
import Typography from '@mui/material/Typography'; | ||
import CloseIcon from '@mui/icons-material/Close'; | ||
import {useTranslation} from 'react-i18next'; | ||
import TourChips from './TourComponents/TourChipsList'; | ||
import LinearProgress from '@mui/material/LinearProgress'; | ||
|
||
interface TopBarPopoverProps { | ||
anchorEl: HTMLElement | null; | ||
open: boolean; | ||
onClose: () => void; | ||
allToursCompleted: boolean; | ||
completedTours: number; | ||
totalTours: number; | ||
} | ||
|
||
/** | ||
* This component is a popover that contains the onboarding tours which the user can take, it is rendered when the user clicks the information button in the top bar | ||
*/ | ||
const TopBarPopover: React.FC<TopBarPopoverProps> = ({ | ||
anchorEl, | ||
open, | ||
onClose, | ||
allToursCompleted, | ||
completedTours, | ||
totalTours, | ||
}) => { | ||
const {t: tOnboarding} = useTranslation('onboarding'); | ||
|
||
/** | ||
* this use memo is to calculate the completion percentage of the tours for the progress bar | ||
*/ | ||
const completionPercentage = useMemo(() => { | ||
return totalTours > 0 ? (completedTours / totalTours) * 100 : 0; | ||
}, [completedTours, totalTours]); | ||
|
||
return ( | ||
<Popover | ||
aria-label='popover' | ||
data-testid='popover-testid' | ||
open={open} | ||
anchorEl={anchorEl} | ||
onClose={onClose} | ||
anchorOrigin={{ | ||
vertical: 'top', | ||
horizontal: 'right', | ||
}} | ||
sx={{ | ||
'& .MuiPopover-paper': { | ||
width: 600, | ||
height: 370, | ||
}, | ||
}} | ||
> | ||
<Box position='relative' p={4}> | ||
<Box> | ||
<Typography variant='h2' align='left' gutterBottom> | ||
{allToursCompleted ? tOnboarding('congrats') : tOnboarding('getStarted')} | ||
</Typography> | ||
</Box> | ||
<Box mt={2}> | ||
<Typography variant='body1' align='left' gutterBottom sx={{color: 'GrayText'}}> | ||
{allToursCompleted ? tOnboarding('congratsContent') : tOnboarding('getStartedContent')} | ||
</Typography> | ||
</Box> | ||
<IconButton | ||
aria-label='close-info-button' | ||
onClick={onClose} | ||
sx={{ | ||
position: 'absolute', | ||
right: 8, | ||
top: 8, | ||
}} | ||
> | ||
<CloseIcon /> | ||
</IconButton> | ||
<Box mt={4}> | ||
<TourChips /> | ||
</Box> | ||
<Box mt={4}> | ||
<LinearProgress | ||
variant='determinate' | ||
value={completionPercentage} | ||
sx={{ | ||
height: 10, | ||
borderRadius: 5, | ||
backgroundColor: '#e0e0e0', | ||
'& .MuiLinearProgress-bar': { | ||
borderRadius: 5, | ||
backgroundColor: 'primary', | ||
}, | ||
}} | ||
/> | ||
<Typography variant='body2' align='left' sx={{color: 'GrayText', mt: 1}}> | ||
{Math.round(completionPercentage)}% {tOnboarding('completed')} | ||
</Typography> | ||
</Box> | ||
</Box> | ||
</Popover> | ||
); | ||
}; | ||
|
||
export default TopBarPopover; |
44 changes: 44 additions & 0 deletions
44
frontend/src/components/OnboardingComponents/TourComponents/TourChip.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,44 @@ | ||
// SPDX-FileCopyrightText: 2024 German Aerospace Center (DLR) | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
import React from 'react'; | ||
import Chip from '@mui/material/Chip'; | ||
import {useTheme} from '@mui/material/styles'; | ||
import {TourType} from '../../../types/tours'; | ||
|
||
interface TourChipProps { | ||
icon: React.ReactElement; | ||
tourType: TourType; | ||
label: string; | ||
color: 'default' | 'primary'; | ||
onClick: (tour: TourType) => void; | ||
} | ||
|
||
/** | ||
* This component is a chip that represents a tour that the user can take | ||
*/ | ||
const TourChip: React.FC<TourChipProps> = ({icon, tourType, label, color, onClick}) => { | ||
const theme = useTheme(); | ||
return ( | ||
<Chip | ||
icon={icon} | ||
label={label} | ||
variant='outlined' | ||
color={color} | ||
onClick={() => onClick(tourType)} | ||
sx={{ | ||
fontSize: theme.typography.listElement.fontSize, | ||
overflow: 'hidden', | ||
textOverflow: 'ellipsis', | ||
whiteSpace: 'nowrap', | ||
justifyContent: 'left', | ||
padding: '0 8px', | ||
'& .MuiChip-label': { | ||
padding: '0 8px', | ||
}, | ||
}} | ||
/> | ||
); | ||
}; | ||
|
||
export default TourChip; |
Oops, something went wrong.