11
22import { OAuthResult } from '@huggingface/hub'
3- import { Page , getHttpSource } from '@hyparam/components '
4- import { useEffect , useState } from 'react'
3+ import { Config , ConfigProvider , Page , getHttpSource } from 'hyperparam '
4+ import { useEffect , useMemo , useState } from 'react'
55import { fetchOAuth , getLocalOAuth } from '../lib/auth.js'
66import { getHuggingFaceSource } from '../lib/huggingfaceSource.js'
77import Home from './Home.js'
@@ -21,6 +21,16 @@ export default function App() {
2121 const [ accessToken , setAccessToken ] = useState < string | undefined > ( localOAuth ?. accessToken )
2222 const [ requestInit , setRequestInit ] = useState < RequestInit | undefined > ( getRequestInit ( localOAuth ?. accessToken ) )
2323
24+ const config : Config = useMemo ( ( ) => ( {
25+ customClass : {
26+ highTable : 'hightable' ,
27+ } ,
28+ routes : {
29+ getSourceRouteUrl : ( { sourceId } ) => `/?url=${ sourceId } ` ,
30+ getCellRouteUrl : ( { sourceId, col, row } ) => `/?url=${ sourceId } &col=${ col } &row=${ row } ` ,
31+ } ,
32+ } ) , [ ] )
33+
2434 useEffect ( ( ) => {
2535 if ( auth ) return
2636 // no local auth, try to fetch it
@@ -52,10 +62,8 @@ export default function App() {
5262 const defaultUrl = '/?url=https://huggingface.co/datasets/severo/test-parquet/resolve/main/parquet/csv-train-00000-of-00001.parquet'
5363 return < div > Could not load a data source. You have to pass a valid source in the url, eg: < a href = { defaultUrl } > { defaultUrl } </ a > .</ div >
5464 }
55- return < Page source = { source } navigation = { { row, col } } config = { {
56- routes : {
57- getSourceRouteUrl : ( { sourceId } ) => `/?url=${ sourceId } ` ,
58- getCellRouteUrl : ( { sourceId, col, row } ) => `/?url=${ sourceId } &col=${ col } &row=${ row } ` ,
59- } ,
60- } } />
65+
66+ return < ConfigProvider value = { config } >
67+ < Page source = { source } navigation = { { row, col } } />
68+ </ ConfigProvider >
6169}
0 commit comments