Skip to content

Commit

Permalink
fix(panel): Correct header and action-bar z-indexing display issues (#…
Browse files Browse the repository at this point in the history
…7440)

**Related Issue:** #7437

## Summary

- Places action-bar within the header so the z-index isn't an issue
anymore
- Adjust styles as necessary
- Adjust rendering as necessary
- Adds screenshot test
  • Loading branch information
driskull committed Aug 4, 2023
1 parent 3dd1e34 commit db7eac7
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 16 deletions.
18 changes: 12 additions & 6 deletions packages/calcite-components/src/components/panel/panel.scss
Expand Up @@ -29,17 +29,23 @@
}

.header {
@apply bg-foreground-1
w-full
items-stretch
justify-start
@apply bg-foreground-1 flex flex-col
z-header;
}

.header-container {
@apply flex flex-row w-full
items-stretch
justify-start;
flex: 0 0 auto;
}

.action-bar-container {
@apply w-full
z-header;
@apply w-full;
}

.top-separator {
border-block-start: 1px solid var(--calcite-ui-border-3);
}

.bottom-separator {
Expand Down
19 changes: 19 additions & 0 deletions packages/calcite-components/src/components/panel/panel.stories.ts
Expand Up @@ -241,6 +241,25 @@ export const actionBarWithoutContent_TestOnly = (): string => html`<calcite-pane
</calcite-action-bar>
</calcite-panel>`;

export const actionBarZIndex_TestOnly = (): string => html`<calcite-panel
style="width: 400px;"
height-scale="s"
menu-open
>
<calcite-action text="banana" text-enabled icon="banana" slot="header-menu-actions"></calcite-action>
<calcite-action text="measure" text-enabled icon="measure" slot="header-menu-actions"></calcite-action>
<calcite-action-bar slot="action-bar">
<calcite-action-group>
<calcite-action text="Add" icon="plus"> </calcite-action>
<calcite-action text="Save" icon="save">
<calcite-tooltip open overlay-positioning="fixed" placement="top" slot="tooltip">test</calcite-tooltip>
</calcite-action>
<calcite-action text="Layers" icon="layers"> </calcite-action>
</calcite-action-group>
</calcite-action-bar>
<p>Some content</p></calcite-panel
>`;

export const footerAndActionBarWithoutContent_TestOnly = (): string => html`<calcite-panel
height-scale="s"
heading="Header!"
Expand Down
26 changes: 16 additions & 10 deletions packages/calcite-components/src/components/panel/panel.tsx
Expand Up @@ -195,6 +195,8 @@ export class Panel

@State() effectiveLocale = "";

@State() showHeaderContent = false;

@Watch("effectiveLocale")
effectiveLocaleChange(): void {
updateMessages(this, this.effectiveLocale);
Expand Down Expand Up @@ -364,7 +366,7 @@ export class Panel
renderActionBar(): VNode {
return (
<div
class={{ [CSS.actionBarContainer]: true, [CSS.bottomSeparator]: this.hasDefaultContent }}
class={{ [CSS.actionBarContainer]: true, [CSS.topSeparator]: this.showHeaderContent }}
hidden={!this.hasActionBar}
>
<slot name={SLOTS.actionBar} onSlotchange={this.handleActionBarSlotChange} />
Expand Down Expand Up @@ -473,23 +475,28 @@ export class Panel

const headerContentNode = this.renderHeaderContent();

const showHeader =
const showHeaderContent =
hasHeaderContent ||
headerContentNode ||
!!headerContentNode ||
hasStartActions ||
hasEndActions ||
closable ||
hasMenuItems;

this.showHeaderContent = showHeaderContent;

return (
<header
class={{ [CSS.header]: true, [CSS.bottomSeparator]: hasDefaultContent || hasActionBar }}
hidden={!showHeader}
class={{ [CSS.header]: true, [CSS.bottomSeparator]: hasDefaultContent }}
hidden={!(showHeaderContent || hasActionBar)}
>
{this.renderHeaderStartActions()}
{this.renderHeaderSlottedContent()}
{headerContentNode}
{this.renderHeaderActionsEnd()}
<div class={CSS.headerContainer} hidden={!showHeaderContent}>
{this.renderHeaderStartActions()}
{this.renderHeaderSlottedContent()}
{headerContentNode}
{this.renderHeaderActionsEnd()}
</div>
{this.renderActionBar()}
</header>
);
}
Expand Down Expand Up @@ -559,7 +566,6 @@ export class Panel
ref={this.setContainerRef}
>
{this.renderHeaderNode()}
{this.renderActionBar()}
{this.renderContent()}
{this.renderFooterNode()}
</article>
Expand Down
2 changes: 2 additions & 0 deletions packages/calcite-components/src/components/panel/resources.ts
Expand Up @@ -3,7 +3,9 @@ export const CSS = {
backButton: "back-button",
container: "container",
header: "header",
headerContainer: "header-container",
bottomSeparator: "bottom-separator",
topSeparator: "top-separator",
heading: "heading",
summary: "summary",
description: "description",
Expand Down

0 comments on commit db7eac7

Please sign in to comment.