Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
2 changes: 1 addition & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ src/ → Core ReScript source code
common/ → Shared utilities, hooks, helpers (non-component modules)
components/ → Reusable React components
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, SidebarNav, etc.)
Comment thread
jderochervlk marked this conversation as resolved.
Outdated
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 __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 __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 __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 __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")
})
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was updated because of the new logo.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion 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 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 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 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 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 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 app/routes/DocsGuidelinesRoute.res
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ let default = () => {

let editHref = `https://github.com/rescript-lang/rescript-lang.org/blob/master/${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 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 @@ -78,7 +78,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 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 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 @@ -71,7 +71,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 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 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
11 changes: 4 additions & 7 deletions src/components/DocsSidebar.res
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
@react.component
let make = (
~categories: array<SidebarLayout.Sidebar.Category.t>,
~activeToc: option<TableOfContents.t>=?,
) => {
let make = (~categories: array<SidebarNav.Category.t>, ~activeToc: option<TableOfContents.t>=?) => {
let {pathname} = ReactRouter.useLocation()
let currentRoute = (pathname :> string)->Url.normalizePath

Expand All @@ -18,16 +15,16 @@ let make = (
<div className="mb-56">
{categories
->Array.map(category => {
let isItemActive = (navItem: SidebarLayout.Sidebar.NavItem.t) =>
let isItemActive = (navItem: SidebarNav.NavItem.t) =>
navItem.href->Url.normalizePath === currentRoute
let getActiveToc = (navItem: SidebarLayout.Sidebar.NavItem.t) =>
let getActiveToc = (navItem: SidebarNav.NavItem.t) =>
if navItem.href->Url.normalizePath === currentRoute {
activeToc
} else {
None
}
<div key=category.name>
<SidebarLayout.Sidebar.Category
<SidebarNav.Category
isItemActive
getActiveToc
category
Expand Down
Loading
Loading