Skip to content

Commit f6fed7e

Browse files
committed
fix(StartOrPauseTimerButton): Width calculation and transition
1 parent 8cc782d commit f6fed7e

File tree

2 files changed

+15
-12
lines changed

2 files changed

+15
-12
lines changed

src/components/Button.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export default function Button({
2020
type='button'
2121
className={cn(
2222
'rounded bg-blue-500 px-4 py-2 font-[Inter] text-2xl font-bold',
23-
'text-white shadow-sm shadow-black transition-colors hover:bg-blue-600',
23+
'text-white shadow-sm shadow-black transition-all hover:bg-blue-600',
2424
'hover:text-gray-100 disabled:opacity-50 disabled:hover:bg-blue-500',
2525
'disabled:hover:text-white',
2626
className,

src/components/StartOrPauseTimerButton.tsx

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,25 +32,28 @@ export default function StartOrPauseTimerButton({
3232

3333
type LanguagesAbbreviations = 'en' | 'pt-BR' | 'pt'
3434

35-
const widthMapping: { [key in LanguagesAbbreviations]: number } = {
36-
en: timerIsRunning ? 28 : timerCanReset ? 32 : 24,
37-
'pt-BR': timerIsRunning ? 32 : 40,
38-
pt: timerIsRunning ? 32 : 40,
35+
const width24 = 'w-24'
36+
const width28 = 'w-28'
37+
const width32 = 'w-32'
38+
const width40 = 'w-40'
39+
40+
const widthMapping: { [key in LanguagesAbbreviations]: string } = {
41+
en: timerIsRunning ? width28 : timerCanReset ? width32 : width24,
42+
'pt-BR': timerIsRunning ? width32 : width40,
43+
pt: timerIsRunning ? width32 : width40,
3944
}
4045

41-
function getWidthClass(): string {
42-
const width =
46+
function getWidthClass(): string | undefined {
47+
return (
4348
widthMapping[i18n.language as LanguagesAbbreviations] ||
44-
(timerIsRunning ? 28 : timerCanReset ? 32 : 24)
45-
46-
return `w-${width}`
49+
(timerIsRunning ? width28 : timerCanReset ? width32 : width24)
50+
)
4751
}
4852

4953
return (
5054
<Button
5155
className={cn(
52-
'bg-green-500 transition-all hover:bg-green-600',
53-
'disabled:hover:bg-green-500',
56+
'bg-green-500 hover:bg-green-600 disabled:hover:bg-green-500',
5457
getWidthClass(),
5558
)}
5659
disabled={disabled}

0 commit comments

Comments
 (0)