1- import { useRef } from "react"
1+ import { useRef , useState } from "react"
22import { useInView } from "motion/react"
33import dynamic from "next/dynamic"
4+ import { clsx } from "clsx"
45
56import { Button } from "@/app/conf/_design-system/button"
67import { SectionLabel } from "@/app/conf/_design-system/section-label"
8+ import InfoIcon from "@/app/conf/_design-system/pixelarticons/info.svg?svgr"
79import {
810 HowItWorks_Schema ,
911 HowItWorks_Query ,
@@ -12,6 +14,7 @@ import {
1214
1315import { HowItWorksListItem } from "./how-it-works-list-item"
1416import { PlayButton } from "./play-button"
17+ import { Kbd } from "../../../_design-system/kbd"
1518
1619const InteractiveEditor = dynamic ( ( ) => import ( "./interactive-editor" ) , {
1720 ssr : false ,
@@ -24,6 +27,7 @@ export function HowItWorks() {
2427 // todo: we could technically consider loading the chunk on hover or focus,
2528 // just so people scrolling through the page don't download CodeMirror
2629 const inView = useInView ( sectionRef )
30+ const [ interacted , setInteracted ] = useState ( false )
2731
2832 return (
2933 < section
@@ -55,15 +59,46 @@ export function HowItWorks() {
5559 < ol
5660 // this is rendered *on top* of the static version to avoid layout shift
5761 className = "max-lg:before pointer-events-none absolute inset-0 list-none gap-px [counter-set:list-item_1] *:pointer-events-auto max-lg:before:absolute max-lg:before:inset-x-0 max-lg:before:-top-2 max-lg:before:bottom-[98%] max-lg:before:bg-[rgb(var(--nextra-bg))] max-sm:top-[191px] sm:max-lg:top-[214px] lg:grid lg:grid-cols-3 lg:[&>:first-child]:col-start-2"
62+ onKeyDown = { ( ) => {
63+ if ( ! interacted ) setInteracted ( true )
64+ } }
5865 >
5966 < InteractiveEditor />
6067 </ ol >
6168 ) }
6269 </ div >
70+ < FigureInfo className = { interacted ? "hidden" : "" } />
6371
6472 < Button className = "mx-auto mt-8 w-fit lg:mt-16" href = { TRY_IT_OUT_URL } >
6573 Try GraphiQL
6674 </ Button >
6775 </ section >
6876 )
6977}
78+
79+ function FigureInfo ( { className } : { className ?: string } ) {
80+ return (
81+ < div
82+ className = { clsx (
83+ "typography-body-sm mx-auto mt-12 flex w-fit gap-2 text-neu-800 hover-none:hidden dark:text-neu-600" ,
84+ className ,
85+ ) }
86+ >
87+ < InfoIcon className = "size-4 shrink-0 translate-y-[2.25px]" />
88+ < p className = "text-neu-800" >
89+ Press < Kbd > Ctrl</ Kbd >
90+ < Kbd className = "ml-0.5" > Space</ Kbd > to show the completions, < MetaKey />
91+ < Kbd > Enter</ Kbd > to run the query.
92+ </ p >
93+ </ div >
94+ )
95+ }
96+
97+ function MetaKey ( ) {
98+ return (
99+ < >
100+ < Kbd className = "mx-0.5 hidden [.mac_&]:inline-flex" > ⌘</ Kbd >
101+ < Kbd className = "mx-0.5 [.mac_&]:hidden" > Ctrl</ Kbd >
102+ </ >
103+ )
104+ }
0 commit comments