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

Fixed button wrapping behavior on mobile #921

merged 5 commits into from
Sep 2, 2018

Conversation

jaril
Copy link
Contributor

@jaril jaril commented Aug 27, 2018

Motivation

Fixes #918

Have you read the Contributing Guidelines on pull requests?

Yes

Test Plan

  1. Visit any doc page where lengthy text on the previous and next buttons caused the buttons to wrap and stack with no space in between (eg https://docusaurus.io/docs/en/navigation)
  2. Check that it no longer stacks when the window is <735px. There should be ample space in between and the both buttons should float left.

It should look like this:
screen shot 2018-08-27 at 5 23 31 pm

Related PRs

(If this PR adds or changes functionality, please take some time to update the docs at https://github.com/facebook/docusaurus, and link to your PR here.)

previous+next buttons with long text now stack properly on smaller screens
@facebook-github-bot facebook-github-bot added the CLA Signed Signed Facebook CLA label Aug 27, 2018
@docusaurus-bot
Copy link
Contributor

docusaurus-bot commented Aug 27, 2018

Deploy preview for docusaurus-preview ready!

Built with commit 320fde7

https://deploy-preview-921--docusaurus-preview.netlify.com

Function/component names are truncated, while regular titles are wrapped
Copy link
Contributor

@endiliey endiliey left a comment

Choose a reason for hiding this comment

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

Few questions below:

@@ -1545,8 +1545,28 @@ 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 👍

className={
nextTitle.match(/[a-z][A-Z]/)
? 'function-name-prevnext'
: 'text-next'
Copy link
Contributor

Choose a reason for hiding this comment

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

I couldn't find any text-next css class on the new main.css.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're right, thanks for checking - it was leftover styling from something I was trying before. Will remove it, and leave the span classless in the case that the button text is (likely) not a function/component name.

Copy link
Contributor

Choose a reason for hiding this comment

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

Seems that is the case. Just checking .. It's easy to miss css selector like this 😄

Copy link
Contributor

@endiliey endiliey left a comment

Choose a reason for hiding this comment

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

Looks good to me. However, one thing that I notice is for text that are quite short, I prefer the before looks.

Before vs after
beforeafter

Anyway, I'll let @yangshun or @JoelMarcey to approve this as well before merging

@jaril
Copy link
Contributor Author

jaril commented Aug 28, 2018

I like the 'before' look as well for shorter text.

Ideally, it would keep both inline until such time that one of the buttons wrap, at which point if floats both buttons left. The problem is I don't think there's a way in CSS to toggle the styling based on whether or not the elements are wrapped. The 'after' styling just toggles automatically at screen width < 735px, floating both buttons left.

If you feel strongly about keeping both buttons inline, we could do Option 1 instead of Option 2. Then both buttons would have equal widths, and any lengthy text would wrap.
option-comparison

It's possible I'm missing something - if there's a CSS trick out there that could do that, let me know.

@endiliey
Copy link
Contributor

@notjaril
This needs rebase / merge upstream master to resolve conflicts.

@jaril
Copy link
Contributor Author

jaril commented Aug 28, 2018

Fixed the conflicts - let me know if this does the trick.

@@ -46,6 +46,23 @@ class DocsLayout extends React.Component {
const title =
idx(i18n, ['localized-strings', 'docs', id, 'title']) || defaultTitle;
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

passed through prettier and all tests pass
@jaril
Copy link
Contributor Author

jaril commented Aug 29, 2018

That was my bad - it's now fixed and is using idx.

Copy link
Contributor

@endiliey endiliey left a comment

Choose a reason for hiding this comment

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

Code functionality wise, approved.

image

UI wise, we might need more opinion from @yangshun / @JoelMarcey

Copy link
Contributor

@JoelMarcey JoelMarcey left a comment

Choose a reason for hiding this comment

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

I kinda like the buttons having the same width to my eye, but I don't feel strongly about it right now.

@yangshun what do you think?

Copy link
Contributor

@yangshun yangshun left a comment

Choose a reason for hiding this comment

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

LGTM!

@yangshun yangshun merged commit e613725 into facebook:master Sep 2, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed Signed Facebook CLA
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants