Skip to content

Commit

Permalink
feat(v2): add style property to theme-classic navbar (#3432)
Browse files Browse the repository at this point in the history
* feat(v2): add style property to theme-classic navbar

* revert config test change

* review changes
  • Loading branch information
Simek committed Sep 11, 2020
1 parent c0ce83f commit 086bee2
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ describe('themeConfig', () => {
},
image: 'img/docusaurus-soc.png',
navbar: {
style: 'primary',
hideOnScroll: true,
title: 'Docusaurus',
logo: {
Expand Down
11 changes: 9 additions & 2 deletions packages/docusaurus-theme-classic/src/theme/Navbar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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} = {},
},
},
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
18 changes: 18 additions & 0 deletions website/versioned_docs/version-2.0.0-alpha.63/theme-classic.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 086bee2

Please sign in to comment.