-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
[core] feat(Dialog): modernise visuals, body & footer components #5753
Conversation
@@ -121,14 +126,19 @@ export class Dialog extends AbstractPureComponent2<DialogProps> { | |||
<Overlay {...this.props} className={Classes.OVERLAY_SCROLL_CONTAINER} hasBackdrop={true}> | |||
<div className={Classes.DIALOG_CONTAINER} ref={this.props.containerRef}> | |||
<div | |||
className={classNames(Classes.DIALOG, this.props.className)} | |||
className={classNames(Classes.DIALOG, this.props.footer != null && Classes.DIALOG_NO_PADDING, this.props.className)} |
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.
classNames has a slightly nicer syntax for conditional classes:
className={classNames(Classes.DIALOG, this.props.footer != null && Classes.DIALOG_NO_PADDING, this.props.className)} | |
className={classNames(Classes.DIALOG, this.props.className, { | |
[Classes.DIALOG_NO_PADDING]: this.props.footer != null, | |
})} |
@@ -197,7 +200,6 @@ export const MULTISTEP_DIALOG = `${NS}-multistep-dialog`; | |||
export const MULTISTEP_DIALOG_PANELS = `${MULTISTEP_DIALOG}-panels`; | |||
export const MULTISTEP_DIALOG_LEFT_PANEL = `${MULTISTEP_DIALOG}-left-panel`; | |||
export const MULTISTEP_DIALOG_RIGHT_PANEL = `${MULTISTEP_DIALOG}-right-panel`; | |||
export const MULTISTEP_DIALOG_FOOTER = `${MULTISTEP_DIALOG}-footer`; |
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 is part of the public API, so unfortunately we can't remove it so easily in this PR. we'll have to keep this constant here and continue adding the class name to the DOM in packages/core/src/components/dialog/multistepDialog.tsx
on L220 (this will also fix the failing tests in this PR), but we can remove its Sass styles and rely on a new class name for the updated styling.
<div className={Classes.DIALOG_BODY_SCROLL_CONTAINER}> | ||
{this.props.children} | ||
</div> |
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'm afraid this may be a breaking change for some consumers who are applying their own scroll/overflow styles to dialogs. We will have to add it in a non-breaking way with a new prop, something like useScrollableBodyContainer?: boolean
where the default is false
to preserve existing behavior.
Or: see my comment below with an API proposal with 3 new components.
{this.props.children} | ||
</div> | ||
|
||
{this.maybeRenderFixedFooter()} |
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.
The ergonomics / developer experience of this new footer feel a little awkward to me right now.
We've kept the Dialog component pretty simple so far, but if we're trying to add more functionality to improve & evolve its layout, we may want to reconsider the design choice of using only a single React component.
I think if we add 3 new components, we can create an API that's more legible while still preserving backwards-compatibility:
<Dialog isOpen={...} onClose={...}>
<DialogHeader title="..." icon="..." isCloseButtonShown={...} />
<DialogBody useOverflowScrollContainer={...}> // <-- scroll container would be enabled by default
{/* children go here */}
</DialogBody>
<DialogFooter fixed={...} actions={...}>
{/* footer left content goes here */}
</DialogFooter>
</Dialog>
If you like this direction, I can help you implement these changes in this PR.
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 don't have a strong preference here. I've also seen the following pattern:
<Dialog
header={IDialogHeader.basic(
{
title: "Title",
icon: IconNames.FOLDER,
isCloseButtonShown: false,
})
footer={IDialogFooter.fixed(
{
left: "",
actions: ""
})
useOverflowScrollContainer={true}
>
// Content
</Dialog>
That may help with discoverability of features? Not sure how back-compatible that would be.
(I'm going to hold off on making the other changes while we discuss the API)
packages/core/src/common/classes.ts
Outdated
@@ -116,8 +116,14 @@ export const CONTROL_GROUP = `${NS}-control-group`; | |||
export const DIALOG = `${NS}-dialog`; | |||
export const DIALOG_CONTAINER = `${DIALOG}-container`; | |||
export const DIALOG_BODY = `${DIALOG}-body`; | |||
export const DIALOG_BODY_NO_PADDING = `${DIALOG}-body-no-padding`; |
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.
not only provides padding but also scroll. Thus, I'm adding a way to remove padding as just not using is not practical.
Adding a "subtractive" class to keep DIALOG_BODY as close from current.
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.
it seems like this class is not being demonstrated in the example... do we need to add it to the public API right now? maybe we can hold off on adding it until we find a concrete use case for it. until then, users can apply custom styles to get padding: 0
.
@@ -116,8 +116,14 @@ export const CONTROL_GROUP = `${NS}-control-group`; | |||
export const DIALOG = `${NS}-dialog`; | |||
export const DIALOG_CONTAINER = `${DIALOG}-container`; | |||
export const DIALOG_BODY = `${DIALOG}-body`; | |||
export const DIALOG_BODY_NO_PADDING = `${DIALOG}-body-no-padding`; | |||
export const DIALOG_BODY_SCROLL_CONTAINER = `${DIALOG}-body-scroll-container`; |
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.
Class applied when making scrollable.
packages/core/src/common/classes.ts
Outdated
export const DIALOG_CLOSE_BUTTON = `${DIALOG}-close-button`; | ||
export const DIALOG_FOOTER = `${DIALOG}-footer`; | ||
export const DIALOG_FOOTER_CONTAINER = `${DIALOG}-footer-container`; |
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.
Needed to apply flex properties on left and right side of the footer. Did not directly added to DIALOG_FOOTER to keep it as current.
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.
packages/core/src/common/classes.ts
Outdated
export const DIALOG_CLOSE_BUTTON = `${DIALOG}-close-button`; | ||
export const DIALOG_FOOTER = `${DIALOG}-footer`; | ||
export const DIALOG_FOOTER_CONTAINER = `${DIALOG}-footer-container`; | ||
export const DIALOG_FIXED_FOOTER = `${DIALOG}-fixed-footer`; |
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.
Styling for the fixed footer (white background, border &c.)
packages/core/src/common/classes.ts
Outdated
export const DIALOG_CLOSE_BUTTON = `${DIALOG}-close-button`; | ||
export const DIALOG_FOOTER = `${DIALOG}-footer`; | ||
export const DIALOG_FOOTER_CONTAINER = `${DIALOG}-footer-container`; | ||
export const DIALOG_FIXED_FOOTER = `${DIALOG}-fixed-footer`; | ||
export const DIALOG_INLINE_FOOTER = `${DIALOG}-inline-footer`; |
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.
Same for inline, in this case, it is just spacing.
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 a better name for this would be "minimal", as it's a kind of minimal appearance. "Inline" is a bit confusing because it's not using inline layout; it's a "block" element with display: flex
.
@@ -0,0 +1,13 @@ | |||
.#{$ns}-dialog-body { | |||
flex: 1 1 auto; | |||
padding: $dialog-padding; |
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.
Changed margin to padding so the scroll works better. Should not cause regressions.
Removed line-height, did not seem appropriate default.
flex: 1 0 auto; | ||
} | ||
|
||
.#{$ns}-dialog-footer-actions { |
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.
Moved, no changes
@@ -0,0 +1,40 @@ | |||
.#{$ns}-dialog-footer { | |||
flex: 0 0 auto; |
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.
Removed side margin. Will break things. I can add a class to keep it and then suppress it if using the new component.
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.
Yeah, we'll need to keep the existing margin and add any new functionality with a modifier class.
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'd like to push a commit to address my comments about the breaking changes. I also want to clean up a few things, fix lint, etc.
@@ -0,0 +1,40 @@ | |||
.#{$ns}-dialog-footer { | |||
flex: 0 0 auto; |
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.
Yeah, we'll need to keep the existing margin and add any new functionality with a modifier class.
|
||
.#{$ns}-dialog-body { | ||
flex: 1 1 auto; | ||
line-height: $pt-grid-size * 1.8; |
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.
unfortunately we need to keep this style too, it's too risky to change, and it's part of our API contract not to break styles on public class names like this.
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.
actually, I take this back -- this is the default line height, and it's applied by the base-typography()
Sass mixin on body
already, so it's probably ok to remove this style 👍
border-radius: 0 0 $dialog-border-radius $dialog-border-radius; | ||
border-top: 1px solid $pt-divider-black; | ||
padding: $pt-grid-size; | ||
padding-left: $dialog-padding; |
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.
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 see now that it's a little tricky to design this style to work for both button and non-button content. In the docs example we have some text in the "left" section for Dialog, but there's a button in that same place for MultiStepDialog...
original CR was addressed, now iterating on final API choices & design
There's a bug in the preview script which is now failing on builds from forks. I'll fix that separately. For now you can view the latest docs preview here: https://output.circle-artifacts.com/output/job/a9d924bc-9ef0-4993-8939-2eb3fcabbd68/artifacts/0/packages/docs-app/dist/index.html |
Checklist
Changes proposed in this pull request:
Screenshot