Commit bc7eb27
authored
refactor: remove dead layouts, extract shared utilities, and deduplicate docs routes (#1248)
* refactor: remove dead ApiLayout, extract shared loader utilities
- Delete ApiLayout component (unused in production routes)
- Inline makeBreadcrumbs into ApiRoute.res (its only consumer)
- Remove test file that only tested the dead component
- Clean up DocsLayout: remove unused makeBreadcrumbs, NavItem/Category
aliases, and StaticContent module type
- Extract FrontmatterUtils.getField to replace ~150 lines of duplicated
frontmatter switch blocks across 6 route files
- Extract TocUtils.buildEntries to replace duplicated TOC construction
logic across 4 route files
* refactor: introduce DocsLayoutRoute for shared NavbarSecondary
Add a React Router layout route that renders <NavbarSecondary /> and
<Outlet />, eliminating the duplicated <NavbarSecondary /> from 7 child
route modules.
- Create app/layouts/DocsLayoutRoute.res as a layout route
- Nest all docs, API, and syntax-lookup routes under the layout
- Remove <NavbarSecondary /> from ApiOverviewRoute, ApiRoute,
DocsGuidelinesRoute, DocsManualRoute, DocsReactRoute,
SyntaxLookupRoute, and SyntaxLookupDetailRoute
- DocsOverview remains a flat route (it uses MainLayout, not the
docs sidebar pattern)
* refactor: inline ApiOverviewLayout into its route
- Move categories data directly into ApiOverviewRoute.res
- Replace <ApiOverviewLayout.Docs> with <DocsLayout categories theme=#Js>
- Update tests to use DocsLayout and MemoryRouter
- Delete src/layouts/ApiOverviewLayout.res and .resi
* refactor: rename LandingPageLayout to LandingPage
Move from src/layouts/ to src/components/ since it is a self-contained
page component, not a layout wrapper. It does not accept children and
does not provide structural wrapping like the other layouts do.
* refactor: consolidate dual sidebar into DocsLayout
DocsLayout now owns both the desktop sidebar (via SidebarLayout.Sidebar)
and the mobile sidebar (via NavbarTertiary dialog). Routes pass data
instead of constructing sidebar JSX inline.
- Add ~breadcrumbs and ~editHref props to DocsLayout
- DocsLayout renders NavbarTertiary internally with mobile sidebar
- Simplify DocsManualRoute, DocsReactRoute, ApiOverviewRoute, and
DocsGuidelinesRoute by removing ~30 lines of duplicated sidebar
construction and NavbarTertiary rendering from each
- ApiRoute is unchanged (uses a different sidebar structure)
- CommunityRoute is unchanged (already handles both sidebars internally)
* fix: update tests for DocsLayout NavbarTertiary integration
DocsLayout now renders NavbarTertiary internally, which creates a mobile
sidebar dialog. This caused two test issues:
- Duplicate element matches: sidebar text appeared in both the desktop
sidebar and the mobile dialog. Fixed by scoping queries to the
sidebar-content testId.
- Screenshot dimension mismatches: NavbarTertiary adds height to the
rendered layout. Regenerated all affected reference screenshots.
Also fixed BrowserRouter -> MemoryRouter in DocsLayout tests per project
conventions.
* fix: extract DocsSidebar component, keep NavbarTertiary in routes
The previous approach of rendering NavbarTertiary inside DocsLayout
placed it in the wrong DOM position (inside the layout content area
instead of above it), causing visual bugs on mobile and desktop.
Fix by reverting DocsLayout to a simple SidebarLayout wrapper and
extracting the duplicated mobile sidebar JSX into a shared DocsSidebar
component. Routes keep rendering NavbarTertiary at the correct position
(above DocsLayout) but use DocsSidebar to avoid the 25-line copy-paste.
- Create src/components/DocsSidebar.res with shared sidebar content
- Revert DocsLayout to pre-NavbarTertiary state (remove breadcrumbs,
editHref props and NavbarTertiary rendering)
- Update DocsManualRoute, DocsReactRoute, ApiOverviewRoute, and
DocsGuidelinesRoute to use DocsSidebar with NavbarTertiary
- Scope ApiOverviewLayout test sidebar queries to sidebar-content
testId to avoid matching pagination links
- Regenerate reference screenshots1 parent 77d3bb1 commit bc7eb27
33 files changed
Lines changed: 215 additions & 589 deletions
File tree
- __tests__
- __screenshots__
- ApiOverviewLayout_.test.jsx
- DocsLayout_.test.jsx
- app
- layouts
- routes
- src
- common
- components
- layouts
This file was deleted.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
4 | 21 | | |
5 | 22 | | |
6 | 23 | | |
7 | 24 | | |
8 | | - | |
| 25 | + | |
9 | 26 | | |
10 | | - | |
| 27 | + | |
11 | 28 | | |
12 | | - | |
| 29 | + | |
13 | 30 | | |
14 | | - | |
| 31 | + | |
15 | 32 | | |
16 | 33 | | |
17 | | - | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
18 | 37 | | |
19 | 38 | | |
20 | | - | |
| 39 | + | |
21 | 40 | | |
22 | 41 | | |
23 | | - | |
| 42 | + | |
24 | 43 | | |
25 | 44 | | |
26 | | - | |
| 45 | + | |
27 | 46 | | |
28 | 47 | | |
29 | | - | |
| 48 | + | |
30 | 49 | | |
31 | 50 | | |
32 | | - | |
| 51 | + | |
33 | 52 | | |
34 | 53 | | |
35 | 54 | | |
| |||
43 | 62 | | |
44 | 63 | | |
45 | 64 | | |
46 | | - | |
| 65 | + | |
47 | 66 | | |
48 | | - | |
| 67 | + | |
49 | 68 | | |
50 | | - | |
| 69 | + | |
51 | 70 | | |
52 | | - | |
| 71 | + | |
53 | 72 | | |
54 | 73 | | |
55 | | - | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
56 | 77 | | |
57 | 78 | | |
58 | | - | |
| 79 | + | |
59 | 80 | | |
60 | 81 | | |
61 | | - | |
| 82 | + | |
62 | 83 | | |
63 | 84 | | |
64 | 85 | | |
| |||
69 | 90 | | |
70 | 91 | | |
71 | 92 | | |
72 | | - | |
| 93 | + | |
73 | 94 | | |
74 | | - | |
| 95 | + | |
75 | 96 | | |
76 | 97 | | |
77 | 98 | | |
78 | 99 | | |
79 | | - | |
| 100 | + | |
80 | 101 | | |
81 | | - | |
| 102 | + | |
82 | 103 | | |
83 | 104 | | |
84 | 105 | | |
| |||
95 | 116 | | |
96 | 117 | | |
97 | 118 | | |
98 | | - | |
| 119 | + | |
99 | 120 | | |
100 | | - | |
| 121 | + | |
101 | 122 | | |
102 | | - | |
| 123 | + | |
103 | 124 | | |
104 | | - | |
| 125 | + | |
105 | 126 | | |
106 | 127 | | |
107 | | - | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
108 | 131 | | |
109 | 132 | | |
110 | 133 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
35 | | - | |
| 35 | + | |
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
41 | | - | |
| 41 | + | |
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
| |||
61 | 61 | | |
62 | 62 | | |
63 | 63 | | |
64 | | - | |
| 64 | + | |
65 | 65 | | |
66 | 66 | | |
67 | 67 | | |
68 | 68 | | |
69 | 69 | | |
70 | | - | |
| 70 | + | |
71 | 71 | | |
72 | 72 | | |
73 | 73 | | |
| |||
88 | 88 | | |
89 | 89 | | |
90 | 90 | | |
91 | | - | |
| 91 | + | |
92 | 92 | | |
93 | 93 | | |
94 | 94 | | |
95 | 95 | | |
96 | 96 | | |
97 | | - | |
| 97 | + | |
98 | 98 | | |
99 | 99 | | |
100 | 100 | | |
| |||
0 commit comments