-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Adds contextControl prop to <TopBar /> and <Navigation /> #966
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
Conversation
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.
Having some issues with the 🎩 instructions. The playground code has some TS linting errors around Topbar.Menu
missing required props. Also the playground itself errors out with React.Children.only expected to receive a single React element child.
Could you fix these up and then ping me again for review?
@danrosenthal I pasted in the Playground code from the description and ran |
src/components/TopBar/TopBar.tsx
Outdated
</UnstyledLink> | ||
) : null; | ||
const contextMarkup = | ||
!contextControl && logo ? ( |
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.
We will want to use if-else flow control here:
if context control -> render context control
else if logo -> render logo
else -> null
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.
Makes sense that makes it a bit clearer and resolves the no contextControl
nor logo
case.
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.
We are missing a test case for top bar without context control and without logo. Currently that code path with still render and empty context control div.
Yes good catch! Will fix that! |
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.
Didn’t 🎩 but code LGTM
During my 🎩 I noticed this was able to be gotten into a weird state if the initial render was on desktop and you resize it to mobile, where the (I think it is related to how |
WHY are these changes introduced?
As part of the context switching updates (details) this PR proposes a
contextControl
prop thats is added to the<TopBar />
and<Navigation />
components and accepts a component that is ideally used to provide a way for users to switch between admin contexts.WHAT is this pull request doing?
Adds the
contextControl
prop to<TopBar />
and<Navigation />
.How to 🎩
1. Copy-paste this code in
playground/Playground.tsx
:yarn dev
and navigate tohttp://localhost:6006/iframe.html?selectedKind=Playground&selectedStory=Playground
.<TopBar.Menu />
shows up in the far left corner of the top bar.contextControl
prop from the top bar.Button
that was passed intoNavigation
doesn't show up on the page.Button
that was passed intoNavigation
shows up in the side nav.