Skip to content

fix(shell): update shell to correctly position calcite shell panel at shell's bottom #9748

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

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ export const CSS = {
main: "main",
content: "content",
contentBehind: "content--behind",
contentBottom: "content-bottom",
contentNonInteractive: "content--non-interactive",
footer: "footer",
positionedSlotWrapper: "positioned-slot-wrapper",
Expand Down
5 changes: 5 additions & 0 deletions packages/calcite-components/src/components/shell/shell.scss
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@

.content {
@apply overflow-auto;
justify-content: space-between;
}

.content ::slotted(calcite-shell-center-row),
Expand Down Expand Up @@ -97,6 +98,10 @@ slot[name="panel-bottom"]::slotted(calcite-shell-center-row:not([detached])) {
min-inline-size: 0;
}

.content-bottom {
justify-content: flex-end;
}

::slotted(calcite-shell-center-row) {
flex: none;
align-self: stretch;
Expand Down
19 changes: 17 additions & 2 deletions packages/calcite-components/src/components/shell/shell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,13 @@ export class Shell implements ConditionalSlotComponent {

const contentContainerKey = "content-container";

const shellPanels: Array<HTMLCalciteShellPanelElement> = Array.from(
Copy link
Member

Choose a reason for hiding this comment

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

fixme: This would't work in cases when shell-panels are slotted in after the shell has been initialized. Instead, an onSlotChange should be used to find shell-panels.

this.el.querySelectorAll("calcite-shell-panel"),
);
const hasOnlyBottomPanel: boolean = !!(
shellPanels.length === 1 && shellPanels.find((element) => element.slot === "panel-bottom")
Copy link
Member

Choose a reason for hiding this comment

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

fixme: Instead, use an onSlotChange event for the panel-bottom slot to determine if a panel bottom shell panel exists and save the state to a State() variable. Also you would need to determine if panel-top slotted element exists and save that to a state. The combined two of those state should give you if one is only panel-bottom. Another state for hasOnlyBottomPanel could be calculated from the two.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@driskull I updated the logic to use onSlotChange events, please let me know if this looks okay.

);

const content = this.contentBehind
? [
<div
Expand All @@ -204,14 +211,22 @@ export class Shell implements ConditionalSlotComponent {
>
{defaultSlotContainerNode}
</div>,
<div class={CSS.contentBehindCenterContent}>
<div
class={{
[CSS.contentBehindCenterContent]: true,
[CSS.contentBottom]: hasOnlyBottomPanel,
}}
>
{panelTopSlotNode}
{panelBottomSlotNode}
{deprecatedCenterRowSlotNode}
</div>,
]
: [
<div class={CSS.content} key={contentContainerKey}>
<div
class={{ [CSS.content]: true, [CSS.contentBottom]: hasOnlyBottomPanel }}
key={contentContainerKey}
>
{panelTopSlotNode}
{defaultSlotContainerNode}
{panelBottomSlotNode}
Expand Down
Loading