-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Timer in prompt form #70
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good job overall
src/components/prompt-form.tsx
Outdated
<TooltipProvider delayDuration={0}> | ||
<Tooltip> | ||
<TooltipTrigger> | ||
<span className="text-sm">Odczekaj: {lockDuration}</span> | ||
</TooltipTrigger> | ||
<TooltipContent> | ||
<span> | ||
Ograniczenie jest wprowadzone dla zachowania stabliności | ||
systemu | ||
</span> | ||
</TooltipContent> | ||
</Tooltip> | ||
</TooltipProvider> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: I think we can get the message through with less text upfront. I would add a clock icon with just the seconds remaining next to it, and provide more information only on hover. I think that this being a timeout countdown should be intuitive to majority of users, and this way it looks nicer imo
<TooltipProvider delayDuration={0}> | |
<Tooltip> | |
<TooltipTrigger> | |
<span className="text-sm">Odczekaj: {lockDuration}</span> | |
</TooltipTrigger> | |
<TooltipContent> | |
<span> | |
Ograniczenie jest wprowadzone dla zachowania stabliności | |
systemu | |
</span> | |
</TooltipContent> | |
</Tooltip> | |
</TooltipProvider> | |
<TooltipProvider delayDuration={0}> | |
<Tooltip> | |
<TooltipTrigger className="flex items-center gap-x-1 w-12 text-red-500"> | |
<ClockAlert className="size-4"/> | |
<span>{lockDuration}</span> | |
</TooltipTrigger> | |
<TooltipContent className="text-center"> | |
<span> | |
Odczekaj przed wysłaniem kolejnego żądania | |
<br/> | |
Ograniczenie jest wprowadzone dla zachowania stabilności systemu | |
</span> | |
</TooltipContent> | |
</Tooltip> | |
</TooltipProvider> |
Notes: fixed width on TooltipTrigger
ensures that there's no slight layout shifts when the numbers change
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Notes: fixed width on TooltipTrigger ensures that there's no slight layout shifts when the numbers change
PRly dose of CSS goes here 😂
lastRequestTimestamp
variable to local storage to track when the user sent last request - it's needed to calculate time required to wait for the next requestDate
tostring
and vice versauseEffect
inPromptForm
component where I check if timestamp is already in local storage, calculate delta to decide if button should be enabled and update the lock duration in interval - it happens inuseEffect
since we need to have access to browser local storagesetInterval
is not accurate - if you know better solution feel free to share itHow it looks: