|
1 |
| -import { useEffect, useRef } from "react" |
2 |
| -import { PredictableResult } from "../../code-blocks" |
3 |
| -import { Pre } from "nextra/components" |
| 1 | +import { ComponentPropsWithoutRef, useEffect, useRef } from "react" |
| 2 | +import { Pre, Code } from "nextra/components" |
4 | 3 | import { clsx } from "clsx"
|
5 |
| -import classes from "./index.module.css" |
6 | 4 |
|
7 |
| -export function PredictableResults() { |
| 5 | +import PredictableResult from "../../code-blocks/predictable-result.mdx" |
| 6 | + |
| 7 | +import classes from "./precision.module.css" |
| 8 | + |
| 9 | +const components = { |
| 10 | + pre: (props: ComponentPropsWithoutRef<typeof Pre>) => ( |
| 11 | + <Pre |
| 12 | + {...props} |
| 13 | + className={clsx(props.className, "!bg-neu-0/[.48]")} |
| 14 | + tabIndex={-1} |
| 15 | + /> |
| 16 | + ), |
| 17 | + code: Code, |
| 18 | +} |
| 19 | + |
| 20 | +export function PrecisionFigure() { |
8 | 21 | const ref = useRef<HTMLDivElement>(null)
|
| 22 | + |
9 | 23 | useEffect(() => {
|
10 | 24 | const showResponse = (num: Number) => {
|
11 | 25 | const lines = ref.current!.querySelectorAll(
|
@@ -66,51 +80,35 @@ export function PredictableResults() {
|
66 | 80 |
|
67 | 81 | return () => clearTimeout(timer)
|
68 | 82 | }, [])
|
| 83 | + |
| 84 | + const Pre = components.pre |
| 85 | + |
69 | 86 | return (
|
70 |
| - <div className="index-gradient"> |
71 |
| - <section |
72 |
| - className="conf-block container flex flex-col justify-around gap-14 lg:flex-row-reverse lg:items-start lg:*:w-1/2" |
73 |
| - id="predictable-results" |
74 |
| - > |
75 |
| - <div className="max-lg:text-center"> |
76 |
| - <h2> |
77 |
| - Ask for what you need, <br className="max-lg:hidden" /> |
78 |
| - get exactly that |
79 |
| - </h2> |
80 |
| - {/*[Illustration: just a simple query and response?]*/} |
81 |
| - <p> |
82 |
| - Send a GraphQL query to your API and get exactly what you need, |
83 |
| - nothing more and nothing less. GraphQL queries always return |
84 |
| - predictable results. Apps using GraphQL are fast and stable because |
85 |
| - they control the data they get, not the server. |
86 |
| - </p> |
87 |
| - </div> |
88 |
| - <div |
89 |
| - ref={ref} |
90 |
| - className="nextra-codeblocks flex *:w-1/2 [&_pre]:!h-48" |
91 |
| - aria-hidden |
92 |
| - > |
93 |
| - <Pre data-filename="Query" className="p-4"> |
94 |
| - {"{"} |
95 |
| - {"\n hero {"} |
96 |
| - {"\n name"} |
97 |
| - {"\n height\n mass".split("").map((char, i) => ( |
98 |
| - <span key={i} id={"ch" + i} className="hidden"> |
99 |
| - {char === "\n" ? <br /> : char} |
100 |
| - </span> |
101 |
| - ))} |
102 |
| - <span |
103 |
| - className={clsx( |
104 |
| - "-mb-0.5 ml-px inline-block h-4 w-2 !bg-primary/50", |
105 |
| - classes.cursor, |
106 |
| - )} |
107 |
| - /> |
108 |
| - {"\n }"} |
109 |
| - {"\n}"} |
110 |
| - </Pre> |
111 |
| - <PredictableResult /> |
112 |
| - </div> |
113 |
| - </section> |
| 87 | + <div |
| 88 | + ref={ref} |
| 89 | + id="predictable-results" |
| 90 | + className="nextra-codeblocks flex bg-gradient-to-b from-transparent to-sec-lighter px-[14px] py-[30px] *:w-1/2 dark:to-sec-darker/25 [&_pre]:!h-48" |
| 91 | + aria-hidden |
| 92 | + > |
| 93 | + <Pre data-filename="Query" className="p-4"> |
| 94 | + {"{"} |
| 95 | + {"\n hero {"} |
| 96 | + {"\n name"} |
| 97 | + {"\n height\n mass".split("").map((char, i) => ( |
| 98 | + <span key={i} id={"ch" + i} className="hidden"> |
| 99 | + {char === "\n" ? <br /> : char} |
| 100 | + </span> |
| 101 | + ))} |
| 102 | + <span |
| 103 | + className={clsx( |
| 104 | + "-mb-0.5 ml-px inline-block h-4 w-2 !bg-pri-base/50 dark:!bg-sec-base/50", |
| 105 | + classes.cursor, |
| 106 | + )} |
| 107 | + /> |
| 108 | + {"\n }"} |
| 109 | + {"\n}"} |
| 110 | + </Pre> |
| 111 | + <PredictableResult components={components} /> |
114 | 112 | </div>
|
115 | 113 | )
|
116 | 114 | }
|
0 commit comments