-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: implemented custom timepicker component for the timer * feat: added timer, timer button and dialog * feat: add disabled prop to timepicker * fix: implement PR feedback+fixed sec. display prob * fix: custom duration, NaN check bug, PR feedback * fix: improved number checking * fix: timer display in picker when running * fix: renamed method * feat: added custom confetti when timer ends * fix: rearranged particles packages * fix: simplified timer + new timers start correct * feat: timer can be paused and resumed * feat: add color to timer pausing * fix: removed increment/decrement buttons * fix: button color change, timer edge case * feat: add timer events in the retroContext * feat: timer over retrocontext * fix: time running end condition * fix: remove decrement / increment time * feat: add pause timer functionality * fix: show remaining time when paused * fix: add timer state values on import * fix: renamed button & timer default value * fix: limit input field to max length * feat: error state disables timer start * feat: button wiggles on finish * fix: remove particle modules * fix: timer button is visible while wiggling * fix: cleanup * fix: clean timepicker structure, removed ":" * fix: cleanup * fix: rework WiggleActionButton * fix: renamed CreateTimerDialog * fix: extract finish effect in hook * fix: correct label at timer above 60 minutes * feat: add timer increment buttons * fix: prevent unnecessary effect timeouts * fix: reshape button properties * fix: extract incrementTimerButton * fix: improve timelabel implementation * feat: eslint checks line between functions * fix: internalized label * fix: remove indirection in useValidatedTimeInput * fix: added line between const and function to eslint * fix: restructured components & cleanup * fix: rearranged closing, optimized naming + conditions * feat: add eslint empty line between function & return * fix: set new duration at PAUSE_TIMER * fix: calculate milliseconds extracted to util * fix: remove curly braces * fix: add increment timer state * refactor: rename increment timer action to change timer action * fix: show timer finish animation for participants * refactor: remove unnecessary setting the timer again when pausing the timer --------- Co-authored-by: Manuel Lehé <manuel.lehe@maibornwolff.de> Co-authored-by: Ben Willenbring <ben.willenbring@maibornwolff.de>
- Loading branch information
1 parent
b4f420c
commit c96652c
Showing
25 changed files
with
540 additions
and
15 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
11 changes: 5 additions & 6 deletions
11
packages/frontend/src/common/components/buttons/ActionButton.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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import React from "react"; | ||
import { FlexBox } from "../../common/components/FlexBox"; | ||
import { TextInput } from "../../common/components/TextInput"; | ||
import IncrementTimerButton from "./buttons/IncrementTimerButton"; | ||
interface TimePickerProps { | ||
minutes: string; | ||
seconds: string; | ||
disabled: boolean; | ||
isMinutesError: boolean; | ||
isSecondsError: boolean; | ||
onSecondsChange: (event: React.ChangeEvent<HTMLInputElement>) => void; | ||
onMinutesChange: (event: React.ChangeEvent<HTMLInputElement>) => void; | ||
onSubmit: () => void; | ||
onTimerIncrement: (increment: number) => void; | ||
} | ||
export function TimePicker({ | ||
minutes, | ||
seconds, | ||
disabled, | ||
isMinutesError, | ||
isSecondsError, | ||
onSecondsChange, | ||
onMinutesChange, | ||
onSubmit, | ||
onTimerIncrement, | ||
}: TimePickerProps) { | ||
return ( | ||
<> | ||
<FlexBox gap={2}> | ||
<TextInput | ||
value={minutes} | ||
onChange={onMinutesChange} | ||
onSubmit={onSubmit} | ||
autoFocus | ||
required | ||
disabled={disabled} | ||
type="tel" | ||
error={isMinutesError} | ||
label="Minutes" | ||
/> | ||
<TextInput | ||
value={seconds} | ||
onChange={onSecondsChange} | ||
onSubmit={onSubmit} | ||
required | ||
type="tel" | ||
disabled={disabled} | ||
error={isSecondsError} | ||
label="Seconds" | ||
/> | ||
</FlexBox> | ||
<FlexBox> | ||
<IncrementTimerButton onTimerIncrement={onTimerIncrement} minutesToIncrement={1} /> | ||
<IncrementTimerButton onTimerIncrement={onTimerIncrement} minutesToIncrement={3} /> | ||
<IncrementTimerButton onTimerIncrement={onTimerIncrement} minutesToIncrement={5} /> | ||
</FlexBox> | ||
</> | ||
); | ||
} |
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
20 changes: 20 additions & 0 deletions
20
packages/frontend/src/retro/components/buttons/IncrementTimerButton.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,20 @@ | ||
import React from "react"; | ||
import { ActionButton } from "../../../common/components/buttons/ActionButton"; | ||
|
||
interface IncrementTimerButtonProps { | ||
onTimerIncrement: (amount: number) => void; | ||
minutesToIncrement: number; | ||
} | ||
export default function IncrementTimerButton({ | ||
onTimerIncrement, | ||
minutesToIncrement, | ||
}: IncrementTimerButtonProps) { | ||
return ( | ||
<ActionButton | ||
label={`+${minutesToIncrement} Minutes`} | ||
onClick={() => { | ||
onTimerIncrement(minutesToIncrement); | ||
}} | ||
/> | ||
); | ||
} |
53 changes: 53 additions & 0 deletions
53
packages/frontend/src/retro/components/buttons/ToggleTimerDialogButton.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,53 @@ | ||
import React from "react"; | ||
import { Alarm, SnoozeOutlined } from "@mui/icons-material"; | ||
import { isModerator } from "../../../common/utils/participantsUtils"; | ||
import { TimerDialog } from "../dialogs/TimerDialog"; | ||
import { useRetroContext } from "../../context/RetroContext"; | ||
import { useUserContext } from "../../../common/context/UserContext"; | ||
import { useDialog } from "../../../common/hooks/useDialog"; | ||
import { useTimer } from "../../hooks/useTimer"; | ||
|
||
import { TimerStatus } from "../../types/retroTypes"; | ||
import { WiggleActionButton } from "./WiggleActionButton"; | ||
import useTimedEffect from "../../hooks/useTimedEffect"; | ||
|
||
export function ToggleTimerDialogButton() { | ||
const { isOpen, closeDialog, openDialog } = useDialog(); | ||
const { retroState } = useRetroContext(); | ||
const { timerStatus } = retroState; | ||
const { user } = useUserContext(); | ||
|
||
const { isEffectActive, startEffect } = useTimedEffect({ effectLength: 3000 }); | ||
const { minutes, seconds, remainingTimeLabel } = useTimer({ onTimerFinish: startEffect }); | ||
|
||
function handleOpenDialog() { | ||
if (!isModerator(user)) return; | ||
openDialog(); | ||
} | ||
|
||
if (!isModerator(user) && timerStatus === TimerStatus.STOPPED && !isEffectActive) return null; | ||
|
||
return ( | ||
<> | ||
<WiggleActionButton | ||
onClick={handleOpenDialog} | ||
label={timerStatus !== TimerStatus.STOPPED ? remainingTimeLabel : "Timer"} | ||
icon={timerStatus === TimerStatus.PAUSED ? <SnoozeOutlined /> : <Alarm />} | ||
color={ | ||
timerStatus === TimerStatus.PAUSED | ||
? "info" | ||
: timerStatus === TimerStatus.RUNNING || isEffectActive | ||
? "error" | ||
: undefined | ||
} | ||
isWiggling={isEffectActive} | ||
/> | ||
<TimerDialog | ||
isOpen={isOpen} | ||
close={closeDialog} | ||
remainingMinutes={minutes} | ||
remainingSeconds={seconds} | ||
/> | ||
</> | ||
); | ||
} |
43 changes: 43 additions & 0 deletions
43
packages/frontend/src/retro/components/buttons/WiggleActionButton.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,43 @@ | ||
import React, { MouseEventHandler } from "react"; | ||
import { ButtonProps } from "@mui/material"; | ||
import { keyframes } from "@emotion/react"; | ||
import { ActionButton } from "../../../common/components/buttons/ActionButton"; | ||
|
||
interface WiggleActionButtonProps extends ButtonProps { | ||
onClick: MouseEventHandler<HTMLButtonElement>; | ||
label: string; | ||
icon?: React.ReactNode; | ||
isWiggling: boolean; | ||
} | ||
|
||
export function WiggleActionButton({ | ||
onClick, | ||
label, | ||
icon, | ||
isWiggling, | ||
...props | ||
}: WiggleActionButtonProps) { | ||
const wiggle = keyframes` | ||
0%, 20%, 40%, 60%, 80%, 100% { | ||
transform: rotate(0deg); | ||
} | ||
5%, 25%, 45%, 65%, 85% { | ||
transform: rotate(5deg); | ||
} | ||
10%, 30%, 50%, 70%, 90% { | ||
transform: rotate(-5deg); | ||
} | ||
15%, 35%, 55%, 75%, 95% { | ||
transform: rotate(0deg); | ||
} | ||
`; | ||
return ( | ||
<ActionButton | ||
label={label} | ||
onClick={onClick} | ||
icon={icon} | ||
sx={{ animation: isWiggling ? `${wiggle} 0.5s ease infinite` : undefined }} | ||
{...props} | ||
/> | ||
); | ||
} |
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
Oops, something went wrong.