@@ -31,15 +31,13 @@ import YouWillLearnCard from './YouWillLearnCard';
3131import { Challenges , Hint , Solution } from './Challenges' ;
3232import { IconNavArrow } from '../Icon/IconNavArrow' ;
3333import ButtonLink from 'components/ButtonLink' ;
34-
3534import { TeamMember } from './TeamMember' ;
36- import { LanguagesContext } from './LanguagesContext' ;
37- import { finishedTranslations } from 'utils/finishedTranslations' ;
38-
3935import ErrorDecoder from './ErrorDecoder' ;
4036import { IconCanary } from '../Icon/IconCanary' ;
4137import { InlineToc } from './InlineToc' ;
4238import { Illustration , IllustrationBlock } from './Illustration' ;
39+ import { LanguageList } from './LanguageList' ;
40+ import { Divider , LI , OL , P , Strong , UL } from './Primitives' ;
4341
4442function CodeStep ( { children, step} : { children : any ; step : number } ) {
4543 return (
@@ -63,27 +61,6 @@ function CodeStep({children, step}: {children: any; step: number}) {
6361 ) ;
6462}
6563
66- const P = ( p : HTMLAttributes < HTMLParagraphElement > ) => (
67- < p className = "whitespace-pre-wrap my-4" { ...p } />
68- ) ;
69-
70- const Strong = ( strong : HTMLAttributes < HTMLElement > ) => (
71- < strong className = "font-bold" { ...strong } />
72- ) ;
73-
74- const OL = ( p : HTMLAttributes < HTMLOListElement > ) => (
75- < ol className = "ms-6 my-3 list-decimal" { ...p } />
76- ) ;
77- const LI = ( p : HTMLAttributes < HTMLLIElement > ) => (
78- < li className = "leading-relaxed mb-1" { ...p } />
79- ) ;
80- const UL = ( p : HTMLAttributes < HTMLUListElement > ) => (
81- < ul className = "ms-6 my-3 list-disc" { ...p } />
82- ) ;
83-
84- const Divider = ( ) => (
85- < hr className = "my-6 block border-b border-t-0 border-border dark:border-border-dark" />
86- ) ;
8764const Wip = ( { children} : { children : React . ReactNode } ) => (
8865 < ExpandableCallout type = "wip" > { children } </ ExpandableCallout >
8966) ;
@@ -235,132 +212,6 @@ function Recipes(props: any) {
235212 return < Challenges { ...props } isRecipes = { true } /> ;
236213}
237214
238- // const IllustrationContext = React.createContext<{
239- // isInBlock?: boolean;
240- // }>({
241- // isInBlock: false,
242- // });
243-
244- // function Illustration({
245- // caption,
246- // src,
247- // alt,
248- // author,
249- // authorLink,
250- // }: {
251- // caption: string;
252- // src: string;
253- // alt: string;
254- // author: string;
255- // authorLink: string;
256- // }) {
257- // const {isInBlock} = React.useContext(IllustrationContext);
258-
259- // return (
260- // <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">
261- // <figure className="my-8 flex justify-center">
262- // <img
263- // src={src}
264- // alt={alt}
265- // style={{maxHeight: 300}}
266- // className="rounded-lg"
267- // />
268- // {caption ? (
269- // <figcaption className="text-center leading-tight mt-4">
270- // {caption}
271- // </figcaption>
272- // ) : null}
273- // </figure>
274- // {!isInBlock && <AuthorCredit author={author} authorLink={authorLink} /> }
275- // </div>
276- // );
277- // }
278-
279- const isInBlockTrue = { isInBlock : true } ;
280-
281- // function IllustrationBlock({
282- // sequential,
283- // author,
284- // authorLink,
285- // children,
286- // }: {
287- // author: string;
288- // authorLink: string;
289- // sequential: boolean;
290- // children: any;
291- // }) {
292- // const imageInfos = Children.toArray(children).map(
293- // (child: any) => child.props
294- // );
295- // const images = imageInfos.map((info, index) => (
296- // <figure key={index}>
297- // <div className="bg-white rounded-lg p-4 flex-1 flex xl:p-6 justify-center items-center my-4">
298- // <img
299- // className="text-primary"
300- // src={info.src}
301- // alt={info.alt}
302- // height={info.height}
303- // />
304- // </div>
305- // {info.caption ? (
306- // <figcaption className="text-secondary dark:text-secondary-dark text-center leading-tight mt-4">
307- // {info.caption}
308- // </figcaption>
309- // ) : null}
310- // </figure>
311- // ));
312- // return (
313- // <IllustrationContext.Provider value={isInBlockTrue}>
314- // <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">
315- // {sequential ? (
316- // <ol className="mdx-illustration-block flex">
317- // {images.map((x: any, i: number) => (
318- // <li className="flex-1" key={i}>
319- // {x}
320- // </li>
321- // ))}
322- // </ol>
323- // ) : (
324- // <div className="mdx-illustration-block">{images}</div>
325- // )}
326- // <AuthorCredit author={author} authorLink={authorLink} />
327- // </div>
328- // </IllustrationContext.Provider>
329- // );
330- // }
331-
332- type TranslationProgress = 'complete' | 'in-progress' ;
333-
334- function LanguageList ( { progress} : { progress : TranslationProgress } ) {
335- const allLanguages = React . useContext ( LanguagesContext ) ?? [ ] ;
336- const languages = allLanguages
337- . filter (
338- ( { code} ) =>
339- code !== 'en' &&
340- ( progress === 'complete'
341- ? finishedTranslations . includes ( code )
342- : ! finishedTranslations . includes ( code ) )
343- )
344- . sort ( ( a , b ) => a . enName . localeCompare ( b . enName ) ) ;
345- return (
346- < UL >
347- { languages . map ( ( { code, name, enName} ) => {
348- return (
349- < LI key = { code } >
350- < Link href = { `https://${ code } .react.dev/` } >
351- { enName } ({ name } )
352- </ Link > { ' ' }
353- —{ ' ' }
354- < Link href = { `https://github.com/reactjs/${ code } .react.dev` } >
355- Contribute
356- </ Link >
357- </ LI >
358- ) ;
359- } ) }
360- </ UL >
361- ) ;
362- }
363-
364215function YouTubeIframe ( props : any ) {
365216 return (
366217 < div className = "relative h-0 overflow-hidden pt-[56.25%]" >
0 commit comments