Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ app/ → React Router app shell (root layout, route definitions, ro
src/ → Core ReScript source code
bindings/ → Zero-cost bindings to JS libraries (@module externals)
common/ → Shared utilities, hooks, helpers (non-component modules)
components/ → Reusable React components
components/ → Reusable React components (e.g. SidebarNav, Breadcrumbs)
ffi/ → Plain JS interop files (prefer %raw over adding new files here)
layouts/ → Page layout components (DocsLayout, SidebarLayout, etc.)
layouts/ → Page layout components (DocsLayout, SidebarPageLayout, etc.)
markdown-pages/ → MDX content (blog posts, docs, community pages, syntax-lookup)
data/ → Hand-curated data (API docs JSON, sidebar ordering)
styles/ → CSS files (Tailwind v4 config in main.css, custom utilities)
Expand Down
2 changes: 1 addition & 1 deletion apps/docs/__tests__/ApiOverviewLayout_.test.res
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
open ReactRouter
open Vitest

let categories: array<SidebarLayout.Sidebar.Category.t> = [
let categories: array<SidebarNav.Category.t> = [
{
name: "Overview",
items: [
Expand Down
58 changes: 58 additions & 0 deletions apps/docs/__tests__/Breadcrumbs_.test.res
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
open ReactRouter
open Vitest

let mockBreadcrumbs: list<Url.breadcrumb> = list{
{Url.name: "Docs", href: "/docs/"},
{Url.name: "Language Manual", href: "/docs/manual/introduction"},
}

test("breadcrumbs render path segments", async () => {
await viewport(1440, 900)

let screen = await render(
<BrowserRouter>
<div dataTestId="breadcrumbs-wrapper">
<Breadcrumbs crumbs=mockBreadcrumbs />
</div>
</BrowserRouter>,
)

let docs = await screen->getByText("Docs")
await element(docs)->toBeVisible

let languageManual = await screen->getByText("Language Manual")
await element(languageManual)->toBeVisible

let wrapper = await screen->getByTestId("breadcrumbs-wrapper")
await element(wrapper)->toMatchScreenshot("sidebar-breadcrumbs")
})

test("breadcrumbs with deep path", async () => {
await viewport(1440, 900)

let deepBreadcrumbs: list<Url.breadcrumb> = list{
{Url.name: "Docs", href: "/docs/"},
{Url.name: "Language Manual", href: "/docs/manual/introduction"},
{Url.name: "Advanced", href: "/docs/manual/advanced"},
}

let screen = await render(
<BrowserRouter>
<div dataTestId="breadcrumbs-wrapper">
<Breadcrumbs crumbs=deepBreadcrumbs />
</div>
</BrowserRouter>,
)

let docs = await screen->getByText("Docs")
await element(docs)->toBeVisible

let languageManual = await screen->getByText("Language Manual")
await element(languageManual)->toBeVisible

let advanced = await screen->getByText("Advanced")
await element(advanced)->toBeVisible

let wrapper = await screen->getByTestId("breadcrumbs-wrapper")
await element(wrapper)->toMatchScreenshot("sidebar-breadcrumbs-deep")
})
4 changes: 2 additions & 2 deletions apps/docs/__tests__/CommunityLayout_.test.res
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
open ReactRouter
open Vitest

let mockCategories: array<SidebarLayout.Sidebar.Category.t> = [
let mockCategories: array<SidebarNav.Category.t> = [
{
name: "Resources",
items: [
Expand Down Expand Up @@ -66,7 +66,7 @@ test("mobile community layout hides sidebar", async () => {
await element(wrapper)->toMatchScreenshot("mobile-community-layout")
})

let mockMultipleCategories: array<SidebarLayout.Sidebar.Category.t> = [
let mockMultipleCategories: array<SidebarNav.Category.t> = [
{
name: "Resources",
items: [
Expand Down
2 changes: 1 addition & 1 deletion apps/docs/__tests__/DocsLayout_.test.res
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
open ReactRouter
open Vitest

let mockCategories: array<SidebarLayout.Sidebar.Category.t> = [
let mockCategories: array<SidebarNav.Category.t> = [
{
name: "Overview",
items: [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
open ReactRouter
open Vitest

let mockCategory: SidebarLayout.Sidebar.Category.t = {
let mockCategory: SidebarNav.Category.t = {
name: "Overview",
items: [
{name: "Introduction", href: "/docs/manual/introduction"},
Expand All @@ -10,18 +10,13 @@ let mockCategory: SidebarLayout.Sidebar.Category.t = {
],
}

let mockBreadcrumbs: list<Url.breadcrumb> = list{
{Url.name: "Docs", href: "/docs/"},
{Url.name: "Language Manual", href: "/docs/manual/introduction"},
}

test("sidebar category renders title and nav items", async () => {
await viewport(1440, 900)

let screen = await render(
<BrowserRouter>
<div dataTestId="category-wrapper">
<SidebarLayout.Sidebar.Category category=mockCategory onClick={_ => ()} />
<SidebarNav.Category category=mockCategory onClick={_ => ()} />
</div>
</BrowserRouter>,
)
Expand All @@ -45,7 +40,7 @@ test("sidebar category highlights active item", async () => {
let screen = await render(
<BrowserRouter>
<div dataTestId="category-wrapper">
<SidebarLayout.Sidebar.Category
<SidebarNav.Category
category=mockCategory
isItemActive={item => item.href == "/docs/manual/introduction"}
onClick={_ => ()}
Expand All @@ -61,27 +56,6 @@ test("sidebar category highlights active item", async () => {
await element(wrapper)->toMatchScreenshot("sidebar-category-active-item")
})

test("breadcrumbs render path segments", async () => {
await viewport(1440, 900)

let screen = await render(
<BrowserRouter>
<div dataTestId="breadcrumbs-wrapper">
<SidebarLayout.BreadCrumbs crumbs=mockBreadcrumbs />
</div>
</BrowserRouter>,
)

let docs = await screen->getByText("Docs")
await element(docs)->toBeVisible

let languageManual = await screen->getByText("Language Manual")
await element(languageManual)->toBeVisible

let wrapper = await screen->getByTestId("breadcrumbs-wrapper")
await element(wrapper)->toMatchScreenshot("sidebar-breadcrumbs")
})

let mockTocEntries: TableOfContents.t = {
title: "Introduction",
entries: [
Expand All @@ -97,7 +71,7 @@ test("sidebar category with active TOC renders entries", async () => {
let screen = await render(
<MemoryRouter initialEntries=["/docs/manual/introduction"]>
<div dataTestId="toc-wrapper">
<SidebarLayout.Sidebar.Category
<SidebarNav.Category
category=mockCategory
isItemActive={item => item.href == "/docs/manual/introduction"}
getActiveToc={item =>
Expand Down Expand Up @@ -128,7 +102,7 @@ test("sidebar category with active TOC renders entries", async () => {
test("sidebar category with many items", async () => {
await viewport(1440, 900)

let largeCategory: SidebarLayout.Sidebar.Category.t = {
let largeCategory: SidebarNav.Category.t = {
name: "All Types",
items: [
{name: "String", href: "/docs/manual/string"},
Expand All @@ -145,7 +119,7 @@ test("sidebar category with many items", async () => {
let screen = await render(
<BrowserRouter>
<div dataTestId="category-wrapper">
<SidebarLayout.Sidebar.Category category=largeCategory onClick={_ => ()} />
<SidebarNav.Category category=largeCategory onClick={_ => ()} />
</div>
</BrowserRouter>,
)
Expand All @@ -159,33 +133,3 @@ test("sidebar category with many items", async () => {
let wrapper = await screen->getByTestId("category-wrapper")
await element(wrapper)->toMatchScreenshot("sidebar-category-many-items")
})

test("breadcrumbs with deep path", async () => {
await viewport(1440, 900)

let deepBreadcrumbs: list<Url.breadcrumb> = list{
{Url.name: "Docs", href: "/docs/"},
{Url.name: "Language Manual", href: "/docs/manual/introduction"},
{Url.name: "Advanced", href: "/docs/manual/advanced"},
}

let screen = await render(
<BrowserRouter>
<div dataTestId="breadcrumbs-wrapper">
<SidebarLayout.BreadCrumbs crumbs=deepBreadcrumbs />
</div>
</BrowserRouter>,
)

let docs = await screen->getByText("Docs")
await element(docs)->toBeVisible

let languageManual = await screen->getByText("Language Manual")
await element(languageManual)->toBeVisible

let advanced = await screen->getByText("Advanced")
await element(advanced)->toBeVisible

let wrapper = await screen->getByTestId("breadcrumbs-wrapper")
await element(wrapper)->toMatchScreenshot("sidebar-breadcrumbs-deep")
})
2 changes: 1 addition & 1 deletion apps/docs/app/routes/ApiDocs.res
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ let make = (props: props) => {
}
}

<SidebarLayout theme=#Reason sidebar rightSidebar> children </SidebarLayout>
<SidebarPageLayout theme=#Reason sidebar rightSidebar> children </SidebarPageLayout>
}

module Data = {
Expand Down
4 changes: 2 additions & 2 deletions apps/docs/app/routes/ApiOverviewRoute.res
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
let categories: array<SidebarLayout.Sidebar.Category.t> = [
let categories: array<SidebarNav.Category.t> = [
{
name: "Overview",
items: [
Expand Down Expand Up @@ -54,7 +54,7 @@ let default = () => {
<>
<Meta title description />
<NavbarTertiary sidebar={<DocsSidebar categories />}>
<SidebarLayout.BreadCrumbs crumbs=breadcrumbs />
<Breadcrumbs crumbs=breadcrumbs />
</NavbarTertiary>
<DocsLayout categories theme=#Js>
<div className="markdown-body">
Expand Down
2 changes: 1 addition & 1 deletion apps/docs/app/routes/ApiOverviewRoute.resi
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
let categories: array<SidebarLayout.Sidebar.Category.t>
let categories: array<SidebarNav.Category.t>

type loaderData = {
compiledMdx: CompiledMdx.t,
Expand Down
2 changes: 1 addition & 1 deletion apps/docs/app/routes/ApiRoute.res
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ let default = () => {
<>
<Meta title description=?docstrings />
<NavbarTertiary sidebar=sidebarContent>
<SidebarLayout.BreadCrumbs crumbs=breadcrumbs />
<Breadcrumbs crumbs=breadcrumbs />
</NavbarTertiary>
<ApiDocs {...loaderData} />
</>
Expand Down
2 changes: 1 addition & 1 deletion apps/docs/app/routes/CommunityRoute.res
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ type loaderData = {
title: string,
description: string,
filePath: string,
categories: array<SidebarLayout.Sidebar.Category.t>,
categories: array<SidebarNav.Category.t>,
}

let communityTableOfContents = async () => {
Expand Down
2 changes: 1 addition & 1 deletion apps/docs/app/routes/CommunityRoute.resi
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ type loaderData = {
title: string,
description: string,
filePath: string,
categories: array<SidebarLayout.Sidebar.Category.t>,
categories: array<SidebarNav.Category.t>,
}

let loader: ReactRouter.Loader.t<loaderData>
Expand Down
2 changes: 1 addition & 1 deletion apps/docs/app/routes/DocsGuidelinesRoute.res
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ let default = () => {
let docsAppRoot = "apps/docs"
let editHref = `https://github.com/rescript-lang/rescript-lang.org/blob/master/${docsAppRoot}/${filePath}`

let categories: array<SidebarLayout.Sidebar.Category.t> = []
let categories: array<SidebarNav.Category.t> = []

<>
<Meta title description />
Expand Down
4 changes: 2 additions & 2 deletions apps/docs/app/routes/DocsManualRoute.res
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
type loaderData = {
compiledMdx: CompiledMdx.t,
categories: array<SidebarLayout.Sidebar.Category.t>,
categories: array<SidebarNav.Category.t>,
entries: array<TableOfContents.entry>,
title: string,
description: string,
Expand Down Expand Up @@ -79,7 +79,7 @@ let default = () => {
<>
<Meta title description />
<NavbarTertiary sidebar={<DocsSidebar categories activeToc />}>
<SidebarLayout.BreadCrumbs crumbs=breadcrumbs />
<Breadcrumbs crumbs=breadcrumbs />
<a
href=editHref className="inline text-14 hover:underline text-fire" rel="noopener noreferrer"
>
Expand Down
2 changes: 1 addition & 1 deletion apps/docs/app/routes/DocsManualRoute.resi
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
type loaderData = {
compiledMdx: CompiledMdx.t,
categories: array<SidebarLayout.Sidebar.Category.t>,
categories: array<SidebarNav.Category.t>,
entries: array<TableOfContents.entry>,
title: string,
description: string,
Expand Down
4 changes: 2 additions & 2 deletions apps/docs/app/routes/DocsReactRoute.res
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
type loaderData = {
compiledMdx: CompiledMdx.t,
categories: array<SidebarLayout.Sidebar.Category.t>,
categories: array<SidebarNav.Category.t>,
entries: array<TableOfContents.entry>,
title: string,
description: string,
Expand Down Expand Up @@ -72,7 +72,7 @@ let default = () => {
<>
<Meta title description />
<NavbarTertiary sidebar={<DocsSidebar categories activeToc />}>
<SidebarLayout.BreadCrumbs crumbs=breadcrumbs />
<Breadcrumbs crumbs=breadcrumbs />
<a
href=editHref className="inline text-14 hover:underline text-fire" rel="noopener noreferrer"
>
Expand Down
2 changes: 1 addition & 1 deletion apps/docs/app/routes/DocsReactRoute.resi
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
type loaderData = {
compiledMdx: CompiledMdx.t,
categories: array<SidebarLayout.Sidebar.Category.t>,
categories: array<SidebarNav.Category.t>,
entries: array<TableOfContents.entry>,
title: string,
description: string,
Expand Down
2 changes: 1 addition & 1 deletion apps/docs/src/common/Url.resi
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ type t = {
pagepath: array<string>,
}

// Moved here from original SidebarLayout.UrlPath
// Moved here from the original sidebar URL helper.
type breadcrumb = {
name: string,
href: string,
Expand Down
Loading
Loading