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

MBS-10272: Convert the header / navbar to Bootstrap #1129

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mwiencek
Copy link
Member

@mwiencek mwiencek commented Jul 1, 2019

How Bootstrap is set up:

We import the custom Bootstrap CSS from design-system, and that's it.

For the actual components, I chose not to use react-bootstrap for a number of reasons:

  • It does weird things with context, causing different markup to be rendered on the client and server when hydrating.
  • Its components obscure what the HTML will actually look like, making the official Bootstrap docs hard to use.
  • It outputs large component trees (in terms of component hierarchy, not markup), which has performance implications for server-rendered pages.
  • It doesn't skip pointless client-only work (like creating event handlers) on the server, which also degrades performance.

A rough performance comparison of a react-bootstrap based navbar vs. a plain React one (both passed to ReactDOMServer.renderToString) showed the react-bootstrap one to be 5X slower. Even though it was a contrived test for a specific component rather than a whole page, we do plan to make heavy use of Bootstrap on our pages, and I don't think making our pages slower on the server is a good idea if we can avoid it.

The only issue with avoiding react-bootstrap was a lack of JS for interactive components like menus. Fortunately, basic implementations that are "good enough" for our purposes are easy to write in React: I added root/static/scripts/common/hooks/useDropdown.js for the menus here.

@mwiencek mwiencek force-pushed the react-bootstrap-nav branch 5 times, most recently from 9f7ba13 to a7ac567 Compare July 7, 2019 07:00
@reosarevok reosarevok added the React PRs directly related with React conversion label Sep 27, 2019
@reosarevok
Copy link
Member

reosarevok commented Oct 15, 2019

Uglify -> Terser commit released to production as part of a hotfix for MBS-10427

@mwiencek mwiencek added this to the Grandma Shark milestone Nov 15, 2019
@mwiencek mwiencek force-pushed the react-bootstrap-nav branch from a7ac567 to acc3345 Compare November 15, 2019 20:56
@mwiencek
Copy link
Member Author

Fixed the conflicts here and merged in the recent menu changes that were made (IIRC just replacing /edits/all with /edits, and the new /votes link).

@mwiencek mwiencek force-pushed the react-bootstrap-nav branch from acc3345 to 656b4e8 Compare November 15, 2019 20:59
How Bootstrap is set up:

We import the custom Bootstrap CSS from design-system, and that's it.

For the actual components, I chose *not* to use react-bootstrap for a
number of reasons:

 * It does weird things with context, causing different markup to be
   rendered on the client and server when hydrating.
 * Its components obscure what the HTML will actually look like, making
   the official Bootstrap docs hard to use.
 * It outputs large component trees (in terms of component hierarchy,
   not markup), which has performance implications for server-rendered
   pages.
 * It doesn't skip pointless client-only work (like creating event
   handlers) on the server, which also degrades performance.

A rough performance comparison of a react-bootstrap based navbar vs. a
plain React one (both passed to ReactDOMServer.renderToString) showed
the react-bootstrap one to be 5X slower. Even though it was a contrived
test for a specific component rather than a whole page, we do plan to
make heavy use of Bootstrap on our pages, and I don't think making our
pages slower on the server is a good idea if we can avoid it.

The only issue with avoiding react-bootstrap was a lack of JS for
interactive components like menus. Fortunately, basic implementations
that are "good enough" for our purposes are easy to write in React: I
added root/static/scripts/common/hooks/useDropdown.js for the menus
here.
@mwiencek mwiencek force-pushed the react-bootstrap-nav branch from 656b4e8 to b672d8b Compare November 15, 2019 21:17
};

export default withCatalystContext(BottomMenu);
Copy link
Member

Choose a reason for hiding this comment

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

Why did you decide to pass $c as a prop rather than use withCatalystContext?

Copy link
Member Author

Choose a reason for hiding this comment

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

From what I can see, because the Header already uses withCatalystContext, so BottomMenu isn't referenced from anywhere we can't easily pass $c through already.

<div className="right">
<TopMenu />
<BottomMenu />
<div className="collapse navbar-collapse flex-md-column">
Copy link
Member

Choose a reason for hiding this comment

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

I was expecting the menus to collapse into one of those clickable bootstrap menus when on phone version, but it does seem to just put them one after another in different lines and nothing else:

Screenshot from 2019-11-16 01-32-10

(FWIW I'd probably expect to collapse all into one menu when on small screens, and leave the search shown on its own)

@@ -42,7 +41,7 @@ const TYPE_OPTION_GROUPS = [
editor: N_l('Editor'),
},
{
doc: DBDefs.GOOGLE_CUSTOM_SEARCH ? N_l('Documentation') : null,
doc: N_l('Documentation'),
Copy link
Member

Choose a reason for hiding this comment

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

Do we just assume we have GOOGLE_CUSTOM_SEARCH or why this change?

</a>
<div className="dropdown-divider" />
<a className="dropdown-item" href="/doc/FreeDB_Gateway">
{l('FreeDB Gateway')}
Copy link
Member

Choose a reason for hiding this comment

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

This no longer exists, we should get rid.

@@ -103,7 +103,7 @@ const Layout = ({$c, ...props}) => (
<Head {...props} />

<body>
<Header {...props} />
<Header $c={$c} />
Copy link
Member

Choose a reason for hiding this comment

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

Aren't you using withCatalystContext on Header anwyay?

@yvanzo
Copy link
Contributor

yvanzo commented Nov 19, 2019

Not sure which of these changes are intentional:

  1. Orange is missing on sub-menu rollover and for unfolded menu border.
  2. Font size changed for both menu and sub-menu.
  3. Font weight changed for menu.

@mwiencek
Copy link
Member Author

Not sure which of these changes are intentional:

1. Orange is missing on sub-menu rollover and for unfolded menu border.

2. Font size changed for both menu and sub-menu.

3. Font weight changed for menu.

With these Bootstrap conversions, it's expected in general for the style to look different in some ways, since it's using the Bootstrap theme developed in the design-system repo. However, I don't think these changes you listed were intentionally designed that way: a full style for the Navbar wasn't developed during the GSoC project. So I'm happy to fix some of these to match the current style (but I would prefer to keep it consistent with the design-system theme where I can, too).

@mwiencek mwiencek removed this from the Tiburón Abuela milestone Feb 10, 2020
@mwiencek mwiencek mentioned this pull request Oct 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
React PRs directly related with React conversion
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants