Skip to content
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

chore: cherry-pick patch commits #9950

Merged
merged 3 commits into from
Aug 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
23 changes: 23 additions & 0 deletions packages/calcite-components/src/components/block/block.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,29 @@ describe("calcite-block", () => {
const actionAssignedSlot = await page.$eval("calcite-action", (action) => action.assignedSlot.name);
expect(actionAssignedSlot).toBe(SLOTS.headerMenuActions);
});

it("applies correct header spacing when heading or description properties are present", async () => {
const page = await newE2EPage();

await page.setContent(`<calcite-block></calcite-block>`);

const block = await page.find("calcite-block");
const header = await page.find(`calcite-block >>> .${CSS.header}`);
block.setAttribute("heading", "test-heading");
await page.waitForChanges();

expect(header).toHaveClass(CSS.headerHasText);

block.removeAttribute("heading");
await page.waitForChanges();

expect(header).not.toHaveClass(CSS.headerHasText);

block.setAttribute("description", "test-description");
await page.waitForChanges();

expect(header).toHaveClass(CSS.headerHasText);
});
});

it("should allow the CSS custom property to be overridden when applied to :root", async () => {
Expand Down
11 changes: 4 additions & 7 deletions packages/calcite-components/src/components/block/block.scss
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@
@apply justify-start;
}

.header--has-text {
padding: var(--calcite-spacing-md);
}

.header,
.toggle {
grid-area: header;
Expand Down Expand Up @@ -194,11 +198,4 @@ calcite-action-menu {
}
}

:host([heading]),
:host([description]) {
.header {
padding: var(--calcite-spacing-md);
}
}

@include base-component();
7 changes: 5 additions & 2 deletions packages/calcite-components/src/components/block/block.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -411,12 +411,15 @@ export class Block
}

render(): VNode {
const { collapsible, el, loading, open, heading, messages } = this;
const { collapsible, el, loading, open, heading, messages, description } = this;

const toggleLabel = open ? messages.collapse : messages.expand;

const headerContent = (
<header class={CSS.header} id={IDS.header}>
<header
class={{ [CSS.header]: true, [CSS.headerHasText]: !!(heading || description) }}
id={IDS.header}
>
{this.renderIcon("start")}
{this.renderContentStart()}
{this.renderLoaderStatusIcon()}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export const CSS = {
description: "description",
header: "header",
headerContainer: "header-container",
headerHasText: "header--has-text",
heading: "heading",
icon: "icon",
iconStart: "icon--start",
Expand Down
2 changes: 1 addition & 1 deletion packages/calcite-components/src/components/modal/modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ let initialDocumentOverflowStyle: string = "";

logger.deprecated("component", {
name: "modal",
removalVersion: 3,
removalVersion: 4,
suggested: "dialog",
});

Expand Down
11 changes: 9 additions & 2 deletions packages/calcite-components/src/components/panel/panel.scss
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

:host([scale="s"]) {
--calcite-internal-panel-default-padding: var(--calcite-spacing-sm);
--calcite-internal-panel-header-vertical-padding: 10px; // this should use a spacing token once made available

.header-content {
.heading {
Expand All @@ -34,6 +35,7 @@

:host([scale="m"]) {
--calcite-internal-panel-default-padding: var(--calcite-spacing-md);
--calcite-internal-panel-header-vertical-padding: var(--calcite-spacing-lg);

.header-content {
.heading {
Expand All @@ -48,6 +50,7 @@

:host([scale="l"]) {
--calcite-internal-panel-default-padding: var(--calcite-spacing-xl);
--calcite-internal-panel-header-vertical-padding: var(--calcite-spacing-xxl);

.header-content {
.heading {
Expand Down Expand Up @@ -163,11 +166,15 @@
}

.content-top,
.content-bottom,
.header-content {
.content-bottom {
padding: var(--calcite-internal-panel-default-padding);
}

.header-content {
padding-block: var(--calcite-internal-panel-header-vertical-padding);
padding-inline: var(--calcite-internal-panel-default-padding);
}

.footer {
@apply flex mt-auto flex-row content-between justify-center items-center bg-foreground-1 text-n2-wrap;
border-block-start: 1px solid var(--calcite-color-border-3);
Expand Down
Loading