-
Notifications
You must be signed in to change notification settings - Fork 89
fix(panel): Remove double border styling when content isn't provided #7368
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
Changes from all commits
8fe2141
4eca82f
18b6399
c44eaf7
c72b469
27e11d5
38debdf
8b9ee32
862c543
3250ea2
14d2a7c
144edd6
6ae14e4
1d97835
dddf440
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,7 +11,12 @@ import { | |
| VNode, | ||
| Watch, | ||
| } from "@stencil/core"; | ||
| import { focusFirstTabbable, slotChangeGetAssignedElements, toAriaBoolean } from "../../utils/dom"; | ||
| import { | ||
| focusFirstTabbable, | ||
| slotChangeGetAssignedElements, | ||
| slotChangeHasAssignedElement, | ||
| toAriaBoolean, | ||
| } from "../../utils/dom"; | ||
| import { | ||
| connectInteractive, | ||
| disconnectInteractive, | ||
|
|
@@ -168,6 +173,8 @@ export class Panel | |
|
|
||
| resizeObserver = createObserver("resize", () => this.resizeHandler()); | ||
|
|
||
| @State() hasDefaultContent = false; | ||
|
|
||
| @State() hasStartActions = false; | ||
|
|
||
| @State() hasEndActions = false; | ||
|
|
@@ -257,28 +264,20 @@ export class Panel | |
| this.calcitePanelScroll.emit(); | ||
| }; | ||
|
|
||
| handleHeaderActionsStartSlotChange = (event: Event): void => { | ||
| const elements = (event.target as HTMLSlotElement).assignedElements({ | ||
| flatten: true, | ||
| }); | ||
| handleDefaultSlotChange = (event: Event): void => { | ||
| this.hasDefaultContent = slotChangeHasAssignedElement(event); | ||
| }; | ||
|
|
||
| this.hasStartActions = !!elements.length; | ||
| handleHeaderActionsStartSlotChange = (event: Event): void => { | ||
| this.hasStartActions = slotChangeHasAssignedElement(event); | ||
| }; | ||
|
|
||
| handleHeaderActionsEndSlotChange = (event: Event): void => { | ||
| const elements = (event.target as HTMLSlotElement).assignedElements({ | ||
| flatten: true, | ||
| }); | ||
|
|
||
| this.hasEndActions = !!elements.length; | ||
| this.hasEndActions = slotChangeHasAssignedElement(event); | ||
| }; | ||
|
|
||
| handleHeaderMenuActionsSlotChange = (event: Event): void => { | ||
| const elements = (event.target as HTMLSlotElement).assignedElements({ | ||
| flatten: true, | ||
| }); | ||
|
|
||
| this.hasMenuItems = !!elements.length; | ||
| this.hasMenuItems = slotChangeHasAssignedElement(event); | ||
| }; | ||
|
|
||
| handleActionBarSlotChange = (event: Event): void => { | ||
|
|
@@ -292,35 +291,19 @@ export class Panel | |
| }; | ||
|
|
||
| handleHeaderContentSlotChange = (event: Event): void => { | ||
| const elements = (event.target as HTMLSlotElement).assignedElements({ | ||
| flatten: true, | ||
| }); | ||
|
|
||
| this.hasHeaderContent = !!elements.length; | ||
| this.hasHeaderContent = slotChangeHasAssignedElement(event); | ||
| }; | ||
|
|
||
| handleFooterSlotChange = (event: Event): void => { | ||
| const elements = (event.target as HTMLSlotElement).assignedElements({ | ||
| flatten: true, | ||
| }); | ||
|
|
||
| this.hasFooterContent = !!elements.length; | ||
| this.hasFooterContent = slotChangeHasAssignedElement(event); | ||
| }; | ||
|
|
||
| handleFooterActionsSlotChange = (event: Event): void => { | ||
| const elements = (event.target as HTMLSlotElement).assignedElements({ | ||
| flatten: true, | ||
| }); | ||
|
|
||
| this.hasFooterActions = !!elements.length; | ||
| this.hasFooterActions = slotChangeHasAssignedElement(event); | ||
| }; | ||
|
|
||
| handleFabSlotChange = (event: Event): void => { | ||
| const elements = (event.target as HTMLSlotElement).assignedElements({ | ||
| flatten: true, | ||
| }); | ||
|
|
||
| this.hasFab = !!elements.length; | ||
| this.hasFab = slotChangeHasAssignedElement(event); | ||
| }; | ||
|
|
||
| // -------------------------------------------------------------------------- | ||
|
|
@@ -380,7 +363,10 @@ export class Panel | |
|
|
||
| renderActionBar(): VNode { | ||
| return ( | ||
| <div class={CSS.actionBarContainer} hidden={!this.hasActionBar}> | ||
| <div | ||
| class={{ [CSS.actionBarContainer]: true, [CSS.bottomSeparator]: this.hasDefaultContent }} | ||
| hidden={!this.hasActionBar} | ||
| > | ||
| <slot name={SLOTS.actionBar} onSlotchange={this.handleActionBarSlotChange} /> | ||
| </div> | ||
| ); | ||
|
|
@@ -475,7 +461,15 @@ export class Panel | |
| } | ||
|
|
||
| renderHeaderNode(): VNode { | ||
| const { hasHeaderContent, hasStartActions, hasEndActions, closable, hasMenuItems } = this; | ||
| const { | ||
| hasHeaderContent, | ||
| hasStartActions, | ||
| hasEndActions, | ||
| closable, | ||
| hasMenuItems, | ||
| hasDefaultContent, | ||
| hasActionBar, | ||
| } = this; | ||
|
|
||
| const headerContentNode = this.renderHeaderContent(); | ||
|
|
||
|
|
@@ -488,7 +482,10 @@ export class Panel | |
| hasMenuItems; | ||
|
|
||
| return ( | ||
| <header class={CSS.header} hidden={!showHeader}> | ||
| <header | ||
| class={{ [CSS.header]: true, [CSS.bottomSeparator]: hasDefaultContent || hasActionBar }} | ||
| hidden={!showHeader} | ||
| > | ||
| {this.renderHeaderStartActions()} | ||
| {this.renderHeaderSlottedContent()} | ||
| {headerContentNode} | ||
|
|
@@ -525,27 +522,16 @@ export class Panel | |
| }; | ||
|
|
||
| renderContent(): VNode { | ||
| const { hasFab } = this; | ||
|
|
||
| const defaultSlotNode: VNode = <slot key="default-slot" />; | ||
| const containerNode = hasFab ? ( | ||
| <section class={CSS.contentContainer}>{defaultSlotNode}</section> | ||
| ) : ( | ||
| defaultSlotNode | ||
| ); | ||
|
|
||
| return ( | ||
| <div | ||
| class={{ | ||
| [CSS.contentWrapper]: true, | ||
| [CSS.contentContainer]: !hasFab, | ||
| [CSS.contentHeight]: hasFab, | ||
| }} | ||
| class={CSS.contentWrapper} | ||
| onScroll={this.panelScrollHandler} | ||
| // eslint-disable-next-line react/jsx-sort-props | ||
| ref={this.setPanelScrollEl} | ||
| > | ||
| {containerNode} | ||
| <section class={CSS.contentContainer}> | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @asangma do you remember why this
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the section was there to keep the FAB sticky. But if it can be sticky without the section, that's cool too.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok. i have it so the section is always there regardless of the FAB or not. Ill move forward with that since its safer. |
||
| <slot onSlotchange={this.handleDefaultSlotChange} /> | ||
| </section> | ||
| {this.renderFab()} | ||
| </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.
@asangma do you think you could review these changes? I changed this because it was causing some problems with
onSlotChangesince this default slot was getting moved into a section element depending on if there was a FAB or not. I don't think its necessary if we always have the section element present and the FAB content classes are no longer conditional.