|
1 | | -'use client'; |
| 1 | +// 'use client'; |
2 | 2 |
|
3 | 3 | /* |
4 | 4 | * Copyright (c) Facebook, Inc. and its affiliates. |
5 | 5 | */ |
6 | 6 |
|
7 | | -import {Children, useContext, useMemo} from 'react'; |
| 7 | +// import {Children, useContext, useMemo} from 'react'; |
8 | 8 | import * as React from 'react'; |
9 | 9 | import cn from 'classnames'; |
10 | 10 | import type {HTMLAttributes} from 'react'; |
@@ -263,99 +263,99 @@ function AuthorCredit({ |
263 | 263 | ); |
264 | 264 | } |
265 | 265 |
|
266 | | -const IllustrationContext = React.createContext<{ |
267 | | - isInBlock?: boolean; |
268 | | -}>({ |
269 | | - isInBlock: false, |
270 | | -}); |
271 | | - |
272 | | -function Illustration({ |
273 | | - caption, |
274 | | - src, |
275 | | - alt, |
276 | | - author, |
277 | | - authorLink, |
278 | | -}: { |
279 | | - caption: string; |
280 | | - src: string; |
281 | | - alt: string; |
282 | | - author: string; |
283 | | - authorLink: string; |
284 | | -}) { |
285 | | - const {isInBlock} = React.useContext(IllustrationContext); |
286 | | - |
287 | | - return ( |
288 | | - <div className="relative group before:absolute before:-inset-y-16 before:inset-x-0 my-16 mx-0 2xl:mx-auto max-w-4xl 2xl:max-w-6xl"> |
289 | | - <figure className="my-8 flex justify-center"> |
290 | | - <img |
291 | | - src={src} |
292 | | - alt={alt} |
293 | | - style={{maxHeight: 300}} |
294 | | - className="rounded-lg" |
295 | | - /> |
296 | | - {caption ? ( |
297 | | - <figcaption className="text-center leading-tight mt-4"> |
298 | | - {caption} |
299 | | - </figcaption> |
300 | | - ) : null} |
301 | | - </figure> |
302 | | - {!isInBlock && <AuthorCredit author={author} authorLink={authorLink} />} |
303 | | - </div> |
304 | | - ); |
305 | | -} |
| 266 | +// const IllustrationContext = React.createContext<{ |
| 267 | +// isInBlock?: boolean; |
| 268 | +// }>({ |
| 269 | +// isInBlock: false, |
| 270 | +// }); |
| 271 | + |
| 272 | +// function Illustration({ |
| 273 | +// caption, |
| 274 | +// src, |
| 275 | +// alt, |
| 276 | +// author, |
| 277 | +// authorLink, |
| 278 | +// }: { |
| 279 | +// caption: string; |
| 280 | +// src: string; |
| 281 | +// alt: string; |
| 282 | +// author: string; |
| 283 | +// authorLink: string; |
| 284 | +// }) { |
| 285 | +// const {isInBlock} = React.useContext(IllustrationContext); |
| 286 | + |
| 287 | +// return ( |
| 288 | +// <div className="relative group before:absolute before:-inset-y-16 before:inset-x-0 my-16 mx-0 2xl:mx-auto max-w-4xl 2xl:max-w-6xl"> |
| 289 | +// <figure className="my-8 flex justify-center"> |
| 290 | +// <img |
| 291 | +// src={src} |
| 292 | +// alt={alt} |
| 293 | +// style={{maxHeight: 300}} |
| 294 | +// className="rounded-lg" |
| 295 | +// /> |
| 296 | +// {caption ? ( |
| 297 | +// <figcaption className="text-center leading-tight mt-4"> |
| 298 | +// {caption} |
| 299 | +// </figcaption> |
| 300 | +// ) : null} |
| 301 | +// </figure> |
| 302 | +// {!isInBlock && <AuthorCredit author={author} authorLink={authorLink} />} |
| 303 | +// </div> |
| 304 | +// ); |
| 305 | +// } |
306 | 306 |
|
307 | 307 | const isInBlockTrue = {isInBlock: true}; |
308 | 308 |
|
309 | | -function IllustrationBlock({ |
310 | | - sequential, |
311 | | - author, |
312 | | - authorLink, |
313 | | - children, |
314 | | -}: { |
315 | | - author: string; |
316 | | - authorLink: string; |
317 | | - sequential: boolean; |
318 | | - children: any; |
319 | | -}) { |
320 | | - const imageInfos = Children.toArray(children).map( |
321 | | - (child: any) => child.props |
322 | | - ); |
323 | | - const images = imageInfos.map((info, index) => ( |
324 | | - <figure key={index}> |
325 | | - <div className="bg-white rounded-lg p-4 flex-1 flex xl:p-6 justify-center items-center my-4"> |
326 | | - <img |
327 | | - className="text-primary" |
328 | | - src={info.src} |
329 | | - alt={info.alt} |
330 | | - height={info.height} |
331 | | - /> |
332 | | - </div> |
333 | | - {info.caption ? ( |
334 | | - <figcaption className="text-secondary dark:text-secondary-dark text-center leading-tight mt-4"> |
335 | | - {info.caption} |
336 | | - </figcaption> |
337 | | - ) : null} |
338 | | - </figure> |
339 | | - )); |
340 | | - return ( |
341 | | - <IllustrationContext.Provider value={isInBlockTrue}> |
342 | | - <div className="relative group before:absolute before:-inset-y-16 before:inset-x-0 my-16 mx-0 2xl:mx-auto max-w-4xl 2xl:max-w-6xl"> |
343 | | - {sequential ? ( |
344 | | - <ol className="mdx-illustration-block flex"> |
345 | | - {images.map((x: any, i: number) => ( |
346 | | - <li className="flex-1" key={i}> |
347 | | - {x} |
348 | | - </li> |
349 | | - ))} |
350 | | - </ol> |
351 | | - ) : ( |
352 | | - <div className="mdx-illustration-block">{images}</div> |
353 | | - )} |
354 | | - <AuthorCredit author={author} authorLink={authorLink} /> |
355 | | - </div> |
356 | | - </IllustrationContext.Provider> |
357 | | - ); |
358 | | -} |
| 309 | +// function IllustrationBlock({ |
| 310 | +// sequential, |
| 311 | +// author, |
| 312 | +// authorLink, |
| 313 | +// children, |
| 314 | +// }: { |
| 315 | +// author: string; |
| 316 | +// authorLink: string; |
| 317 | +// sequential: boolean; |
| 318 | +// children: any; |
| 319 | +// }) { |
| 320 | +// const imageInfos = Children.toArray(children).map( |
| 321 | +// (child: any) => child.props |
| 322 | +// ); |
| 323 | +// const images = imageInfos.map((info, index) => ( |
| 324 | +// <figure key={index}> |
| 325 | +// <div className="bg-white rounded-lg p-4 flex-1 flex xl:p-6 justify-center items-center my-4"> |
| 326 | +// <img |
| 327 | +// className="text-primary" |
| 328 | +// src={info.src} |
| 329 | +// alt={info.alt} |
| 330 | +// height={info.height} |
| 331 | +// /> |
| 332 | +// </div> |
| 333 | +// {info.caption ? ( |
| 334 | +// <figcaption className="text-secondary dark:text-secondary-dark text-center leading-tight mt-4"> |
| 335 | +// {info.caption} |
| 336 | +// </figcaption> |
| 337 | +// ) : null} |
| 338 | +// </figure> |
| 339 | +// )); |
| 340 | +// return ( |
| 341 | +// <IllustrationContext.Provider value={isInBlockTrue}> |
| 342 | +// <div className="relative group before:absolute before:-inset-y-16 before:inset-x-0 my-16 mx-0 2xl:mx-auto max-w-4xl 2xl:max-w-6xl"> |
| 343 | +// {sequential ? ( |
| 344 | +// <ol className="mdx-illustration-block flex"> |
| 345 | +// {images.map((x: any, i: number) => ( |
| 346 | +// <li className="flex-1" key={i}> |
| 347 | +// {x} |
| 348 | +// </li> |
| 349 | +// ))} |
| 350 | +// </ol> |
| 351 | +// ) : ( |
| 352 | +// <div className="mdx-illustration-block">{images}</div> |
| 353 | +// )} |
| 354 | +// <AuthorCredit author={author} authorLink={authorLink} /> |
| 355 | +// </div> |
| 356 | +// </IllustrationContext.Provider> |
| 357 | +// ); |
| 358 | +// } |
359 | 359 |
|
360 | 360 | type NestedTocRoot = { |
361 | 361 | item: null; |
@@ -388,27 +388,27 @@ function calculateNestedToc(toc: Toc): NestedTocRoot { |
388 | 388 | return root; |
389 | 389 | } |
390 | 390 |
|
391 | | -function InlineToc() { |
392 | | - const toc = useContext(TocContext); |
393 | | - const root = useMemo(() => calculateNestedToc(toc), [toc]); |
394 | | - if (root.children.length < 2) { |
395 | | - return null; |
396 | | - } |
397 | | - return <InlineTocItem items={root.children} />; |
398 | | -} |
399 | | - |
400 | | -function InlineTocItem({items}: {items: Array<NestedTocNode>}) { |
401 | | - return ( |
402 | | - <UL> |
403 | | - {items.map((node) => ( |
404 | | - <LI key={node.item.url}> |
405 | | - <Link href={node.item.url}>{node.item.text}</Link> |
406 | | - {node.children.length > 0 && <InlineTocItem items={node.children} />} |
407 | | - </LI> |
408 | | - ))} |
409 | | - </UL> |
410 | | - ); |
411 | | -} |
| 391 | +// function InlineToc() { |
| 392 | +// const toc = useContext(TocContext); |
| 393 | +// const root = useMemo(() => calculateNestedToc(toc), [toc]); |
| 394 | +// if (root.children.length < 2) { |
| 395 | +// return null; |
| 396 | +// } |
| 397 | +// return <InlineTocItem items={root.children} />; |
| 398 | +// } |
| 399 | + |
| 400 | +// function InlineTocItem({items}: {items: Array<NestedTocNode>}) { |
| 401 | +// return ( |
| 402 | +// <UL> |
| 403 | +// {items.map((node) => ( |
| 404 | +// <LI key={node.item.url}> |
| 405 | +// <Link href={node.item.url}>{node.item.text}</Link> |
| 406 | +// {node.children.length > 0 && <InlineTocItem items={node.children} />} |
| 407 | +// </LI> |
| 408 | +// ))} |
| 409 | +// </UL> |
| 410 | +// ); |
| 411 | +// } |
412 | 412 |
|
413 | 413 | type TranslationProgress = 'complete' | 'in-progress'; |
414 | 414 |
|
@@ -500,10 +500,10 @@ export const MDXComponents = { |
500 | 500 | Pitfall, |
501 | 501 | Deprecated, |
502 | 502 | Wip, |
503 | | - Illustration, |
504 | | - IllustrationBlock, |
| 503 | + // Illustration, |
| 504 | + // IllustrationBlock, |
505 | 505 | Intro, |
506 | | - InlineToc, |
| 506 | + // InlineToc, |
507 | 507 | LanguageList, |
508 | 508 | LearnMore, |
509 | 509 | Math, |
|
0 commit comments