mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-20 20:46:58 +02:00
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:
parent
c0ce83f243
commit
086bee287d
4 changed files with 29 additions and 2 deletions
|
@ -33,6 +33,7 @@ describe('themeConfig', () => {
|
||||||
},
|
},
|
||||||
image: 'img/docusaurus-soc.png',
|
image: 'img/docusaurus-soc.png',
|
||||||
navbar: {
|
navbar: {
|
||||||
|
style: 'primary',
|
||||||
hideOnScroll: true,
|
hideOnScroll: true,
|
||||||
title: 'Docusaurus',
|
title: 'Docusaurus',
|
||||||
logo: {
|
logo: {
|
||||||
|
|
|
@ -43,7 +43,12 @@ function Navbar(): JSX.Element {
|
||||||
const {
|
const {
|
||||||
siteConfig: {
|
siteConfig: {
|
||||||
themeConfig: {
|
themeConfig: {
|
||||||
navbar: {title = '', items = [], hideOnScroll = false} = {},
|
navbar: {
|
||||||
|
title = '',
|
||||||
|
items = [],
|
||||||
|
hideOnScroll = false,
|
||||||
|
style = undefined,
|
||||||
|
} = {},
|
||||||
colorMode: {disableSwitch: disableColorModeSwitch = false} = {},
|
colorMode: {disableSwitch: disableColorModeSwitch = false} = {},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -83,7 +88,9 @@ function Navbar(): JSX.Element {
|
||||||
return (
|
return (
|
||||||
<nav
|
<nav
|
||||||
ref={navbarRef}
|
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,
|
'navbar-sidebar--show': sidebarShown,
|
||||||
[styles.navbarHideable]: hideOnScroll,
|
[styles.navbarHideable]: hideOnScroll,
|
||||||
[styles.navbarHidden]: !isNavbarVisible,
|
[styles.navbarHidden]: !isNavbarVisible,
|
||||||
|
|
|
@ -189,6 +189,7 @@ const ThemeConfigSchema = Joi.object({
|
||||||
isCloseable: Joi.bool().default(true),
|
isCloseable: Joi.bool().default(true),
|
||||||
}).optional(),
|
}).optional(),
|
||||||
navbar: Joi.object({
|
navbar: Joi.object({
|
||||||
|
style: Joi.string().equal('dark', 'primary'),
|
||||||
hideOnScroll: Joi.bool().default(false),
|
hideOnScroll: Joi.bool().default(false),
|
||||||
// TODO temporary (@alpha-58)
|
// TODO temporary (@alpha-58)
|
||||||
links: Joi.any().forbidden().messages({
|
links: Joi.any().forbidden().messages({
|
||||||
|
|
|
@ -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
|
## Footer
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue