Skip to content

Commit

Permalink
refactor(shell-panel): Remove usage of getSlotted utility. #6059 (#7465)
Browse files Browse the repository at this point in the history
**Related Issue:** #6059

## Summary

- Remove usage of getSlotted utility
  • Loading branch information
driskull authored and benelan committed Aug 16, 2023
1 parent 02e6a6f commit 7c64627
Showing 1 changed file with 11 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import {
} from "../../utils/conditionalSlot";
import {
getElementDir,
getSlotted,
isPrimaryPointerButton,
slotChangeGetAssignedElements,
slotChangeHasAssignedElement,
} from "../../utils/dom";
import { connectLocalized, disconnectLocalized, LocalizedComponent } from "../../utils/locale";
import { clamp } from "../../utils/math";
Expand Down Expand Up @@ -214,21 +214,19 @@ export class ShellPanel implements ConditionalSlotComponent, LocalizedComponent,
updateMessages(this, this.effectiveLocale);
}

@State() hasHeader = false;

// --------------------------------------------------------------------------
//
// Render Methods
//
// --------------------------------------------------------------------------
renderHeader(): VNode {
const { el } = this;

const hasHeader = getSlotted(el, SLOTS.header);

return hasHeader ? (
<div class={CSS.contentHeader} key="header">
<slot name={SLOTS.header} />
return (
<div class={CSS.contentHeader} hidden={!this.hasHeader} key="header">
<slot name={SLOTS.header} onSlotchange={this.handleHeaderSlotChange} />
</div>
) : null;
);
}

render(): VNode {
Expand Down Expand Up @@ -636,4 +634,8 @@ export class ShellPanel implements ConditionalSlotComponent, LocalizedComponent,
this.actionBars = actionBars;
this.setActionBarsLayout(actionBars);
};

handleHeaderSlotChange = (event: Event): void => {
this.hasHeader = slotChangeHasAssignedElement(event);
};
}

0 comments on commit 7c64627

Please sign in to comment.