import 'ipfs-css' import React, { type MouseEvent, useEffect, useState } from 'react' import { createRoot } from 'react-dom/client' import { I18nextProvider, useTranslation } from 'react-i18next' import 'tachyons' import i18n from '../src/i18n.js' import { ExplorePage, StartExploringPage, IpldExploreForm, IpldCarExploreForm, ExploreProvider, HeliaProvider, useExplore, useHelia } from '../src/index.js' const HeaderComponent: React.FC = () => { const activeColor = 'navy 0-100' const inActiveColor = 'navy o-50' const [exploreFormType, setExploreFormType] = useState('cid') const [cidColor, setCidColor] = useState(activeColor) const [carColor, setCarColor] = useState(inActiveColor) const { t } = useTranslation('explore') function handleOnChange (evt: MouseEvent): void { const selectedType = evt.currentTarget.getAttribute('data-value') if (selectedType == null) { console.error('No data-value attribute found on the button') return } setExploreFormType(selectedType) if (selectedType === 'cid') { setCidColor(activeColor) setCarColor(inActiveColor) } else { setCidColor(inActiveColor) setCarColor(activeColor) } } return (
{/* IPFS */}
{exploreFormType === 'cid' ? : }

{ t('appName') }

{/* SVG content */}
) } const PageRenderer = (): React.ReactElement => { const { setExplorePath, exploreState: { path } } = useExplore() const { doInitHelia } = useHelia() useEffect(() => { void doInitHelia() // eslint-disable-next-line react-hooks/exhaustive-deps }, []) useEffect(() => { const onHashChange = (): void => { const newRoute = window.location.hash ?? null setExplorePath(newRoute) } window.addEventListener('hashchange', onHashChange) return () => { window.removeEventListener('hashchange', onHashChange) } }, [setExplorePath]) if (path == null || path === '') { return } return } const App = (): React.ReactElement => { return ( ) } const rootEl = document.getElementById('root') if (rootEl == null) { throw new Error('No root element found with the id "root"') } const root = createRoot(rootEl) root.render( )