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

[core] feat(Dialog): modernise visuals, body & footer components #5753

Merged
merged 12 commits into from
Jan 10, 2023

Conversation

CPerinet
Copy link
Contributor

@CPerinet CPerinet commented Nov 10, 2022

Checklist

  • Update documentation

Changes proposed in this pull request:

  • Reduced title from H5 to H6
  • Header min-height is now based on the button size + padding.
  • Use light-gray5 as default background colour for light mode
  • Enable scrolling of the body past a given height
  • Add a fixed footer. This is especially useful when the dialog body is likely to scroll.
    • Made it use the same class for both normal and multi-step dialog
    • Kept current footer classes

Screenshot

Screenshot 2022-11-10 at 14 50 02

@CPerinet CPerinet marked this pull request as ready for review November 10, 2022 14:51
@@ -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)}
Copy link
Contributor

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:

Suggested change
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`;
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 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.

Comment on lines 137 to 139
<div className={Classes.DIALOG_BODY_SCROLL_CONTAINER}>
{this.props.children}
</div>
Copy link
Contributor

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()}
Copy link
Contributor

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.

Copy link
Contributor Author

@CPerinet CPerinet Nov 14, 2022

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)

@@ -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`;
Copy link
Contributor Author

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.

Copy link
Contributor

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`;
Copy link
Contributor Author

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.

export const DIALOG_CLOSE_BUTTON = `${DIALOG}-close-button`;
export const DIALOG_FOOTER = `${DIALOG}-footer`;
export const DIALOG_FOOTER_CONTAINER = `${DIALOG}-footer-container`;
Copy link
Contributor Author

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.

Copy link
Contributor

@adidahiya adidahiya Jan 9, 2023

Choose a reason for hiding this comment

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

Hmm, I don't think this is quite working like we want it to. I think we can do this without an additional level of DOM nesting, by using a modifier class instead. I'll take a stab at that approach.

before after
image image

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`;
Copy link
Contributor Author

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.)

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`;
Copy link
Contributor Author

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.

Copy link
Contributor

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;
Copy link
Contributor Author

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 {
Copy link
Contributor Author

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;
Copy link
Contributor Author

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.

Copy link
Contributor

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.

Copy link
Contributor

@adidahiya adidahiya left a 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;
Copy link
Contributor

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;
Copy link
Contributor

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.

Copy link
Contributor

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;
Copy link
Contributor

Choose a reason for hiding this comment

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

why the extra padding here? is this intentional? if so, should we add the extra (5px) padding on the right side as well?

before after
image image

Copy link
Contributor

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...

@adidahiya adidahiya dismissed their stale review January 9, 2023 23:41

original CR was addressed, now iterating on final API choices & design

@adidahiya adidahiya changed the title Update dialog [core] feat(Dialog): modernise visuals, add body & footer components Jan 10, 2023
@adidahiya
Copy link
Contributor

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

@adidahiya adidahiya changed the title [core] feat(Dialog): modernise visuals, add body & footer components [core] feat(Dialog): modernise visuals, body & footer components Jan 10, 2023
@adidahiya adidahiya merged commit a154e34 into palantir:develop Jan 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants