Skip to content

Feature: Show level previews#24

Merged
gvjacob merged 42 commits into
mainfrom
gn-55
Feb 1, 2023
Merged

Feature: Show level previews#24
gvjacob merged 42 commits into
mainfrom
gn-55

Conversation

@gvjacob

@gvjacob gvjacob commented Jan 31, 2023

Copy link
Copy Markdown
Member

What This Does

  • Show level preview when you hover over a tile or current champ player is on that tile
  • The level preview only uses hardcoded content right now! I want to refactor how we scaffold mock content before wiring this up.
  • Send all tooltips on the board to a div container to avoid z-index issues with the board.
CleanShot.2023-01-31.at.15.32.26.mp4

How to Test

  1. Hover over a tile
  2. Make sure the level preview shows up and does not show a CTA button
  3. Make sure the level preview also changes orientation (where it is anchored relative to the tile) depending on the viewport. For example, the preview should appear below the tile if the tile is close to the top of the screen
  4. Focus on the champ player and move it to a level tile
  5. Make sure the preview appears after a delay of 500ms to avoid rapidly showing previews when you're rapidly moving through the board
  6. Make sure the preview shows a CTA button

Accessibility Checklist

  • Markup uses semantic HTML
  • <img> tags have appropriate alt text
  • Links and buttons have discernable text
  • Form inputs have labels
  • Pages are keyboard accessible & focus states are handled

See the
Playbook accessibility page
for more details.

@linear

linear Bot commented Jan 31, 2023

Copy link
Copy Markdown
GN-55 Preview popovers for level tiles

Tile States - GoNoodle Define (Figma)

Level tiles should provide previews of the level, estimated duration, and energy level. Consider the experience for tablet users as well.

@vercel

vercel Bot commented Jan 31, 2023

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated
supernoodle-prototype ✅ Ready (Inspect) Visit Preview 💬 Add your feedback Feb 1, 2023 at 7:34PM (UTC)

@gvjacob gvjacob changed the title Feature: Show level preivews Feature: Show level previews Jan 31, 2023
# Conflicts:
#	src/components/WorldBoard.tsx
Comment thread src/components/LevelPreview.tsx Outdated
<Image
className="w-full rounded"
src={breatheLevelPreviewThumbnail}
alt="Stack of vibrant discs that expand and contract on inhale and exhale"

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a copywriter can't you tell? 😏

Comment on lines +77 to +78
<Tooltip.Provider>
<Tooltip.Root open={isHovering || isCurrentPlayerPosition}>

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Considered using a Popover from Radix because it seems to be the correct choice based on what we want to achieve here but decided to go with Tooltip for a couple reasons:

  1. We don't want to trigger the preview with a button, which seems to be the intended purpose for Popover
  2. We don't want to trap focus into the preview, which Popover will do.

Although these caveats can be overridden, I think it adds complexity and probably defeats the purpose anyways.


<ChampPlayer classroomChamp={mcpuffersonClassroomChamp} />

<div id="board-tooltips" />

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Decided to portal every tooltip to this container so that it sits above the board and we can avoid funky z-index issues.

Comment thread src/hooks/index.ts
Comment on lines +103 to +109
/**
* Returns a stateful value, and a function to update it with a timeout.
*
* @param initial - initial state value
* @param delay - timeout duration for setting state value
*/
export function useTimeoutState<T>(

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does exactly what it says on the docs, but happy to huddle and explain how this is used in LevelTile!

@gvjacob gvjacob self-assigned this Jan 31, 2023
@gvjacob gvjacob added this to the 0.2.0 milestone Jan 31, 2023
@gvjacob gvjacob marked this pull request as ready for review January 31, 2023 21:02

@RegisBiron RegisBiron left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Screenshot 2023-02-01 at 9 09 49 AM

Should edge cases like this be considered or is it intuitive enough to scroll since the button is hiding behind the bottom UI bar? For example should the tooltip logic account for the UI bar and the tooltip jumps to the top sooner so that the button isn't hidden? I feel like it's intuitive enough to scroll but figured i'd flag this.


<ChampPlayer classroomChamp={mcpuffersonClassroomChamp} />

<div id="board-tooltips" />

@gvjacob gvjacob Feb 1, 2023

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@RegisBiron opening up a thread about your note. It's a good question! I had thought that it's intuitive to scroll down, but do you think it could work better if we give these tooltips a higher z-index than the progress bar or is that weird?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, most users would be using this on a 1920x1080 TV, which I think means this edge case is unlikely

@joshpensky joshpensky left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lookin good! 🤩 Just a few comments/q's

Comment thread src/components/Icons/EnergyBars.tsx Outdated

export default function EnergyBars({ className, energy }: EnergyBarsProps) {
function getBarFillClass(i: number) {
const energies = ["low", "medium", "high"] as Energy[];

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Preference for explicit type declarations over as narrowing!

Suggested change
const energies = ["low", "medium", "high"] as Energy[];
const energies: Energy[] = ["low", "medium", "high"];

Comment thread src/components/LevelPreview.tsx Outdated
Comment thread src/components/LevelPreview.tsx Outdated
);
}

export interface PreviewProps {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

quick fix!

Suggested change
export interface PreviewProps {
export interface LevelPreviewProps {

Comment thread src/components/LevelPreview.tsx Outdated
duration: 0.1,
},
translateY: {
type: "spring",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

non-blocking: the spring felt a bit too bouncy for a tooltip to me, so I played around with a different animation style in #27!

Comment thread src/components/Tile/LevelTile.tsx Outdated
}, [state.context.coordinates, coordinates, setIsCurrentPlayerPosition]);

function onHoverStart() {
setIsHovering(true);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's remove these in favor of the tooltip's onOpenChange event:

<Tooltip.Root open={isHovering || isCurrentPlayerPosition} onOpenChange={setIsHovering} delayDuration={0}>

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@joshpensky we want to keep those because we're detecting the hovers from the motion.div's onHoverStart and onHoverEnd. If we move it to onOpenChange, setIsHovering won't be called!

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh I see, thanks for calling out! Let's keep it as is for now then

Comment thread src/components/Icons/EnergyBars.tsx Outdated
width="3"
height="11"
rx="1.5"
fill="#5D15E3"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tagging the fill attr here !

@catlynbowles catlynbowles left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amazing work ! <3

@joshpensky joshpensky left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work! 💯

@gvjacob gvjacob merged commit 6b5575c into main Feb 1, 2023
@gvjacob gvjacob deleted the gn-55 branch February 1, 2023 20:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants