feat(v2): add style property to theme-classic navbar (#3432)

* feat(v2): add style property to theme-classic navbar

* revert config test change

* review changes
This commit is contained in:
Bartosz Kaszubowski 2020-09-11 18:03:06 +02:00 committed by GitHub
parent c0ce83f243
commit 086bee287d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 29 additions and 2 deletions

View file

@ -33,6 +33,7 @@ describe('themeConfig', () => {
},
image: 'img/docusaurus-soc.png',
navbar: {
style: 'primary',
hideOnScroll: true,
title: 'Docusaurus',
logo: {

View file

@ -43,7 +43,12 @@ function Navbar(): JSX.Element {
const {
siteConfig: {
themeConfig: {
navbar: {title = '', items = [], hideOnScroll = false} = {},
navbar: {
title = '',
items = [],
hideOnScroll = false,
style = undefined,
} = {},
colorMode: {disableSwitch: disableColorModeSwitch = false} = {},
},
},
@ -83,7 +88,9 @@ function Navbar(): JSX.Element {
return (
<nav
ref={navbarRef}
className={clsx('navbar', 'navbar--light', 'navbar--fixed-top', {
className={clsx('navbar', 'navbar--fixed-top', {
'navbar--dark': style === 'dark',
'navbar--primary': style === 'primary',
'navbar-sidebar--show': sidebarShown,
[styles.navbarHideable]: hideOnScroll,
[styles.navbarHidden]: !isNavbarVisible,

View file

@ -189,6 +189,7 @@ const ThemeConfigSchema = Joi.object({
isCloseable: Joi.bool().default(true),
}).optional(),
navbar: Joi.object({
style: Joi.string().equal('dark', 'primary'),
hideOnScroll: Joi.bool().default(false),
// TODO temporary (@alpha-58)
links: Joi.any().forbidden().messages({

View file

@ -304,6 +304,24 @@ module.exports = {
};
```
### Navbar style
You can set the static Navbar style without disabling the theme switching ability. The selected style will always apply no matter which theme user have selected.
Currently, there are two possible style options: `dark` and `primary` (based on the `--ifm-color-primary` color). You can see the styles preview in the [Infima documentation](https://facebookincubator.github.io/infima/docs/components/navbar/).
```js {5} title="docusaurus.config.js"
module.exports = {
// ...
themeConfig: {
navbar: {
style: 'primary',
},
// ...
},
};
```
<!--
## Footer