-
Notifications
You must be signed in to change notification settings - Fork 77
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
fix(panel): Remove double border styling when content isn't provided #7368
Changes from 11 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); | ||
}; | ||
|
||
// -------------------------------------------------------------------------- | ||
|
@@ -498,12 +481,15 @@ export class Panel | |
} | ||
|
||
renderFooterNode(): VNode { | ||
const { hasFooterContent, hasFooterActions } = this; | ||
const { hasFooterContent, hasFooterActions, hasDefaultContent } = this; | ||
|
||
const showFooter = hasFooterContent || hasFooterActions; | ||
|
||
return ( | ||
<footer class={CSS.footer} hidden={!showFooter}> | ||
<footer | ||
class={{ [CSS.footer]: true, [CSS.footerBorder]: hasDefaultContent }} | ||
hidden={!showFooter} | ||
> | ||
<slot key="footer-slot" name={SLOTS.footer} onSlotchange={this.handleFooterSlotChange} /> | ||
<slot | ||
key="footer-actions-slot" | ||
|
@@ -525,27 +511,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> | ||
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 think you could review these changes? I changed this because it was causing some problems with |
||
) : ( | ||
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}> | ||
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 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. 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.
moved these together since
border-block-end
isnt exactly the same asborder-bottom
. Applies to other CSS