Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(v2): add sticky footer #1855

Merged
merged 4 commits into from
Oct 23, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG-2.x.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
# Docusaurus 2 Changelog

## Unreleased

- Add sticky footer.

## 2.0.0-alpha.30

- Fix babel transpilation include/exclude logic to be more efficient. This also fix a very weird bug `TypeError: Cannot assign to read only property 'exports' of object '#<Object>'` if your website path contains `docusaurus` word in it.

## 2.0.0-alpha.29
Expand All @@ -11,6 +16,7 @@
- New UI for webpack compilation progress bar.

## 2.0.0-alpha.28

- Further reduce memory usage to avoid heap memory allocation failure.
- Fix `keywords` frontmatter for SEO not working properly.
- Fix `swizzle` command not passing context properly to theme packages.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ function Layout(props) {
<meta name="twitter:card" content="summary" />
</Head>
<Navbar />
{children}
<main className="main">{children}</main>
{!noFooter && <Footer />}
</React.Fragment>
);
Expand Down
15 changes: 15 additions & 0 deletions packages/docusaurus-theme-classic/src/theme/Layout/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,23 @@
* LICENSE file in the root directory of this source tree.
*/

html,
body {
height: 100%;
}

body {
margin: 0;
padding-top: var(--ifm-navbar-height);
transition: var(--ifm-transition-fast) ease color;
}

body > div {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's better not to use tags directly (except for html/body)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we add these styles to body instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we add these styles to body instead?

Nope, we need to apply styles to the root element, i.e. id="__docusaurus", but it seemed like a bad use to me (this name can change, but here body > div applies just to the root element, which will always be one in the body tag.

The same goes for the Bootstrap approach.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By the way, as for the Bootstrap approach - there the styles are also applied to the footer, which can be hidden (noFooter), then CSS rules for it needs to be defined in its component - Footer, not Layout. I want to say that the current approach is more integral - the change is only in Layout.

height: 100%;
display: flex;
flex-direction: column;
}

.main {
flex: 1 0 auto;
}