Skip to content

Commit 6e3e339

Browse files
donghwi parkphated
donghwi park
andauthoredApr 7, 2021
Upgrade Docusaurus to alpha.70 (#133)
* Docusaurus upgrade debugging 1. docusaurus-plugin-sass"from ^0.1.08 to 0.1.11 2. config modification 3. Implement Navbar/index.js accordingly * Additional fix on the docusaurus update * fixup some search box styles & cleanup css * remove commented and unused code Co-authored-by: Blaine Bublitz <blaine.bublitz@gmail.com>
1 parent ac31770 commit 6e3e339

File tree

7 files changed

+3870
-2025
lines changed

7 files changed

+3870
-2025
lines changed
 

‎docusaurus.config.js

+6-3
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,18 @@ module.exports = {
1313
projectName: 'gulpjs.github.io',
1414
// The theme
1515
themeConfig: {
16-
disableDarkMode: true,
16+
colorMode: {
17+
defaultMode: 'light',
18+
disableSwitch: true,
19+
},
1720
navbar: {
1821
logo: {
1922
alt: 'gulp',
2023
src: 'img/gulp.svg',
2124
href: '/',
2225
target: '_self',
2326
},
24-
links: [
27+
items: [
2528
{
2629
to: 'docs/en/getting-started/quick-start',
2730
label: 'Get Started',
@@ -196,7 +199,7 @@ module.exports = {
196199
// to support translations and v2 doesn't support them yet
197200
routeBasePath: 'docs/en/',
198201
}],
199-
"docusaurus-plugin-sass",
202+
['docusaurus-plugin-sass', {}],
200203
['@docusaurus/plugin-content-pages', {}],
201204
isProd && ['@docusaurus/plugin-google-analytics', {}],
202205
isProd && ['@docusaurus/plugin-google-gtag', {}],

‎package-lock.json

+3,791-1,928
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json

+11-11
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,18 @@
1616
"swizzle": "docusaurus swizzle"
1717
},
1818
"devDependencies": {
19-
"@docusaurus/core": "2.0.0-alpha.50",
20-
"@docusaurus/plugin-content-docs": "2.0.0-alpha.50",
21-
"@docusaurus/plugin-content-pages": "2.0.0-alpha.50",
22-
"@docusaurus/plugin-google-analytics": "2.0.0-alpha.50",
23-
"@docusaurus/plugin-google-gtag": "2.0.0-alpha.50",
24-
"@docusaurus/plugin-sitemap": "2.0.0-alpha.50",
25-
"@docusaurus/theme-classic": "2.0.0-alpha.50",
26-
"@docusaurus/theme-search-algolia": "2.0.0-alpha.50",
27-
"@docusaurus/types": "2.0.0-alpha.50",
28-
"@docusaurus/utils": "2.0.0-alpha.50",
19+
"@docusaurus/core": "2.0.0-alpha.70",
20+
"@docusaurus/plugin-content-docs": "2.0.0-alpha.70",
21+
"@docusaurus/plugin-content-pages": "2.0.0-alpha.70",
22+
"@docusaurus/plugin-google-analytics": "2.0.0-alpha.70",
23+
"@docusaurus/plugin-google-gtag": "2.0.0-alpha.70",
24+
"@docusaurus/plugin-sitemap": "2.0.0-alpha.70",
25+
"@docusaurus/theme-classic": "2.0.0-alpha.70",
26+
"@docusaurus/theme-search-algolia": "2.0.0-alpha.70",
27+
"@docusaurus/types": "2.0.0-alpha.70",
28+
"@docusaurus/utils": "2.0.0-alpha.70",
2929
"del": "^5.1.0",
30-
"docusaurus-plugin-sass": "^0.1.8",
30+
"docusaurus-plugin-sass": "^0.1.11",
3131
"github-download-directory": "^1.2.0",
3232
"gray-matter": "^3.1.1",
3333
"gulp": "^4.0.2",

‎src/css/docs.css

+44-48
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
/* TODO: maybe this should be --ifm-font-family-primary */
77
--ifm-font-family-base: 'Poppins', sans-serif;
88
/* TODO: add to ifm as ifm-font-family-secondary? */
9-
--font-family-secondary: 'Roboto', sans-serif;
9+
--font-family-secondary: "Roboto", sans-serif;
1010
--font-weight-secondary: 900;
1111
/* Primary color */
1212
--ifm-color-primary: #cf4647;
@@ -27,7 +27,7 @@
2727
--ifm-navbar-link-color: var(--ifm-color-white);
2828
--ifm-navbar-link-hover-color: var(--ifm-color-white);
2929
--ifm-navbar-link-hover-decoration: underline;
30-
/* Search */
30+
/* Plugin(?) Search */
3131
--ifm-navbar-search-input-background-color: var(--ifm-color-primary-darkest);
3232
--ifm-navbar-search-input-color: var(--ifm-color-white);
3333
--ifm-navbar-search-input-placeholder-color: var(--ifm-color-white);
@@ -51,7 +51,10 @@
5151
}
5252

5353
/* Element defaults */
54-
h1, h2, h3, h4 {
54+
h1,
55+
h2,
56+
h3,
57+
h4 {
5558
font-family: var(--font-family-secondary);
5659
font-weight: var(--font-weight-secondary);
5760
}
@@ -134,7 +137,8 @@ h1 .hash-link {
134137
}
135138

136139
/* Tables */
137-
th, td {
140+
th,
141+
td {
138142
text-align: start;
139143
}
140144

@@ -166,11 +170,37 @@ table tr td + td + td:last-child {
166170
border-radius: var(--ifm-global-radius);
167171
}
168172

169-
/* Search */
170-
.navbar .navbar__search .navbar__search-input {
171-
width: 15.5rem;
173+
/* Navbar search */
174+
.navbar__items .DocSearch-Button {
175+
height: 2.25rem;
172176
font-size: 1rem;
177+
border-radius: var(--ifm-global-radius);
178+
color: var(--ifm-color-white);
179+
background-color: var(--ifm-color-primary-darkest);
173180
font-family: var(--ifm-font-family-base);
181+
}
182+
.navbar__items .DocSearch-Button:active,
183+
.navbar__items .DocSearch-Button:focus,
184+
.navbar__items .DocSearch-Button:hover {
185+
color: var(--ifm-color-primary-darkest);
186+
}
187+
.navbar__items .DocSearch-Button .DocSearch-Search-Icon {
188+
width: 1rem;
189+
height: 1rem;
190+
color: var(--ifm-color-white);
191+
}
192+
.navbar__items .DocSearch-Button:active .DocSearch-Search-Icon ,
193+
.navbar__items .DocSearch-Button:focus .DocSearch-Search-Icon ,
194+
.navbar__items .DocSearch-Button:hover .DocSearch-Search-Icon {
195+
color: var(--ifm-color-primary-darkest);
196+
}
197+
.DocSearch .DocSearch-Button-Keys {
198+
display: none;
199+
}
200+
/* More qualifiers than built-in styles */
201+
.DocSearch-Modal .DocSearch-Form,
202+
.DocSearch-Modal .DocSearch-Hit,
203+
.DocSearch-Modal .DocSearch-Hit a {
174204
border-radius: var(--ifm-global-radius);
175205
}
176206

@@ -188,30 +218,16 @@ table tr td + td + td:last-child {
188218
}
189219
}
190220

191-
/* Tons of hacks for the algolia search to look good on mobile */
192221
@media only screen and (max-width: 600px) {
193-
.navbar .navbar__search {
222+
.navbar__items .DocSearch-Button {
194223
width: 100%;
224+
margin: 0;
195225
}
196-
.search-icon-hidden {
197-
display: none !important;
198-
}
199-
.navbar .navbar__search .navbar__search-input {
200-
width: 100% !important;
201-
}
202-
203-
.navbar .algolia-autocomplete {
204-
width: 100%;
226+
.navbar__items .DocSearch-Button-Placeholder {
205227
display: block;
206228
}
207-
.navbar .algolia-autocomplete .ds-dropdown-menu {
208-
position: absolute !important;
209-
right: 0.5rem !important;
210-
max-width: calc(100% - 1rem);
211-
}
212229
}
213230

214-
/* TODO: These will need to be update when "Enterprise" is added */
215231
@media only screen and (max-width: 767px) {
216232
.navbar .navbar__inner {
217233
display: block;
@@ -223,35 +239,20 @@ table tr td + td + td:last-child {
223239
justify-content: space-around;
224240
flex-wrap: wrap;
225241
}
226-
227-
/* .navbar .navbar__items.navbar__items--right {
228-
justify-content: space-around;
229-
} */
230-
231-
.navbar .navbar__search {
232-
padding-left: 0;
233-
}
234242
}
235243

236244
@media only screen and (min-width: 768px) {
237-
.navbar .navbar__search .navbar__search-input {
245+
.navbar__items .DocSearch-Button {
238246
width: 9.5rem;
239247
}
240248
}
241249

242250
@media only screen and (min-width: 996px) {
243-
.navbar .navbar__search .navbar__search-input {
251+
.navbar .DocSearch-Button {
244252
width: 12.5rem;
245-
transition: width 0.5s ease 0s;
246-
}
247-
248-
.navbar .navbar__search .navbar__search-input:active,
249-
.navbar .navbar__search .navbar__search-input:focus {
250-
width: 16.5rem;
251253
}
252254
}
253255

254-
255256
@media only screen and (max-width: 996px) {
256257
.footer .col.col.col {
257258
--ifm-col-width: 33%;
@@ -289,18 +290,13 @@ table tr td + td + td:last-child {
289290
color: var(--ifm-color-secondary);
290291
border: 2px solid var(--ifm-color-secondary);
291292
box-shadow: 7px 7px 0 2px var(--ifm-color-secondary);
292-
transition: box-shadow .1s ease-in, transform .1s ease-in;
293+
transition: box-shadow 0.1s ease-in, transform 0.1s ease-in;
293294
}
294295
.tidelift-button:hover {
295296
text-decoration: none;
296297
color: var(--ifm-color-secondary);
297298
outline: none;
298299
transform: translate(2px, 10%);
299300
box-shadow: 6px 6px 0 0 var(--ifm-color-secondary);
300-
transition: box-shadow .1s ease-in, transform .1s ease-in;
301-
}
302-
303-
/* Fix: show "Copy to clipboard" button */
304-
button.copyButton_node_modules-\@docusaurus-theme-classic-src-theme-CodeBlock- {
305-
color: var(--ifm-color-white);
301+
transition: box-shadow 0.1s ease-in, transform 0.1s ease-in;
306302
}

‎src/pages/plugins/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ function PluginFooter({ keywords = [] }) {
9898
return (
9999
<div className="card__footer">
100100
<ul className={classnames('pills padding-top--sm text--normal text--right', styles.pluginCardKeywords)}>
101-
{keywords.map((keyword) => <li key={keyword} className="pill-item">{keyword}</li>)}
101+
{keywords.map((keyword) => <li key={keyword} className={styles.pillsItem}>{keyword}</li>)}
102102
</ul>
103103
</div>
104104
);

‎src/pages/plugins/plugins.module.scss

+8-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@
4444
}
4545
}
4646

47-
4847
.deprecatedMessage {
4948
color: var(--ifm-color-primary-dark);
5049
background-color: var(--ifm-color-white);
@@ -71,3 +70,11 @@
7170
.primaryUrl {
7271
color: var(--ifm-font-base-color);
7372
}
73+
74+
.pillsItem {
75+
border-radius: 0.5rem;
76+
cursor: pointer;
77+
display: inline-block;
78+
list-style-type: none;
79+
padding: 0.25rem 1rem;
80+
}

‎src/theme/Navbar/index.js

+9-33
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* LICENSE file in the root directory of this source tree.
66
*/
77

8-
import React, { useCallback, useState, useEffect } from 'react';
8+
import React, { useState, useEffect } from 'react';
99
import classnames from 'classnames';
1010
import Link from '@docusaurus/Link';
1111
import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
@@ -14,11 +14,9 @@ import isInternalUrl from '@docusaurus/isInternalUrl';
1414
import { useLocation } from '@docusaurus/router';
1515

1616
import SearchBar from '@theme/SearchBar';
17-
import Toggle from '@theme/Toggle';
1817
import useThemeContext from '@theme/hooks/useThemeContext';
1918
import useHideableNavbar from '@theme/hooks/useHideableNavbar';
20-
import useLogo from '@theme/hooks/useLogo';
21-
19+
import Logo from '@theme/Logo';
2220
import styles from './styles.module.css';
2321

2422
function noop() { }
@@ -120,25 +118,17 @@ function Navbar() {
120118
const {
121119
siteConfig: {
122120
themeConfig: {
123-
navbar: { title, links = [], hideOnScroll = false } = {},
124-
disableDarkMode = false,
121+
navbar: { items = [], hideOnScroll = false } = {},
125122
},
126123
},
127-
isClient,
128124
} = useDocusaurusContext();
129125

130126
const location = useLocation();
131127
const [enableSearch, setEnableSearch] = useState(notPluginPage(location.pathname));
132128
useEffect(() => {
133129
setEnableSearch(notPluginPage(location.pathname));
134130
}, [location]);
135-
const { isDarkTheme, setLightTheme, setDarkTheme } = useThemeContext();
136131
const { navbarRef, isNavbarVisible } = useHideableNavbar(hideOnScroll);
137-
const { logoLink, logoLinkProps, logoImageUrl, logoAlt } = useLogo();
138-
const onToggleChange = useCallback(
139-
e => (e.target.checked ? setDarkTheme() : setLightTheme()),
140-
[setLightTheme, setDarkTheme],
141-
);
142132

143133
return (
144134
<nav
@@ -149,36 +139,22 @@ function Navbar() {
149139
})}>
150140
<div className="navbar__inner">
151141
<div className="navbar__items">
152-
<Link className="navbar__brand" to={logoLink} {...logoLinkProps}>
153-
{logoImageUrl != null && (
154-
<img
155-
key={isClient}
156-
className="navbar__logo"
157-
src={logoImageUrl}
158-
alt={logoAlt}
159-
/>
160-
)}
161-
</Link>
162-
{links
142+
<Logo
143+
className="navbar__brand"
144+
imageClassName="navbar__logo"
145+
/>
146+
{items
163147
.filter(linkItem => linkItem.position === 'left')
164148
.map((linkItem, i) => (
165149
<NavItem {...linkItem} key={i} />
166150
))}
167151
</div>
168152
<div className="navbar__items navbar__items--right">
169-
{links
153+
{items
170154
.filter(linkItem => linkItem.position === 'right')
171155
.map((linkItem, i) => (
172156
<NavItem {...linkItem} key={i} />
173157
))}
174-
{!disableDarkMode && (
175-
<Toggle
176-
className={styles.displayOnlyInLargeViewport}
177-
aria-label="Dark mode toggle"
178-
checked={isDarkTheme}
179-
onChange={onToggleChange}
180-
/>
181-
)}
182158
{enableSearch && (
183159
<SearchBar
184160
handleSearchBarToggle={noop}

0 commit comments

Comments
 (0)
Please sign in to comment.