@@ -44,8 +44,11 @@ import {
4444 getLibraryLayoutVersion ,
4545 getLibraryTabLinkOptions ,
4646 getMenuGroupInitialOpenState ,
47- isChartsCatalogTarget ,
4847} from './library-layout-navigation'
48+ import {
49+ customToolTabs ,
50+ isCustomToolTarget ,
51+ } from '~/libraries/custom-tool-tabs'
4952
5053// Number of days a doc page is flagged as "New"/"Updated" in the sidebar.
5154const RECENCY_WINDOW_DAYS = 7
@@ -675,18 +678,6 @@ const useMenuConfig = ({
675678 const currentFramework = useCurrentFramework ( frameworks )
676679 const statsAvailable =
677680 getLibrary ( libraryId as LibraryId ) . statsAvailable !== false
678- const chartsExamplesMenuItems : MenuItem [ 'children' ] = [
679- {
680- label : 'Examples' ,
681- to : '/charts/catalog' ,
682- tab : 'home' ,
683- } ,
684- {
685- label : 'Examples' ,
686- to : '/charts/catalog' ,
687- tab : 'examples' ,
688- } ,
689- ]
690681
691682 const localMenu : MenuItem = {
692683 label : 'Menu' ,
@@ -695,7 +686,6 @@ const useMenuConfig = ({
695686 label : 'Home' ,
696687 to : '..' ,
697688 } ,
698- ...( libraryId === 'charts' ? chartsExamplesMenuItems : [ ] ) ,
699689 {
700690 label : 'Blog' ,
701691 to : '/$libraryId/$version/docs/blog' ,
@@ -830,17 +820,7 @@ export function LibraryLayout({
830820 const menuConfig = useMenuConfig ( { config, frameworks, repo, libraryId } )
831821 const libraryGroupColor = categoryTextColor [ categoryOf ( libraryId ) ]
832822
833- const isExample = matches . some (
834- ( d ) =>
835- d . pathname . includes ( '/examples/' ) ||
836- d . routeId . startsWith ( '/_library/charts/catalog' ) ,
837- )
838-
839- const isThemeEditor = matches . some ( ( d ) =>
840- d . routeId . startsWith ( '/_library/highlight/$version/theme-editor' ) ,
841- )
842-
843- const isNpmStats = matches . some ( ( d ) => d . pathname . includes ( '/docs/npm-stats' ) )
823+ const docsTab = matches . find ( ( d ) => d . staticData . docsTab ) ?. staticData . docsTab
844824
845825 // The library blog already lists posts, so the "Latest Posts" rail widget is
846826 // redundant there — hide it on the blog while keeping it on other docs pages.
@@ -872,60 +852,17 @@ export function LibraryLayout({
872852 } , [ closeMobileMenu , mobileMenuOpen ] )
873853
874854 const tabbedMenuConfig = React . useMemo ( ( ) => {
875- const tabs = getTabbedMenuConfig ( menuConfig )
876-
877- if ( libraryId === 'charts' ) {
878- return tabs . map ( ( tab ) =>
879- tab . id === 'examples'
880- ? {
881- ...tab ,
882- firstItem : {
883- label : 'Examples' ,
884- to : '/charts/catalog' ,
885- tab : 'examples' ,
886- } ,
887- }
888- : tab ,
889- )
890- }
891-
892- if ( libraryId === 'highlight' ) {
893- return [
894- ...tabs ,
895- {
896- id : 'theme-editor' as const ,
897- label : 'Theme Editor' ,
898- groups : [ ] ,
899- firstItem : {
900- label : 'Theme Editor' ,
901- to : '/highlight/$version/theme-editor' ,
902- tab : 'theme-editor' as const ,
903- } ,
904- } ,
905- ]
906- }
907-
908- return tabs
855+ return getTabbedMenuConfig ( menuConfig , customToolTabs [ libraryId ] )
909856 } , [ libraryId , menuConfig ] )
910857
911858 const activeTabId = React . useMemo ( ( ) => {
912- if ( isThemeEditor ) {
913- return 'theme-editor' as const
914- }
915-
916859 return getActiveDocsNavTabId ( {
917- isExample ,
860+ tabIdOverride : docsTab ?. id ,
918861 menuConfig,
919862 pathname : lastMatch . pathname ,
920863 relativePathname,
921864 } )
922- } , [
923- isExample ,
924- isThemeEditor ,
925- lastMatch . pathname ,
926- menuConfig ,
927- relativePathname ,
928- ] )
865+ } , [ docsTab ?. id , lastMatch . pathname , menuConfig , relativePathname ] )
929866
930867 const visibleMenuConfig = React . useMemo ( ( ) => {
931868 return (
@@ -964,11 +901,12 @@ export function LibraryLayout({
964901
965902 const groupInitialOpenState = React . useMemo ( ( ) => {
966903 return getMenuGroupInitialOpenState (
904+ libraryId ,
967905 visibleMenuConfig ,
968906 _splat ,
969907 lastMatch . pathname ,
970908 )
971- } , [ lastMatch . pathname , visibleMenuConfig , _splat ] )
909+ } , [ libraryId , lastMatch . pathname , visibleMenuConfig , _splat ] )
972910
973911 const [ openGroups , setOpenGroups ] = React . useState ( groupInitialOpenState )
974912
@@ -1042,7 +980,7 @@ export function LibraryLayout({
1042980 ? ( { libraryId, version } as never )
1043981 : undefined
1044982 const isHomeLink = child . to === '..'
1045- const isChartsExamplesLink = isChartsCatalogTarget ( child . to )
983+ const isCustomToolLink = isCustomToolTarget ( libraryId , child . to )
1046984 const frameworkDocsTarget = getFrameworkDocsLinkTarget ( child . to )
1047985
1048986 const recency = getDocRecency ( child . addedAt , child . updatedAt )
@@ -1130,14 +1068,12 @@ export function LibraryLayout({
11301068 ) : (
11311069 < Link
11321070 from = {
1133- isChartsExamplesLink
1134- ? undefined
1135- : '/$libraryId/$version/docs'
1071+ isCustomToolLink ? undefined : '/$libraryId/$version/docs'
11361072 }
11371073 to = { child . to }
11381074 params = { linkParams }
11391075 onClick = { closeMobileMenu }
1140- preload = { isChartsExamplesLink ? false : 'intent' }
1076+ preload = { isCustomToolLink ? false : 'intent' }
11411077 activeOptions = { {
11421078 exact : true ,
11431079 includeHash : false ,
@@ -1244,8 +1180,7 @@ export function LibraryLayout({
12441180 params = { linkOptions . params as never }
12451181 onClick = { closeMobileMenu }
12461182 preload = {
1247- isChartsCatalogTarget ( target . to ) ||
1248- target . to === '/highlight/$version/theme-editor'
1183+ isCustomToolTarget ( libraryId , target . to )
12491184 ? false
12501185 : 'intent'
12511186 }
@@ -1421,10 +1356,7 @@ export function LibraryLayout({
14211356 to = { linkOptions . to as never }
14221357 params = { linkOptions . params as never }
14231358 preload = {
1424- isChartsCatalogTarget ( target . to ) ||
1425- target . to === '/highlight/$version/theme-editor'
1426- ? false
1427- : 'intent'
1359+ isCustomToolTarget ( libraryId , target . to ) ? false : 'intent'
14281360 }
14291361 activeOptions = { {
14301362 exact : true ,
@@ -1545,18 +1477,21 @@ export function LibraryLayout({
15451477 ! isLandingPage && 'px-4 md:px-8' ,
15461478
15471479 ! isLandingPage &&
1548- ! isExample &&
1549- ! isNpmStats &&
1550- ! isThemeEditor &&
1480+ ! docsTab ?. fullBleed &&
15511481 'mx-auto w-[var(--docs-content-width,900px)]' ,
15521482 ) }
15531483 >
15541484 { landingBreadcrumbItems && (
1555- < div className = "px-4 pt-4 md:px-8" >
1556- < Breadcrumbs
1557- section = "Libraries"
1558- items = { landingBreadcrumbItems }
1559- />
1485+ // Overlays the hero's top padding; matches the hero container so it aligns with the logo.
1486+ < div className = "pointer-events-none absolute inset-x-0 top-0 z-10" >
1487+ < div className = "mx-auto w-full max-w-384 px-5 pt-4 md:px-10 lg:px-12 lg:pt-5 2xl:px-20" >
1488+ < div className = "pointer-events-auto w-fit" >
1489+ < Breadcrumbs
1490+ section = "Libraries"
1491+ items = { landingBreadcrumbItems }
1492+ />
1493+ </ div >
1494+ </ div >
15601495 </ div >
15611496 ) }
15621497 { children }
0 commit comments