-
Notifications
You must be signed in to change notification settings - Fork 244
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
feat: use a drawer for the streaks tooltip on mobile #2920
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
import React, { ReactElement, useMemo } from 'react'; | ||
import { addDays, isSameDay, subDays } from 'date-fns'; | ||
import { useQuery } from '@tanstack/react-query'; | ||
import classNames from 'classnames'; | ||
import { StreakSection } from './StreakSection'; | ||
import { DayStreak, Streak } from './DayStreak'; | ||
import { generateQueryKey, RequestKey, StaleTime } from '../../../lib/query'; | ||
|
@@ -24,10 +25,12 @@ const streakDays = [ | |
|
||
interface ReadingStreakPopupProps { | ||
streak: UserStreak; | ||
fullWidth?: boolean; | ||
} | ||
|
||
export function ReadingStreakPopup({ | ||
streak, | ||
fullWidth, | ||
}: ReadingStreakPopupProps): ReactElement { | ||
const { user } = useAuthContext(); | ||
const { data: history } = useQuery( | ||
|
@@ -83,7 +86,14 @@ export function ReadingStreakPopup({ | |
<StreakSection streak={streak.current} label="Current streak" /> | ||
<StreakSection streak={streak.max} label="Longest streak 🏆" /> | ||
</div> | ||
<div className="mt-6 flex flex-row gap-2">{streaks}</div> | ||
<div | ||
className={classNames( | ||
'mt-6 flex flex-row gap-2', | ||
fullWidth && 'justify-between', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We could've maybe used a className object prop here, but I really don't have a strong opinion here. Just makes it more flexible. Not necessary, this is optional. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. since it's a classname specific to the streak days list, we would have to create a |
||
)} | ||
> | ||
{streaks} | ||
</div> | ||
<div className="mt-4 text-center font-bold leading-8 text-text-tertiary"> | ||
Total reading days: {streak.total} | ||
</div> | ||
|
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.
Since there is content when it is not compact, I think we should also include the condition.
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.
Not sure I follow your comment here, the conditional wrapper is only for the
Tooltip
, which dictates wether it's wrapped around the button on non-mobile resolutions. It should have nothing to do with thecompact
property 🤔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.
Yep, but the thing is, we only display tooltip for buttons without text. Which when compact is applied, there is no text, and only when should be applied.
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.
but tooltips are not a thing on mobile, right? so including
compact
here would not really matter.Also, since the
Tooltip
orCustomStreaksTooltip
is not dictated bycompact
, I feel like we could mistakenly create a situation where someone uses thecompact
version and ends up displaying both the main streaks tooltip and the drawer. I would suggest we tinker with this only if the situation arises that requires it, WDYT?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.
Ah, okay, I misunderstood, I thought this is only for tooltip to display a text. In that case, feel free to ignore and move on.