Skip to content

Commit f90c4d2

Browse files
committed
fix: sidebar & secondary menu
1 parent 8175151 commit f90c4d2

File tree

2 files changed

+46
-38
lines changed

2 files changed

+46
-38
lines changed

apify-docs-theme/src/theme/Layout/index.jsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,18 @@
1+
import { useLocation } from '@docusaurus/router';
12
// cannot use any of the theme aliases here as it causes a circular dependency :( ideas welcome
23
import Layout from '@docusaurus/theme-classic/lib/theme/Layout/index';
4+
import useBaseUrl from '@docusaurus/useBaseUrl';
5+
import { usePluginData } from '@docusaurus/useGlobalData';
36
import React from 'react';
47

58
export default function LayoutWrapper(props) {
9+
const { options: { subNavbar } } = usePluginData('@apify/docs-theme');
10+
const baseUrl = useBaseUrl('/');
11+
const currentPath = useLocation().pathname.replace(new RegExp(`^${baseUrl}`), '');
12+
613
return (
714
<div style={{
15+
'--ifm-navbar-height': subNavbar && !currentPath.startsWith('api/v2') ? '126px' : '68px',
816
margin: 0,
917
padding: 0,
1018
boxSizing: 'border-box',

apify-docs-theme/src/theme/custom.css

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ html[data-theme='dark'] {
1414
--ifm-heading-color: #f2f3fb;
1515
--ifm-navbar-link-color: #f2f3fb;
1616

17-
--ifm-navbar-height: 68px;
1817
--ifm-line-height-base: 1.65;
1918

2019
--ifm-code-background: var(--ifm-pre-background) !important;
@@ -136,6 +135,7 @@ html[data-theme='dark'] {
136135
--ifm-font-weight-semibold: 600;
137136
--ifm-font-color-base: #242736;
138137

138+
--ifm-navbar-sidebar-width: 100vw;
139139
--ifm-navbar-item-padding-horizontal: 28px;
140140
--ifm-navbar-link-color: #41465d;
141141
--ifm-navbar-shadow: none;
@@ -146,7 +146,6 @@ html[data-theme='dark'] {
146146
--ifm-code-padding-horizontal: 6.4px;
147147
--ifm-code-padding-vertical: 3.2px;
148148

149-
--ifm-navbar-height: 68px;
150149
--ifm-global-spacing: 1.6rem !important;
151150

152151
--ifm-color-primary-lightest: #5d9df1;
@@ -414,11 +413,16 @@ footer .col {
414413

415414
.navbar__inner {
416415
width: 100%;
417-
height: var(--ifm-navbar-height);
416+
height: 68px;
418417
padding: 0 var(--ifm-spacing-horizontal);
419418
background: var(--color-Neutral_Background);
420419
}
421420

421+
.navbar__sub {
422+
padding: 0.8rem var(--ifm-spacing-horizontal);
423+
height: 58px;
424+
}
425+
422426
.navbar__container {
423427
max-width: var(--max-layout-width);
424428
display: flex;
@@ -519,6 +523,7 @@ aside .icon svg[class*=iconExternalLink] {
519523
}
520524

521525
.navbar__items {
526+
height: calc(100% -68px);
522527
gap: 0.4rem;
523528
}
524529

@@ -527,11 +532,10 @@ aside .icon svg[class*=iconExternalLink] {
527532
}
528533

529534
.navbar__item, .menu__link, .navbar__link {
530-
border-radius: 8px;
531535
color: var(--color-Neutral_TextMuted);
532-
padding: 4px 8px;
533-
font-size: 14px;
534-
line-height: 24.4px;
536+
padding: 0;
537+
font-size: 1.4rem;
538+
line-height: 2.4rem;
535539
transition: all ease-in 0.12s;
536540
}
537541

@@ -558,7 +562,8 @@ aside .icon svg[class*=iconExternalLink] {
558562
display: flex;
559563
align-items: center;
560564
width: 200px;
561-
padding-right: 8px;
565+
margin-right: 1.6rem;
566+
padding-right: 2rem;
562567
position: relative;
563568
border-right: 1px solid var(--color-Neutral_SeparatorSubtle);
564569
justify-content: center;
@@ -602,7 +607,6 @@ article .card h2 {
602607
}
603608

604609
.tsd-kind-icon,
605-
.menu__link,
606610
.table-of-contents__link {
607611
text-overflow: ellipsis;
608612
display: inline-block !important;
@@ -630,7 +634,7 @@ article .card h2 {
630634
}
631635

632636
.menu__link--sublist-caret:after {
633-
height: 2.5rem;
637+
height: 2.4rem;
634638
}
635639

636640
aside button[class*="collapseSidebarButton"] svg {
@@ -708,8 +712,12 @@ aside button[class*="collapseSidebarButton"] svg {
708712
width: 100vw;
709713
}
710714

715+
.navbar-sidebar__items {
716+
height: calc(100vh - 68px);
717+
}
718+
711719
.navbar-sidebar__brand {
712-
height: var(--ifm-navbar-height);
720+
height: 68px;
713721
padding: 0 var(--ifm-spacing-horizontal);
714722
display: flex;
715723
align-items: center;
@@ -812,7 +820,6 @@ html .plugin-docs .theme-doc-markdown h3 {
812820
display: none;
813821
}
814822

815-
.theme-doc-sidebar-menu .menu__link,
816823
.theme-doc-toc-desktop .table-of-contents .toc-highlight {
817824
height: auto;
818825
background: none;
@@ -822,10 +829,6 @@ html .plugin-docs .theme-doc-markdown h3 {
822829
margin-top: 0;
823830
}
824831

825-
.theme-doc-sidebar-menu .menu__link:hover {
826-
background: inherit;
827-
}
828-
829832
.theme-doc-sidebar-menu .menu__link {
830833
font-weight: 400;
831834
}
@@ -834,15 +837,6 @@ html .plugin-docs .theme-doc-markdown h3 {
834837
font-weight: 700;
835838
}
836839

837-
.theme-doc-sidebar-menu .menu__list-item-collapsible {
838-
background: none;
839-
border-radius: 0.8rem;
840-
}
841-
842-
.theme-doc-sidebar-menu .menu__list-item-collapsible:hover {
843-
background: var(--color-Neutral_Hover);
844-
}
845-
846840
.theme-doc-sidebar-menu .menu__list-item-collapsible--active:hover {
847841
background: var(--color-neutral-overflow);
848842
}
@@ -873,7 +867,6 @@ html[data-theme='dark'] .theme-doc-toc-desktop .table-of-contents .table-of-cont
873867
color: #f2f3fb;
874868
}
875869

876-
.theme-doc-sidebar-menu .menu__link:hover,
877870
.theme-doc-sidebar-menu .menu__link--active,
878871
.theme-doc-toc-desktop .table-of-contents .table-of-contents__link:hover,
879872
.theme-doc-toc-desktop .table-of-contents .table-of-contents__link--active {
@@ -921,17 +914,23 @@ div[class*="searchBox"] {
921914
display: flex;
922915
}
923916

924-
.menu__link--sublist,
925917
.menu__list-item > .menu__link,
918+
.menu__list-item-collapsible,
919+
.menu__list-item-collapsible > .menu__link,
926920
.navbar__item.navbar__link,
927-
.navbar__item > .navbar__link {
921+
.navbar__item > .navbar__link,
922+
.navbar-sidebar__back {
928923
padding: 0.8rem 1.2rem;
929924
border-radius: 2rem;
930925
font-size: 1.4rem;
931926
line-height: 2.4rem;
932927
font-weight: 500;
933928
}
934929

930+
.menu__list-item-collapsible {
931+
padding: unset;
932+
}
933+
935934
.menu__list {
936935
width: 100%;
937936
display: flex;
@@ -940,20 +939,26 @@ div[class*="searchBox"] {
940939
}
941940

942941
.menu__list .menu__list {
942+
margin-top: unset;
943943
padding-left: 1.6rem;
944944
}
945945

946946
.menu__list .menu__list .menu__list-item {
947947
margin-top: 0.4rem;
948948
}
949949

950-
.menu__list-item {
951-
display: flex;
952-
flex-direction: column;
950+
.menu__caret {
951+
margin-right: 0.8rem;
953952
}
954953

955-
.theme-doc-sidebar-item-category .menu__list-item-collapsible,
956-
.theme-doc-sidebar-item-link {
954+
.navbar-sidebar__back {
955+
width: 100%;
956+
margin: unset;
957+
}
958+
959+
.theme-doc-sidebar-item-category
960+
.theme-doc-sidebar-item-link,
961+
.menu__list-item-collapsible {
957962
display: flex;
958963
align-items: center;
959964
}
@@ -1129,11 +1134,6 @@ aside li.section-header > .menu__list {
11291134
padding-left: 0;
11301135
}
11311136

1132-
.theme-doc-sidebar-menu > li.section-header > ul > li.theme-doc-sidebar-item-category-level-2 > .menu__list-item-collapsible:hover,
1133-
.theme-doc-sidebar-menu > li.section-header > ul > li.theme-doc-sidebar-item-category-level-2 > .menu__list-item-collapsible--active {
1134-
background: inherit !important;
1135-
}
1136-
11371137
.theme-doc-sidebar-menu > li.section-header > ul > li.theme-doc-sidebar-item-category-level-2 {
11381138
margin-bottom: 1rem;
11391139
}

0 commit comments

Comments
 (0)