import { DocsLogo, mergeClasses } from '@expo/styleguide'; import { PlanEnterpriseIcon, BookOpen02Icon, GraduationHat02Icon, Home02Icon, Hash02Icon, } from '@expo/styleguide-icons'; import type { AlgoliaItemType } from '../types'; import { getContentHighlightHTML, getHighlightHTML, isReferencePath, isEASPath, isHomePath, isLearnPath, } from '../utils'; import { CommandItemBase } from './CommandItemBase'; import { FootnoteSection } from './FootnoteSection'; import { FootnoteArrowIcon } from './icons'; import versions from '~/public/static/constants/versions.json'; import { CALLOUT, CAPTION, FOOTNOTE } from '~/ui/components/Text'; const { LATEST_VERSION } = versions; type Props = { item: AlgoliaItemType; onSelect?: () => void; isNested?: boolean; }; type ItemIconProps = { url: string; className?: string; isNested?: boolean; }; const isDev = process.env.NODE_ENV === 'development'; const ItemIcon = ({ url, className, isNested }: ItemIconProps) => { if (isNested) { return ; } else if (isReferencePath(url)) { return ; } else if (isEASPath(url)) { return ; } else if (isHomePath(url)) { return ; } else if (isLearnPath(url)) { return ; } return ; }; const getFootnotePrefix = (url: string) => { if (isReferencePath(url)) { return 'Reference'; } else if (isEASPath(url)) { return 'Expo Application Services'; } else if (isHomePath(url)) { return 'Home'; } else if (isLearnPath(url)) { return 'Learn'; } else { return 'Guides'; } }; const ItemFootnotePrefix = ({ url, isNested = false }: { url: string; isNested?: boolean }) => { return isNested ? ( <> {getFootnotePrefix(url)} ) : ( {getFootnotePrefix(url)} ); }; const transformUrl = (url: string) => { if (url.includes(LATEST_VERSION)) { url = url.replace(LATEST_VERSION, 'latest'); } if (isDev) { url = url.replace('https://docs.expo.dev/', 'http://localhost:3002/'); } // If viewing a docs preview hosted on S3, use the current origin instead of production if (window?.location?.origin?.includes('s3-website-us-east-1.amazonaws.com')) { url = url.replace('https://docs.expo.dev/', window.location.origin + '/'); } return url; }; export const ExpoDocsItem = ({ item, onSelect, isNested }: Props) => { const { lvl0, lvl2, lvl3, lvl4, lvl6 } = item.hierarchy; const TitleElement = isNested ? FOOTNOTE : CALLOUT; const ContentElement = isNested ? CAPTION : FOOTNOTE; const titleWeight = isNested ? 'regular' : 'medium'; return (
{lvl6 && ( <> {!isNested && ( )} )} {!lvl6 && lvl4 && ( <> {!isNested && ( )} )} {!lvl6 && !lvl4 && lvl3 && ( <> {!isNested && ( )} )} {!lvl6 && !lvl4 && !lvl3 && lvl2 && ( <> {!isNested && ( )} )} {!lvl6 && !lvl4 && !lvl3 && !lvl2 && lvl0 && ( <> )} {(!isNested || item.content) && ( )}
); };