Skip to content

Commit

Permalink
feat: Stage timeline styling (#6903)
Browse files Browse the repository at this point in the history
  • Loading branch information
kwasniew committed Apr 23, 2024
1 parent e7fe31e commit d59f1ad
Show file tree
Hide file tree
Showing 7 changed files with 147 additions and 13 deletions.
8 changes: 8 additions & 0 deletions frontend/src/assets/icons/stage-archived.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions frontend/src/assets/icons/stage-completed-discarded.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions frontend/src/assets/icons/stage-completed.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions frontend/src/assets/icons/stage-initial.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions frontend/src/assets/icons/stage-live.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions frontend/src/assets/icons/stage-pre-live.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
import { Box, styled, Typography } from '@mui/material';
import { Badge } from '../../../../common/Badge/Badge';
import { Badge } from 'component/common/Badge/Badge';
import { HtmlTooltip } from 'component/common/HtmlTooltip/HtmlTooltip';
import type { FC } from 'react';
import type * as React from 'react';
import type { FC } from 'react';
import { ReactComponent as InitialStageIcon } from 'assets/icons/stage-initial.svg';
import { ReactComponent as PreLiveStageIcon } from 'assets/icons/stage-pre-live.svg';
import { ReactComponent as LiveStageIcon } from 'assets/icons/stage-live.svg';
import { ReactComponent as CompletedStageIcon } from 'assets/icons/stage-completed.svg';
import { ReactComponent as ArchivedStageIcon } from 'assets/icons/stage-archived.svg';

const TimeLabel = styled('span')(({ theme }) => ({
color: theme.palette.text.secondary,
Expand All @@ -24,18 +29,89 @@ const TimeLifecycleRow = styled(Box)(({ theme }) => ({
marginBottom: theme.spacing(1.5),
}));

const IconsRow = styled(Box)(({ theme }) => ({
display: 'flex',
alignItems: 'center',
marginTop: theme.spacing(4),
marginBottom: theme.spacing(6),
}));

const Line = styled(Box)(({ theme }) => ({
height: '1px',
background: theme.palette.background.application,
flex: 1,
}));

const StageBox = styled(Box, {
shouldForwardProp: (prop) => prop !== 'active',
})<{ active?: boolean }>(({ theme, active }) => ({
position: 'relative',
// speech bubble triangle for active stage
...(active && {
'&:before': {
content: '""',
position: 'absolute',
display: 'block',
borderStyle: 'solid',
borderColor: `${theme.palette.primary.main} transparent`,
borderWidth: '0 6px 6px',
top: theme.spacing(3.25),
left: theme.spacing(1.75),
},
}),
// stage name text
'&:after': {
content: 'attr(data-after-content)',
display: 'block',
position: 'absolute',
top: theme.spacing(4),
left: theme.spacing(-1.25),
right: theme.spacing(-1.25),
textAlign: 'center',
whiteSpace: 'nowrap',
fontSize: theme.spacing(1.25),
padding: theme.spacing(0.25, 0),
color: theme.palette.text.secondary,
// active wrapper for stage name text
...(active && {
backgroundColor: theme.palette.primary.main,
color: theme.palette.primary.contrastText,
fontWeight: theme.fontWeight.bold,
borderRadius: theme.spacing(0.5),
}),
},
}));

const ColorFill = styled(Box)(({ theme }) => ({
backgroundColor: theme.palette.primary.main,
color: theme.palette.primary.contrastText,
borderRadius: theme.spacing(0, 0, 1, 1), // has to match the parent tooltip container
margin: theme.spacing(-1, -1.5), // has to match the parent tooltip container
padding: theme.spacing(2, 3),
}));

export const FeatureLifecycleTooltip: FC<{
children: React.ReactElement<any, any>;
}> = ({ children }) => (
<HtmlTooltip
maxHeight={800}
maxWidth={350}
arrow
title={
<Box>
<Box sx={(theme) => ({ padding: theme.spacing(2) })}>
<MainLifecycleRow>
<Typography variant='h3'>Lifecycle</Typography>
<Badge>Initial</Badge>
<Box
sx={{
display: 'flex',
alignItems: 'center',
gap: 1,
}}
>
<Badge>Initial</Badge>
<InitialStageIcon />
</Box>
</MainLifecycleRow>
<TimeLifecycleRow>
<TimeLabel>Stage entered at</TimeLabel>
Expand All @@ -45,16 +121,37 @@ export const FeatureLifecycleTooltip: FC<{
<TimeLabel>Time spent in stage</TimeLabel>
<span>3 days</span>
</TimeLifecycleRow>
<IconsRow>
<StageBox data-after-content='Initial' active={true}>
<InitialStageIcon />
</StageBox>

<Line />

<StageBox data-after-content='Pre-live'>
<PreLiveStageIcon />
</StageBox>

<Line />

<StageBox data-after-content='Live'>
<LiveStageIcon />
</StageBox>

<Line />

<StageBox data-after-content='Completed'>
<CompletedStageIcon />
</StageBox>

<Line />

<StageBox data-after-content='Archived'>
<ArchivedStageIcon />
</StageBox>
</IconsRow>
</Box>
<Box
sx={(theme) => ({
backgroundColor: theme.palette.primary.main,
color: theme.palette.primary.contrastText,
borderRadius: theme.spacing(0, 0, 1, 1), // has to match the parent tooltip container
margin: theme.spacing(-1, -1.5), // has to match the parent tooltip container
p: theme.spacing(2, 3),
})}
>
<ColorFill>
<InfoText>
This feature toggle is currently in the initial phase of
it's life cycle.
Expand All @@ -67,7 +164,7 @@ export const FeatureLifecycleTooltip: FC<{
Once we detect metrics for a non-production environment
it will move into pre-live.
</InfoText>
</Box>
</ColorFill>
</Box>
}
>
Expand Down

0 comments on commit d59f1ad

Please sign in to comment.