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

Fixed button wrapping behavior on mobile #921

Merged
merged 5 commits into from
Sep 2, 2018
Merged
Show file tree
Hide file tree
Changes from 3 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
52 changes: 32 additions & 20 deletions lib/core/DocsLayout.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,23 @@ class DocsLayout extends React.Component {
] || this.props.metadata.title
: this.props.metadata.title;
const hasOnPageNav = this.props.config.onPageNav === 'separate';

const previousTitle = i18n
? translation[this.props.metadata.language]['localized-strings'][
Copy link
Contributor

Choose a reason for hiding this comment

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

You should do it with idx (safe getter) now. See the upstream master

metadata.previous_id
] ||
translation[this.props.metadata.language]['localized-strings']
.previous ||
'Previous'
: metadata.previous_title || 'Previous';
const nextTitle = i18n
? translation[this.props.metadata.language]['localized-strings'][
metadata.next_id
] ||
translation[this.props.metadata.language]['localized-strings'].next ||
'Next'
: metadata.next_title || 'Next';

return (
<Site
config={this.props.config}
Expand Down Expand Up @@ -78,16 +95,14 @@ class DocsLayout extends React.Component {
metadata.localized_id,
metadata.previous_id
)}>
←{' '}
{i18n
? translation[this.props.metadata.language][
'localized-strings'
][metadata.previous_id] ||
translation[this.props.metadata.language][
'localized-strings'
].previous ||
'Previous'
: metadata.previous_title || 'Previous'}
<span className="arrow-prev">← </span>
<span
className={
previousTitle.match(/[a-z][A-Z]/) &&
'function-name-prevnext'
}>
{previousTitle}
</span>
</a>
)}
{metadata.next_id && (
Expand All @@ -97,16 +112,13 @@ class DocsLayout extends React.Component {
metadata.localized_id,
metadata.next_id
)}>
{i18n
? translation[this.props.metadata.language][
'localized-strings'
][metadata.next_id] ||
translation[this.props.metadata.language][
'localized-strings'
].next ||
'Next'
: metadata.next_title || 'Next'}{' '}
<span
className={
nextTitle.match(/[a-z][A-Z]/) && 'function-name-prevnext'
}>
{nextTitle}
</span>
<span className="arrow-next"> →</span>
</a>
)}
</div>
Expand Down
28 changes: 26 additions & 2 deletions lib/static/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -1545,8 +1545,32 @@ input::placeholder {
}

@media only screen and (max-width: 735px) {
.docs-prevnext {
Copy link
Contributor

Choose a reason for hiding this comment

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

Deleting this means the class here is useless
https://github.com/notjaril/Docusaurus/blob/f9151ca17ac424d0102d65faedef78db15ef4cbd/lib/core/DocsLayout.js#L90

<div className="docs-prevnext">

Copy link
Contributor Author

@jaril jaril Aug 28, 2018

Choose a reason for hiding this comment

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

The docs-prevnext class is still styled with:

/* Start of Docs Navigation */
.docs-prevnext {
  margin: 20px 0;
}

The intent with removing the doc-prevnext styling within the media query was so the buttons' top and bottom margins were displayed properly, where it wasn't being displayed properly with a fixed doc-prevnext height.

docs-prevnext

Does this make sense? Let me know if I missed something.

Copy link
Contributor

Choose a reason for hiding this comment

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

This is correct. I missed that 👍

height: 40px;
.docs-next {
clear: both;
float: left;
margin: 10px 0;
}

.docs-prev {
margin: 10px 0;
}

.arrow-next {
float: right;
margin-left: 10px;
}

.arrow-prev {
float: left;
margin-right: 10px;
}

.function-name-prevnext {
width: 200px;
display: inline-block;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
}
/* End of Docs Navigation */
Expand Down