Skip to content

Commit 677aa78

Browse files
Simekcortinico
andauthored
update Navigation styling, align more with react.dev (#4722)
Co-authored-by: Nicola Corti <[email protected]>
1 parent dbf0c85 commit 677aa78

File tree

1 file changed

+150
-68
lines changed

1 file changed

+150
-68
lines changed

website/src/css/customTheme.scss

Lines changed: 150 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,18 @@
1616
--subtle: #636363;
1717
--divider: #ececec;
1818
--tintColor: #f7f7f7;
19+
20+
--navbar-background: #111317ee;
21+
--navbar-active-item-background: #61dafb11;
22+
23+
--doc-sidebar-width: 266px !important;
24+
--docsearch-container-background: rgba(32, 35, 42, 0.6);
1925
--rn-note-background: rgba(255, 229, 100, 0.25);
26+
2027
--ifm-font-family-base:
2128
"Optimistic Display", system-ui, -apple-system, sans-serif;
2229
--ifm-color-primary: #06bcee;
30+
--ifm-code-background: rgba(0, 0, 0, 0.06);
2331
--ifm-font-size-base: 17px;
2432
--ifm-spacing-horizontal: 16px;
2533
--ifm-navbar-item-padding-horizontal: 18px;
@@ -97,29 +105,28 @@ body {
97105
}
98106

99107
html[data-theme="light"] {
100-
--ifm-code-background: rgba(0, 0, 0, 0.06);
101-
--docsearch-container-background: rgba(32, 35, 42, 0.6);
102108
--ifm-link-color: #357da1;
103109
}
104110

105111
html[data-theme="dark"] {
112+
--subtle: #a7a7a7;
113+
114+
--navbar-background: #20232aee;
115+
106116
--ifm-code-background: rgba(255, 255, 255, 0.06);
107117
--ifm-toc-border-color: var(--dark);
108118
--ifm-color-emphasis-300: var(--dark);
109119
--ifm-table-head-background: var(--deepdark);
110-
--subtle: #a7a7a7;
111120
--ifm-table-head-color: var(--subtle);
112121

113-
*[class^="DocSearch"] {
114-
--docsearch-searchbox-background: var(--ifm-background-color);
115-
--docsearch-modal-background: var(--deepdark);
116-
--docsearch-footer-background: var(--dark);
117-
--docsearch-key-gradient: var(--deepdark);
118-
--docsearch-key-shadow:
119-
inset 0 -2px 0 0 var(--light), inset 0 0 1px 1px var(--light),
120-
0 1px 2px 1px var(--ifm-table-border-color);
121-
--docsearch-container-background: rgba(0, 0, 0, 0.6);
122-
}
122+
--docsearch-searchbox-background: var(--ifm-background-color);
123+
--docsearch-modal-background: var(--deepdark);
124+
--docsearch-footer-background: var(--dark);
125+
--docsearch-key-gradient: var(--deepdark);
126+
--docsearch-key-shadow:
127+
inset 0 -2px 0 0 var(--light), inset 0 0 1px 1px var(--light),
128+
0 1px 2px 1px var(--ifm-table-border-color);
129+
--docsearch-container-background: rgba(0, 0, 0, 0.6);
123130

124131
--logo: #58c4dc;
125132
--home-hero-floor-background: #151517;
@@ -165,10 +172,6 @@ html[data-theme="dark"] {
165172
}
166173
}
167174

168-
:root {
169-
--doc-sidebar-width: 266px !important;
170-
}
171-
172175
::marker {
173176
color: var(--ifm-font-color-secondary);
174177
}
@@ -241,6 +244,13 @@ div[class^="generatedIndexPage"] {
241244
max-width: 100%;
242245
width: 100%;
243246
}
247+
248+
.navbar__inner {
249+
max-width: 100% !important;
250+
width: 100%;
251+
padding: var(--ifm-navbar-padding-vertical)
252+
var(--ifm-navbar-padding-horizontal);
253+
}
244254
}
245255

246256
@media (max-width: 1320px) and (min-width: 997px) {
@@ -660,13 +670,20 @@ a[class*="tagRegular"] {
660670
/* Navbar */
661671

662672
.navbar {
673+
padding: 0;
674+
663675
&.navbar--dark {
664-
background-color: var(--deepdark);
676+
background-color: var(--navbar-background);
665677
}
666678

667679
.navbar__inner {
668680
max-width: 1360px;
669681
margin: 0 auto;
682+
backdrop-filter: blur(12px);
683+
684+
&.navbar-sidebar--show {
685+
backdrop-filter: none;
686+
}
670687
}
671688

672689
.navbar__title {
@@ -678,7 +695,51 @@ a[class*="tagRegular"] {
678695
color: var(--brand);
679696
}
680697

698+
.navbar__link {
699+
transition:
700+
color 0.15s,
701+
background-color 0.15s;
702+
703+
&:hover {
704+
color: #fff;
705+
background-color: var(--dark);
706+
}
707+
}
708+
709+
.navbar__link--active {
710+
background-color: var(--navbar-active-item-background);
711+
712+
&:hover {
713+
color: var(--brand);
714+
background-color: var(--navbar-active-item-background);
715+
}
716+
}
717+
718+
.navbar-github-link,
719+
button[class*="toggleButton"] {
720+
transition: scale 0.2s;
721+
722+
&:hover {
723+
background-color: var(--dark);
724+
}
725+
726+
&:active {
727+
scale: 0.95;
728+
}
729+
}
730+
681731
.navbar__item {
732+
border-radius: 32px;
733+
padding-inline: 12px;
734+
cursor: pointer;
735+
transition-property: scale;
736+
transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
737+
transition-duration: 0.15s;
738+
739+
&:active {
740+
scale: 0.97;
741+
}
742+
682743
&.navbar__link {
683744
font-weight: 400;
684745
font-size: 17px;
@@ -690,24 +751,35 @@ a[class*="tagRegular"] {
690751
font-weight: 400;
691752
font-size: 14px;
692753
}
693-
ul {
694-
/* Control navbar dropdown alignment */
695-
top: calc(100% + 0px);
696-
left: 0;
697-
}
698754
}
699755

700756
&.dropdown--right {
701757
.dropdown__menu {
702-
min-width: 168px;
758+
min-width: 158px;
703759
}
704760
}
705761
}
706762

707-
.dropdown > .navbar__link:after {
708-
margin-left: 8px;
709-
top: 1px;
710-
opacity: 0.75;
763+
.dropdown {
764+
&.navbar__item:active {
765+
scale: none;
766+
}
767+
768+
.navbar__link {
769+
&:hover {
770+
background-color: transparent;
771+
}
772+
}
773+
774+
& > .navbar__link:after {
775+
margin-left: 8px;
776+
top: 1px;
777+
opacity: 0.75;
778+
}
779+
780+
&:hover > .navbar__link:after {
781+
color: var(--brand);
782+
}
711783
}
712784

713785
.navbar__logo {
@@ -721,27 +793,34 @@ a[class*="tagRegular"] {
721793
}
722794

723795
.DocSearch-Button {
724-
border-radius: var(--ifm-global-radius);
725-
padding: 0 6px 0 10px;
796+
border-radius: 32px;
797+
border: 1px solid var(--light);
798+
padding: 0 8px 0 12px;
726799
font-family: var(--ifm-font-family-base);
727800

728801
.DocSearch-Search-Icon {
729802
width: 16px;
730803
margin-top: -1px;
804+
color: var(--docsearch-muted-color);
805+
}
806+
807+
.DocSearch-Button-Key--pressed {
808+
box-shadow: var(--docsearch-key-shadow);
809+
transform: none;
731810
}
732811
}
733812

734-
.DocSearch-Button-Placeholder,
735-
.DocSearch-Button-Key {
736-
font-size: 14px !important;
813+
.DocSearch-Button-Placeholder {
814+
font-size: 14px;
737815
}
738816

739817
.DocSearch-Button-Key {
740-
padding-bottom: 0 !important;
818+
font-size: 12px;
819+
font-weight: 600;
741820
}
742821

743-
.DocSearch-Button-Key svg {
744-
margin-bottom: 1px !important;
822+
.DocSearch-Button-Keys {
823+
margin-top: 1px;
745824
}
746825

747826
.dropdown__menu {
@@ -752,45 +831,45 @@ a[class*="tagRegular"] {
752831
}
753832
}
754833

834+
.navbar__items {
835+
gap: 8px;
836+
}
837+
755838
.navbar__items div[class^="navbarSearchContainer"] {
756-
padding-left: 14px;
839+
padding-left: 6px;
757840
}
758841

759842
.navbar-github-link {
843+
display: flex;
844+
height: 36px;
845+
width: 36px;
846+
padding: 0;
847+
align-items: center;
848+
justify-content: center;
849+
760850
&:after {
761851
transition: opacity 0.2s;
762852
content: "";
763-
width: 24px;
764-
height: 24px;
853+
width: 20px;
854+
height: 20px;
765855
display: flex;
766856
background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fill='%23fff' d='M12 .297c-6.63 0-12 5.373-12 12 0 5.303 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332-5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0 1.005-.322 3.3 1.23.96-.267 1.98-.399 3-.405 1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015 3.286 0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12'/%3E%3C/svg%3E");
767857
background-repeat: no-repeat;
768858
background-position: center;
769859
}
770-
771-
&:hover:after {
772-
opacity: 0.5;
773-
}
774-
}
775-
776-
.navbar__link--active:after {
777-
content: "";
778-
display: flex;
779-
width: calc(100% + 40px);
780-
height: 4px;
781-
margin-top: -4px;
782-
margin-left: -20px;
783-
margin-right: -20px;
784-
position: relative;
785-
top: 18px;
786-
background: var(--brand);
787860
}
788861

789862
.navbar-sidebar__back:hover {
790863
background: var(--ifm-code-background);
791864
}
792865
}
793866

867+
html[data-theme="dark"] {
868+
.navbar-sidebar {
869+
background: var(--ifm-background-color);
870+
}
871+
}
872+
794873
/*
795874
Config has themeConfig.navbar.style === "dark"
796875
But the navbar sidebar should still support light theme
@@ -843,16 +922,6 @@ So we need to "revert" some CSS vars to not enforce dark mode
843922
}
844923
}
845924

846-
html[data-theme="dark"] {
847-
.navbar-sidebar {
848-
background: var(--ifm-background-color);
849-
}
850-
851-
.navbar button[class*="toggleButton"]:hover {
852-
background: var(--ifm-color-emphasis-200);
853-
}
854-
}
855-
856925
@media (max-width: 1200px) {
857926
.navbar {
858927
.navbar__item.navbar__link {
@@ -864,10 +933,12 @@ html[data-theme="dark"] {
864933
}
865934

866935
.DocSearch-Button {
867-
padding: 0 12px;
868-
max-width: 40px;
936+
padding: 0;
937+
justify-content: center;
938+
width: 36px;
869939
}
870940

941+
.DocSearch-Button-Keys,
871942
.DocSearch-Button-Key,
872943
.DocSearch-Button-KeySeparator,
873944
.DocSearch-Button-Placeholder {
@@ -876,6 +947,17 @@ html[data-theme="dark"] {
876947
}
877948
}
878949

950+
@media (max-width: 996px) {
951+
.navbar__items div[class^="navbarSearchContainer"] {
952+
position: static;
953+
padding-left: 0;
954+
}
955+
956+
.navbar-github-link {
957+
display: none !important;
958+
}
959+
}
960+
879961
/* Sidebar */
880962

881963
aside[class^="theme-doc-sidebar-container"] {

0 commit comments

Comments
 (0)