Skip to content

Commit 48ad605

Browse files
Merge pull request #4984 from OneCommunityGlobal/venkataramanan_fix_countdown_formatting
Venkataramanan 🔥 countdown formatting
2 parents 7f15d6e + 964b58b commit 48ad605

3 files changed

Lines changed: 33 additions & 17 deletions

File tree

src/components/Timer/Countdown.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ export default function Countdown({
6666
const remainingSecondsDisplay = remainingSeconds.toString().padStart(2, '0');
6767

6868
const shouldDisplay = {
69-
hour: !!remainingHours,
70-
minute: !!remainingHours || !!remainingMinutes,
69+
hour: true,
70+
minute: true,
7171
};
7272

7373
const forceMinMax = (event, ref) => {

src/components/Timer/Countdown.module.css

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,16 @@
5555
}
5656

5757
.countdownCircle .content {
58+
width: 74%;
59+
max-width: 190px;
60+
margin: 0 auto;
5861
display: flex;
5962
flex-direction: column;
6063
align-items: center;
6164
justify-content: center;
6265
gap: 0.3rem;
6366
text-align: center;
67+
box-sizing: border-box;
6468
}
6569

6670
.countdownCircle .content > span {
@@ -71,37 +75,47 @@
7175
}
7276

7377
.content .remainingTime {
74-
display: flex;
75-
align-items: flex-start;
76-
justify-content: center;
77-
gap: 0.2rem;
78+
width: 100%;
79+
display: grid;
80+
grid-template-columns: 1fr auto 1fr auto 1fr;
81+
place-items: center;
82+
column-gap: 0.1rem;
7883
margin-top: 0.05rem;
7984
}
8085

86+
.content .remainingTime > div {
87+
min-width: 0;
88+
width: 100%;
89+
}
90+
8191
.content .timeDisplay {
82-
min-width: 2.8rem;
92+
width: 100%;
93+
min-width: 0;
8394
font-weight: 800;
84-
font-size: 2.5rem;
95+
font-size: 1.7rem;
8596
line-height: 1;
8697
text-align: center;
98+
white-space: nowrap;
8799
}
88100

89101
.content .label {
90-
margin-top: 0.25rem;
91-
font-size: 0.72rem;
102+
margin-top: 0.2rem;
103+
font-size: 0.42rem;
92104
font-weight: 800;
93105
text-align: center;
94106
text-transform: uppercase;
95-
letter-spacing: 0.05em;
96-
line-height: 1.1;
107+
letter-spacing: 0.03em;
108+
line-height: 1.05;
97109
opacity: 0.95;
110+
white-space: nowrap;
98111
}
99112

100113
.content .timeColon {
101-
margin-top: 0.05rem;
102-
font-size: 2rem;
114+
font-size: 1.1rem;
103115
font-weight: 800;
104116
line-height: 1;
117+
align-self: center;
118+
width: auto;
105119
}
106120

107121
.content .operators {

src/components/Timer/__test__/Countdown.test.jsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,11 @@ describe('Countdown Component', () => {
3636
expect(screen.getByText('Goal: 01:00:00')).toBeInTheDocument();
3737
expect(screen.getByText('Elapsed: 00:30:00')).toBeInTheDocument();
3838
expect(screen.getByText('Time Remaining')).toBeInTheDocument();
39-
expect(screen.getByText('00')).toBeInTheDocument();
39+
expect(screen.getAllByText('00')).toHaveLength(2);
4040
expect(screen.getByText('30')).toBeInTheDocument();
41+
expect(screen.getByText('Hours')).toBeInTheDocument();
42+
expect(screen.getByText('minutes')).toBeInTheDocument();
43+
expect(screen.getByText('seconds')).toBeInTheDocument();
4144
});
4245

4346
it('calls toggleTimer when the close button is clicked', () => {
@@ -51,9 +54,8 @@ describe('Countdown Component', () => {
5154
it('displays correct remaining time based on props', () => {
5255
// eslint-disable-next-line react/jsx-props-no-spreading
5356
const { rerender } = render(<Countdown {...defaultProps} />);
54-
expect(screen.getByText('00')).toBeInTheDocument(); // Hours
57+
expect(screen.getAllByText('00')).toHaveLength(2); // Hours and Seconds
5558
expect(screen.getByText('30')).toBeInTheDocument(); // Minutes
56-
expect(screen.getByText('00')).toBeInTheDocument(); // Seconds
5759

5860
rerender(
5961
<Countdown

0 commit comments

Comments
 (0)