Skip to content

Commit 5a9e189

Browse files
committed
Match the docs' PageFooter for page navigation
The invented bordered cards with Previous/Next labels are replaced by the docs' actual footer: the destination name with a 14px emcn chevron on a flex-1 hover pill (rounded-lg, px-3 py-3, --surface-active), next right-justified, and a spacer holding the empty half — verified against apps/docs/components/docs-layout/page-footer.tsx.
1 parent cbcc31c commit 5a9e189

3 files changed

Lines changed: 46 additions & 26 deletions

File tree

‎apps/sim/lib/workspace-files/artifact-stylesheet.ts‎

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -551,18 +551,21 @@ figcaption { font-size: 0.875em; line-height: 1.4285714; color: var(--text-prima
551551
.codeblock-copy.is-copied { color: var(--brand-accent); }
552552
.codeblock pre { border: none; border-radius: 0; margin: 0; background: transparent; }
553553
554-
/* Footer pagination — the docs' previous/next cards. */
555-
.page-nav { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; margin-top: 3rem; }
554+
/* Footer pagination — the docs' PageFooter verbatim: name + chevron on a
555+
hover pill (mt-12 flex gap-2 py-3; cards flex-1 gap-1.5 rounded-lg px-3
556+
py-3 text-sm --text-body, hover --surface-active; chevrons 14px
557+
--text-icon; a missing side keeps its half as a spacer). */
558+
.page-nav { display: flex; gap: 0.5rem; margin-top: 3rem; padding: 0.75rem 0; }
556559
.page-nav-card {
557-
display: flex; flex-direction: column; gap: 0.15rem;
558-
border: 1px solid var(--border); border-radius: 0.75rem;
559-
padding: 0.75rem 1rem; text-decoration: none;
560+
flex: 1; display: flex; align-items: center; gap: 0.375rem; min-width: 0;
561+
border-radius: 0.5rem; padding: 0.75rem;
562+
font-size: var(--text-sm); font-weight: 400; color: var(--text-body);
563+
text-decoration: none; transition: background-color 0.2s;
560564
}
561-
.page-nav-card:hover { background: var(--surface-hover); }
562-
.page-nav-card.prev { grid-column: 1; }
563-
.page-nav-card.next { grid-column: 2; text-align: right; }
564-
.page-nav-dir { font-size: var(--text-caption); color: var(--text-muted); }
565-
.page-nav-title { font-size: var(--text-sm); font-weight: 500; color: var(--text-primary); }
565+
.page-nav-card:hover { background: var(--surface-active); opacity: 1; }
566+
.page-nav-card.next { justify-content: flex-end; }
567+
.page-nav-card svg { flex-shrink: 0; color: var(--text-icon); }
568+
.page-nav-spacer { flex: 1; }
566569
`.trim()
567570

568571
/**

‎apps/sim/lib/workspace-files/page-compile.test.ts‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,15 +133,23 @@ describe('compileSimPage', () => {
133133
expect(html).toContain('src="/api/files/view/img9"')
134134
})
135135

136+
it('keeps a lone next card right-aligned with a spacer', () => {
137+
const html = compileSimPage('---\ntitle: T\nnext: "[API](sim:file/b)"\n---\nBody.')
138+
expect(html).toContain('<div class="page-nav-spacer"></div><a class="page-nav-card next"')
139+
})
140+
136141
it('renders frontmatter prev/next as footer pagination cards', () => {
137142
const html = compileSimPage(
138143
'---\ntitle: T\nprev: "[Getting Started](sim:file/a)"\nnext: "[API Reference](sim:file/b)"\n---\nBody.',
139144
{ workspaceId: 'ws1' }
140145
)
141146
expect(html).toContain('<footer class="page-nav">')
142147
expect(html).toContain('class="page-nav-card prev"')
143-
expect(html).toContain('<span class="page-nav-title">API Reference</span>')
148+
expect(html).toContain('Getting Started')
144149
expect(html).toContain('href="/workspace/ws1/files/b/view"')
150+
// The docs' PageFooter shape: chevron + name, no Previous/Next labels.
151+
expect(html).toContain('M6.25 3L13.25 10.25L6.25 17.5')
152+
expect(html).not.toContain('Previous')
145153
})
146154

147155
it('renders sim:accordion like sim:faq with title keys', () => {

‎apps/sim/lib/workspace-files/page-compile.ts‎

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,26 @@ const frontmatterSchema = z.object({
4646

4747
const MD_LINK = /^\s*\[([^\]]+)\]\(([^)]+)\)\s*$/
4848

49-
/** Renders one footer pagination card from a frontmatter `[Title](href)` link. */
50-
function paginationCard(value: string, direction: 'prev' | 'next'): string {
51-
const match = value.match(MD_LINK)
52-
if (!match) return ''
49+
const CHEVRON_ATTRS =
50+
'viewBox="-1 -2 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="1.55" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"'
51+
const CHEVRON_LEFT = `<svg ${CHEVRON_ATTRS}><path d="M13.25 3L6.25 10.25L13.25 17.5"/></svg>`
52+
const CHEVRON_RIGHT = `<svg ${CHEVRON_ATTRS}><path d="M6.25 3L13.25 10.25L6.25 17.5"/></svg>`
53+
54+
/**
55+
* One footer navigation card from a frontmatter `[Title](href)` link — the
56+
* docs' own PageFooter: the destination name with a direction chevron on a
57+
* hover pill, no border and no Previous/Next label (the chevron already says
58+
* which way you are going). A missing side renders a spacer so the other
59+
* card keeps its half.
60+
*/
61+
function paginationCard(value: string | undefined, direction: 'prev' | 'next'): string {
62+
const match = value?.match(MD_LINK)
63+
if (!match) return '<div class="page-nav-spacer"></div>'
5364
const [, title, href] = match
54-
const label = direction === 'prev' ? '← Previous' : 'Next →'
55-
return `<a class="page-nav-card ${direction}" href="${escapeHtml(href)}"><span class="page-nav-dir">${label}</span><span class="page-nav-title">${escapeHtml(title)}</span></a>`
65+
const name = escapeHtml(title)
66+
return direction === 'prev'
67+
? `<a class="page-nav-card prev" href="${escapeHtml(href)}">${CHEVRON_LEFT}${name}</a>`
68+
: `<a class="page-nav-card next" href="${escapeHtml(href)}">${name}${CHEVRON_RIGHT}</a>`
5669
}
5770

5871
/** YAML leaves unquoted scalars typed; reject null/objects rather than stringify them. */
@@ -344,15 +357,11 @@ function compileSimPageDocument(source: string, lenient = false): string {
344357
`<h1>${escapeHtml(meta.title)}</h1>`,
345358
...(meta.lede ? [`<p class="lede">${escapeHtml(meta.lede)}</p>`] : []),
346359
compileBody(rest, lenient),
347-
...(() => {
348-
const cards = [
349-
meta.prev ? paginationCard(meta.prev, 'prev') : '',
350-
meta.next ? paginationCard(meta.next, 'next') : '',
351-
]
352-
.filter(Boolean)
353-
.join('')
354-
return cards ? [`<footer class="page-nav">${cards}</footer>`] : []
355-
})(),
360+
...(meta.prev || meta.next
361+
? [
362+
`<footer class="page-nav">${paginationCard(meta.prev, 'prev')}${paginationCard(meta.next, 'next')}</footer>`,
363+
]
364+
: []),
356365
'</div>',
357366
'</body>',
358367
'</html>',

0 commit comments

Comments
 (0)