Skip to content

Commit

Permalink
feat: format <RelativeUptime /> label and removed opacity: 1 from dis…
Browse files Browse the repository at this point in the history
…abled <Board />
  • Loading branch information
Luca Tagliabue committed Aug 28, 2024
1 parent 8cd6ac7 commit 8145ccf
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
4 changes: 0 additions & 4 deletions src/lib/components/board/_styles.less
Original file line number Diff line number Diff line change
Expand Up @@ -265,10 +265,6 @@
font-style: italic;
}
}

&:hover {
opacity: 1;
}
}

&--status-in-evidence {
Expand Down
16 changes: 14 additions & 2 deletions src/lib/components/relative-up-time/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ const RelativeUpTime = ({ timestamp, from, withTooltip }: Props) => {
const daysLabel = days ? `${days}d` : '';
const hoursLabel = hours ? `${hours}h` : '';
const minutesLabel = minutes ? `${minutes}m` : '';

const label = `${monthsLabel} ${weeksLabel} ${daysLabel} ${hoursLabel} ${minutesLabel}`;
const label = getLabel(monthsLabel, weeksLabel, daysLabel, hoursLabel, minutesLabel);
const lableOrElse = label.trim().length === 0 ? '0m' : label;

if (withTooltip) {
Expand All @@ -55,6 +55,18 @@ const RelativeUpTime = ({ timestamp, from, withTooltip }: Props) => {
return <>{lableOrElse}</>;
};

const getLabel = (monthsLabel: string, weeksLabel: string, daysLabel: string, hoursLabel: string, minutesLabel: string): string => {
if (monthsLabel) {
return `${monthsLabel} ${weeksLabel} ${daysLabel} `;
}

if (weeksLabel) {
return `${weeksLabel} ${daysLabel} ${hoursLabel}`;
}

return `${daysLabel} ${hoursLabel} ${minutesLabel}`;
};

RelativeUpTime.displayName = 'RelativeDateTime';

export default memo<Props>(RelativeUpTime);

0 comments on commit 8145ccf

Please sign in to comment.