-
Notifications
You must be signed in to change notification settings - Fork 6
Sidebar container refactor #1995
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
Open
jacbn
wants to merge
11
commits into
main
Choose a base branch
from
improvement/sidebar-container-refactor
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
9be713d
Rework most pages' sidebar container
jacbn 9ccf8c3
Restore Sci sidebar layout; import, docs
jacbn fd921a8
Remove unused import (eslint)
jacbn bec70fd
More ESLint fixes
jacbn 4253087
Align all `sidebar=` props for easier regex checking
jacbn aa3ac3d
Correctly use `pageTitle` prop in QF
jacbn 0287ab9
Update VRT baselines
actions-user 1afd557
Merge pull request #1996 from isaacphysics/vrt/improvement/sidebar-co…
jacbn f83d415
Restore old Account page width for Ada
jacbn 723fb63
Adjust Sci sidebar padding
jacbn a59557c
Significantly reduce margin below pages to do separately
jacbn File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| import React from "react"; | ||
| import { Container, ContainerProps } from "reactstrap"; | ||
| import { siteSpecific } from "../../../services"; | ||
| import { MainContent, SidebarLayout } from "./SidebarLayout"; | ||
| import classNames from "classnames"; | ||
|
|
||
| interface PageContainerProps extends Omit<ContainerProps, "pageTitle"> { | ||
| pageTitle?: React.ReactNode; | ||
| sidebar?: React.ReactNode; | ||
| } | ||
|
|
||
| /** | ||
| * A component to manage the main layout of a page, including the page title and sidebar if required. | ||
| * @param props The props for the PageContainer component. | ||
| * @param props.pageTitle The title of the page, displayed above both the main content and the sidebar. | ||
| * @param props.sidebar The content of the sidebar. Displayed according to @see SidebarLayout. If not provided, the page will be displayed without a sidebar. | ||
| * @param props.children The main content of the page. | ||
| * @returns A React component that renders the page layout. | ||
| */ | ||
| export const PageContainer = (props: PageContainerProps) => { | ||
| const { children, sidebar, pageTitle, id, ...rest } = props; | ||
| // TODO increase mb-2 to ~mb-7, but carefully consider mobile layouts and remove inconsistent additional spacing below individual pages. | ||
| if (!sidebar) { | ||
| return <Container {...rest} id={id} className={classNames("mb-2", rest.className)}> | ||
| {pageTitle} | ||
| {children} | ||
| </Container>; | ||
| } | ||
|
|
||
| return siteSpecific( | ||
| // Sci | ||
| <Container {...rest} id={id} className={classNames("mb-2", rest.className)}> | ||
| {pageTitle} | ||
| <SidebarLayout show={!!sidebar}> | ||
| {sidebar} | ||
| <MainContent> | ||
| {children} | ||
| </MainContent> | ||
| </SidebarLayout> | ||
| </Container>, | ||
|
|
||
| // Ada | ||
| // The ID is applied to the top-level component here to ensure #id:before / :after background elements cover the entire page. | ||
| // Slightly annoying since the className feels like it should be on the Container, leaving this awkward split. | ||
| // Maybe revisit this when we have more use cases? | ||
| <SidebarLayout className="g-md-0" id={id} show={!!sidebar}> | ||
| {sidebar} | ||
| <MainContent className="overflow-x-auto"> | ||
| <Container fluid {...rest} className={classNames("my-ada-container mw-1600 px-md-4 px-lg-6 mb-2", rest.className)}> | ||
| {pageTitle} | ||
| {children} | ||
| </Container> | ||
| </MainContent> | ||
| </SidebarLayout> | ||
| ); | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,12 @@ | ||
| import React, { ReactNode } from "react"; | ||
| import { SidebarLayout, MainContent } from "../layout/SidebarLayout"; | ||
| import { isPhy } from "../../../services"; | ||
|
|
||
| export const QuizSidebarLayout = ({ children } : { children: ReactNode }) => | ||
| <SidebarLayout className="d-flex flex-column align-items-end"> | ||
| <SidebarLayout show={isPhy} className="d-flex flex-column align-items-end"> | ||
| <MainContent> | ||
| <div className="d-flex border-top pt-2 my-2 align-items-center"> | ||
| {children} | ||
| </div> | ||
| </MainContent> | ||
| </SidebarLayout>; | ||
| </SidebarLayout>; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This
className(rather than the simpler"sidebar-layout row"of before) is shifting everything on Sci horizontally such that sidebar and main content and now much closer together, the sidebar is smaller, and it doesn't line up as well with the left side of the page (i.e. aligning with the title hex icon/my isaac/logo). I imagine it isn't intentional, but regardless I don't like it.I'm also not entirely clear on what the class is meant to achieve. It seems to me from quickly looking at the My Ada branch that the
"d-flex flex-column flex-md-row"is only needed for Ada and not Sci, since we use things like<Col ... xs={12} lg={8}on L32 to handle this kind of stacking behaviour on Sci. I think that this dichotomy is for the sake of sidebars being a fixed size on Ada, but a proportion of screen-size on Sci, but I'm not fully sure?An easy solution is just to move the new
classNamesinside the Ada branch ofsiteSpecific, but it would be nicer for the content/sidebar stacking to work in a similar way across both sites, if at all possible.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I did this because we weren't really using
rowproperly before. Even though it ended up looking fine, the row has negative margin (what with being a row and this being Bootstrap), but this does not match the parent.container's padding.These two images are identical besides the box model, so you can see that the sidebar's padding overlaps the page container's padding badly:
I suppose this would have meant that a new, fixed-width sidebar doesn't take up the width it claims to take up, which might have been why I changed it; I can't remember for certain though. Alternatively, this could have been solved by adding
g-0to give the same outcome while keeping the samesidebar-layout rowstructure, though all the changes below this point would still be required, and there might well have been reasons I am forgetting.You are right, though, that the new approach ends up looking bad on Sci – but this is because the
p-4class that the sidebar has is now actually insetting on the left, rather than arbitrarily being shifted by -1.5rem:(aligned, at least!)
I much prefer this structure; we can then just kill off some of the left padding to restore it to its former glory (

ps-1most closely matches the title hexagon's spacing, butps-3most closely matches the old layout):The only real difference left is that the
rowapproach enforces spacing between the sidebar and the main content, which this new approach no longer does. I'd probably usegapin any other situation, but for Sci the sidebar:content ratio is fixed at either 1:2 or 1:3, and gap adds extra that causes overflow. I think my preferred alternative is just to increase the padding on the right of the sidebar, something likepe-5; this leaves the<MainContent>flush with the actual contents.I'll make a commit with these changes on (appreciate long paragraphs are probably a bit hard to follow!) and would appreciate any thoughts from there.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As you mention before, this is quite difficult owing to the relative positioning of the sidebar and main content given the requirement for the Ada sidebar to exist flush with the left of the page. One possible improvement might be to replace
<MainContent>'s<Col>lg/mdsizings on L32 with just a div withflex-grow-1, which is how the Ada one should work, so that component is the same across both. But this is only possible because the sidebar itself has a fixedlg/mdsize on Sci, so the automatic sizing always gives (100% - sidebar%), which is precisely the sizings we would be replacing.