Skip to content

Commit 90161c3

Browse files
authored
docs: redesign homepage and improve documentation styling (#13)
- Update basefn from v1.3.0 to v1.8.0 for new component variants - Redesign landing page with centered hero section, gradient title, feature cards with icons, code showcase sections, and bottom CTA - Use Card variant={Outlined} across all API reference and doc pages for consistent card styling - Update CSS to use basefn semantic tokens (--basefn-border-primary, --basefn-bg-tertiary, etc.) instead of legacy --basefn-color-* vars - Add hero, feature section, and code showcase CSS classes with responsive breakpoints - Improve typography spacing and card header monospace font styling - Code blocks: use both github and github-dark highlight.js themes for proper light/dark mode support, remove hardcoded #0d1117 background - Landing page: remove separators, redesign "Why" section with split layout (title+description left, stacked benefits right) - Topbar: single "rescript-signals" title, add nav links (Installation, API Reference, Examples), fetch version from npm registry, add theme toggle and GitHub icon - Doc pages: remove Card wrappers from documentation sections, use heading anchors with # links for all H2/H3 headings - Layout: center doc content with max-width 780px and auto margins - Breadcrumbs: remove "Home" entry, use semantic color tokens - Key characteristics in Computed page: use bullet list instead of cards
1 parent 7b7f4ae commit 90161c3

13 files changed

Lines changed: 787 additions & 423 deletions

docs-website/package-lock.json

Lines changed: 8 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs-website/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313
},
1414
"dependencies": {
1515
"@rescript/core": "^1.6.1",
16+
"basefn": "^1.8.0",
1617
"rescript-signals": "^1.3.3",
17-
"xote": "^4.11.0",
18-
"basefn": "^1.3.0"
18+
"xote": "^4.11.0"
1919
},
2020
"devDependencies": {
2121
"rescript": "^12.0.0",

docs-website/src/App.res

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,22 @@ open Xote
22
open Xote.ReactiveProp
33
open Basefn
44

5-
let version = "1.3.3"
5+
// Fetch latest version from npm registry
6+
@val external fetch: string => promise<'a> = "fetch"
7+
@send external json: 'a => promise<'b> = "json"
8+
9+
let npmVersion = Signal.make("...")
10+
11+
let _ = fetch("https://registry.npmjs.org/rescript-signals/latest")
12+
->Promise.then(response => response->json)
13+
->Promise.then((data: {"version": string}) => {
14+
Signal.set(npmVersion, data["version"])
15+
Promise.resolve()
16+
})
17+
->Promise.catch(_ => {
18+
Signal.set(npmVersion, "1.3.3")
19+
Promise.resolve()
20+
})
621

722
// Helper to check if a URL matches the current path
823
let isActive = (url: string, pathname: string) => {
@@ -44,20 +59,27 @@ let make = () => {
4459

4560
let logo =
4661
<Router.Link to="/" style="text-decoration: none; color: inherit;">
47-
<Typography text={static("ReScript Signals")} variant={H4} />
62+
<Typography text={static("rescript-signals")} variant={H4} />
4863
</Router.Link>
4964

5065
let topbarLeft =
51-
<Router.Link to="/" style="text-decoration: none; color: inherit; display: flex; align-items: center; gap: 0.75rem;">
52-
<Typography text={static("ReScript Signals")} variant={H5} />
53-
<Badge label={Signal.make("v" ++ version)} variant={Secondary} />
54-
</Router.Link>
66+
<div style="display: flex; align-items: center; gap: 1rem;">
67+
<Router.Link to="/" style="text-decoration: none; color: inherit; display: flex; align-items: center;">
68+
<Typography text={static("rescript-signals")} variant={H5} />
69+
</Router.Link>
70+
<div class="topbar-nav-links">
71+
<Router.Link to="/getting-started"> {Component.text("Installation")} </Router.Link>
72+
<Router.Link to="/api/signal"> {Component.text("API Reference")} </Router.Link>
73+
<Router.Link to="/examples"> {Component.text("Examples")} </Router.Link>
74+
</div>
75+
</div>
5576

5677
let topbarRight =
57-
<div style="display: flex; align-items: center; gap: 1rem;">
78+
<div style="display: flex; align-items: center; gap: 0.75rem;">
5879
<div style="width: 200px;">
5980
<Search />
6081
</div>
82+
<Badge label={Computed.make(() => "v" ++ Signal.get(npmVersion))} variant={Secondary} size={Sm} />
6183
<a
6284
href="https://github.com/brnrdog/rescript-signals"
6385
target="_blank"
@@ -87,7 +109,7 @@ let make = () => {
87109
[
88110
<div style="min-height: 100vh; display: flex; flex-direction: column;">
89111
{topbar}
90-
<main style="flex: 1; padding: 2rem; max-width: 1200px; margin: 0 auto; width: 100%;">
112+
<main style="flex: 1;">
91113
{routes}
92114
</main>
93115
</div>,
@@ -97,7 +119,7 @@ let make = () => {
97119
let sidebar = <Sidebar logo sections />
98120
[
99121
<AppLayout sidebar topbar>
100-
<div style="padding: 2rem; max-width: 900px;">
122+
<div class="doc-content">
101123
<Breadcrumbs />
102124
{routes}
103125
<PageNavigation />

docs-website/src/components/Breadcrumbs.res

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,13 @@ type breadcrumb = {
77

88
// Map paths to their breadcrumb hierarchy
99
let getBreadcrumbs = (pathname: string): array<breadcrumb> => {
10-
let home = {label: "Home", url: Some("/")}
11-
1210
switch pathname {
13-
| "/getting-started" => [home, {label: "Getting Started", url: None}]
14-
| "/api/signal" => [home, {label: "API Reference", url: None}, {label: "Signal", url: None}]
15-
| "/api/computed" => [home, {label: "API Reference", url: None}, {label: "Computed", url: None}]
16-
| "/api/effect" => [home, {label: "API Reference", url: None}, {label: "Effect", url: None}]
17-
| "/examples" => [home, {label: "Examples", url: None}]
18-
| "/release-notes" => [home, {label: "Release Notes", url: None}]
11+
| "/getting-started" => [{label: "Getting Started", url: None}]
12+
| "/api/signal" => [{label: "API Reference", url: None}, {label: "Signal", url: None}]
13+
| "/api/computed" => [{label: "API Reference", url: None}, {label: "Computed", url: None}]
14+
| "/api/effect" => [{label: "API Reference", url: None}, {label: "Effect", url: None}]
15+
| "/examples" => [{label: "Examples", url: None}]
16+
| "/release-notes" => [{label: "Release Notes", url: None}]
1917
| _ => []
2018
}
2119
}
@@ -32,27 +30,27 @@ let make = () => {
3230
[]
3331
} else {
3432
[
35-
<nav style="margin-bottom: 1rem;">
36-
<div style="display: flex; align-items: center; gap: 0.5rem; font-size: 0.875rem; color: var(--basefn-color-muted);">
33+
<nav style="margin-bottom: 1.5rem;">
34+
<div style="display: flex; align-items: center; gap: 0.5rem; font-size: 0.875rem; color: var(--basefn-text-tertiary);">
3735
{Component.fragment(
3836
crumbs->Array.mapWithIndex((crumb, idx) => {
3937
let isLast = idx == Array.length(crumbs) - 1
4038
let separator = if !isLast {
41-
<span style="color: var(--basefn-color-muted);"> {"/"->Component.text} </span>
39+
<span style="color: var(--basefn-text-muted);"> {"/"->Component.text} </span>
4240
} else {
4341
<span />
4442
}
4543

4644
switch crumb.url {
4745
| Some(url) =>
4846
<span>
49-
<Router.Link to={url} style="color: var(--basefn-color-muted); text-decoration: none;">
47+
<Router.Link to={url} style="color: var(--basefn-text-tertiary); text-decoration: none;">
5048
{crumb.label->Component.text}
5149
</Router.Link>
5250
{separator}
5351
</span>
5452
| None =>
55-
<span style={isLast ? "color: var(--basefn-color-foreground);" : ""}>
53+
<span style={isLast ? "color: var(--basefn-text-primary);" : ""}>
5654
{crumb.label->Component.text}
5755
{separator}
5856
</span>

docs-website/src/components/CodeBlock.res

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ open Xote
22
open Xote.ReactiveProp
33
open Basefn
44

5+
%%raw(`import 'highlight.js/styles/github.min.css'`)
56
%%raw(`import 'highlight.js/styles/github-dark.min.css'`)
67

78
@module("highlight.js") external hljs: 'a = "default"
@@ -50,11 +51,11 @@ let make = (~code: string, ~language: string="rescript") => {
5051
}
5152

5253
<div style="position: relative;">
53-
<pre class="code-block" style="background: #0d1117; padding: 1rem; padding-right: 4rem; border-radius: 8px; overflow-x: auto; margin: 0.5rem 0;">
54+
<pre class="code-block hljs" style="padding: 1rem; padding-right: 4rem; border-radius: var(--basefn-radius-lg); overflow-x: auto; margin: 0.5rem 0; border: 1px solid var(--basefn-border-primary);">
5455
<code
5556
id
5657
class={"language-" ++ language}
57-
style="font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, monospace; font-size: 14px; line-height: 1.5;">
58+
style="font-family: var(--basefn-font-family-mono); font-size: 14px; line-height: 1.5;">
5859
{Component.text(code)}
5960
</code>
6061
</pre>

0 commit comments

Comments
 (0)