Skip to content

Commit b0024e4

Browse files
committed
feat: improve mobile documentation navigation
1 parent 8eb854f commit b0024e4

4 files changed

Lines changed: 365 additions & 6 deletions

File tree

app/globals.css

Lines changed: 177 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,7 @@ select {
323323
}
324324

325325
.icon-button,
326+
.mobile-primary-dropdown > button,
326327
.language-dropdown > summary,
327328
.copy-page-link,
328329
.article-actions a {
@@ -432,6 +433,158 @@ select {
432433
padding: 0;
433434
}
434435

436+
.mobile-primary-dropdown {
437+
position: relative;
438+
display: none;
439+
}
440+
441+
.mobile-primary-dropdown > button {
442+
width: 36px;
443+
padding: 0;
444+
cursor: pointer;
445+
font: inherit;
446+
}
447+
448+
.mobile-primary-dropdown > button svg {
449+
width: 18px;
450+
height: 18px;
451+
}
452+
453+
.mobile-primary-dropdown.is-open > button {
454+
border-color: color-mix(in srgb, var(--accent) 34%, var(--border));
455+
background: var(--surface-soft);
456+
color: var(--text-strong);
457+
}
458+
459+
.mobile-primary-dropdown-menu {
460+
position: fixed;
461+
top: calc(var(--header-height) - 1px);
462+
right: 12px;
463+
left: 12px;
464+
z-index: 90;
465+
display: grid;
466+
gap: 4px;
467+
max-height: calc(100dvh - var(--header-height) - 12px);
468+
padding: 8px;
469+
overflow-y: auto;
470+
border: 1px solid var(--border);
471+
border-radius: 0 0 14px 14px;
472+
background: var(--surface);
473+
box-shadow: var(--shadow-md);
474+
backdrop-filter: blur(18px) saturate(150%);
475+
}
476+
477+
.mobile-primary-external-links {
478+
display: grid;
479+
gap: 4px;
480+
}
481+
482+
.mobile-primary-item,
483+
.mobile-sdk-menu > button,
484+
.mobile-sdk-menu-section a {
485+
display: flex;
486+
width: 100%;
487+
min-height: 42px;
488+
align-items: center;
489+
justify-content: space-between;
490+
gap: 8px;
491+
padding: 0 12px;
492+
border: 1px solid transparent;
493+
border-radius: 9px;
494+
background: transparent;
495+
color: var(--text-muted);
496+
cursor: pointer;
497+
font-family: inherit;
498+
font-size: 13px;
499+
font-weight: 620;
500+
text-align: left;
501+
}
502+
503+
.mobile-primary-item:hover,
504+
.mobile-primary-item.is-active,
505+
.mobile-sdk-menu > button:hover,
506+
.mobile-sdk-menu > button.is-active,
507+
.mobile-sdk-menu-section a:hover,
508+
.mobile-sdk-menu-section a.is-active {
509+
border-color: color-mix(in srgb, var(--accent) 24%, var(--border));
510+
background: var(--accent-soft);
511+
color: var(--text-strong);
512+
}
513+
514+
.mobile-primary-external-links {
515+
margin-top: 4px;
516+
padding-top: 8px;
517+
border-top: 1px solid var(--border);
518+
}
519+
520+
.mobile-primary-external-links svg {
521+
width: 15px;
522+
height: 15px;
523+
color: var(--text-subtle);
524+
}
525+
526+
.mobile-sdk-menu {
527+
display: grid;
528+
gap: 4px;
529+
}
530+
531+
.mobile-sdk-menu > button svg {
532+
width: 15px;
533+
height: 15px;
534+
color: var(--text-subtle);
535+
transition: transform 160ms ease;
536+
}
537+
538+
.mobile-sdk-menu.is-open > button svg {
539+
transform: rotate(180deg);
540+
}
541+
542+
.mobile-sdk-menu-list {
543+
display: grid;
544+
gap: 8px;
545+
margin: 0 0 4px 13px;
546+
padding: 7px 0 7px 10px;
547+
border-left: 1px solid color-mix(in srgb, var(--accent) 26%, var(--border));
548+
}
549+
550+
.mobile-sdk-menu-section {
551+
display: grid;
552+
gap: 5px;
553+
}
554+
555+
.mobile-sdk-menu-section > p {
556+
display: flex;
557+
align-items: baseline;
558+
justify-content: space-between;
559+
gap: 12px;
560+
margin: 2px 10px 1px;
561+
color: var(--text-subtle);
562+
}
563+
564+
.mobile-sdk-menu-section > p strong {
565+
font-size: 10px;
566+
font-weight: 760;
567+
letter-spacing: 0.06em;
568+
text-transform: uppercase;
569+
}
570+
571+
.mobile-sdk-menu-section > p span {
572+
font-size: 10px;
573+
font-weight: 620;
574+
}
575+
576+
.mobile-sdk-menu-section > div {
577+
display: grid;
578+
gap: 2px;
579+
}
580+
581+
.mobile-sdk-menu-section a {
582+
min-height: 38px;
583+
justify-content: flex-start;
584+
padding: 0 10px;
585+
font-size: 12px;
586+
}
587+
435588
.language-dropdown {
436589
position: relative;
437590
}
@@ -4315,6 +4468,16 @@ html.dark .guide-markdown a {
43154468
}
43164469
}
43174470

4471+
@media (max-width: 760px) {
4472+
.primary-nav {
4473+
display: none;
4474+
}
4475+
4476+
.mobile-primary-dropdown {
4477+
display: block;
4478+
}
4479+
}
4480+
43184481
@media (max-width: 640px) {
43194482
.global-header-inner {
43204483
gap: 12px;
@@ -4502,7 +4665,14 @@ html.dark .guide-markdown a {
45024665
justify-content: space-between;
45034666
}
45044667

4505-
.primary-nav {
4668+
.language-dropdown > summary {
4669+
width: 36px;
4670+
min-width: 36px;
4671+
padding: 0;
4672+
}
4673+
4674+
.language-dropdown > summary .language-current,
4675+
.language-dropdown > summary > svg:last-child {
45064676
display: none;
45074677
}
45084678

@@ -4511,6 +4681,12 @@ html.dark .guide-markdown a {
45114681
}
45124682
}
45134683

4684+
@media (max-width: 350px) {
4685+
.brand-name {
4686+
display: none;
4687+
}
4688+
}
4689+
45144690
@media (prefers-reduced-motion: reduce) {
45154691
*,
45164692
*::before,

app/layout.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export const viewport: Viewport = {
4040

4141
export default function RootLayout({ children }: { children: ReactNode }) {
4242
return (
43-
<html lang="en" suppressHydrationWarning>
43+
<html data-scroll-behavior="smooth" lang="en" suppressHydrationWarning>
4444
<body>
4545
<RootProvider theme={{ storageKey: 'openim-docs-theme' }}>{children}</RootProvider>
4646
</body>

src/components/search/search-dialog.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,12 @@ export function SearchDialog({ locale = 'en' }: { locale?: Locale }) {
7878

7979
return (
8080
<>
81-
<button className="search-trigger" onClick={openDialog} type="button">
81+
<button
82+
aria-label={text.search.trigger}
83+
className="search-trigger"
84+
onClick={openDialog}
85+
type="button"
86+
>
8287
<SearchIcon />
8388
<span>{text.search.trigger}</span>
8489
<kbd>⌘K</kbd>

0 commit comments

Comments
 (0)