Skip to content
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
6 changes: 3 additions & 3 deletions packages/calcite-components/src/components/block/block.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -427,17 +427,17 @@ describe("calcite-block", () => {
block.setAttribute("heading", "test-heading");
await page.waitForChanges();

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

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

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

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

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

Expand Down
15 changes: 12 additions & 3 deletions packages/calcite-components/src/components/block/block.scss
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,13 @@

:host([scale="s"]) {
.header {
padding: var(--calcite-spacing-sm);
gap: var(--calcite-spacing-sm);
}

.header--has-content {
padding: var(--calcite-spacing-sm);
}

.icon-end-container {
gap: var(--calcite-spacing-sm);
padding-inline-end: var(--calcite-spacing-sm);
Expand All @@ -55,10 +58,13 @@

:host([scale="m"]) {
.header {
padding: var(--calcite-spacing-md);
gap: var(--calcite-spacing-md);
}

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

.icon-end-container {
gap: var(--calcite-spacing-md);
padding-inline-end: var(--calcite-spacing-md);
Expand All @@ -84,10 +90,13 @@

:host([scale="l"]) {
.header {
padding: var(--calcite-spacing-lg);
gap: var(--calcite-spacing-lg);
}

.header--has-content {
padding: var(--calcite-spacing-lg);
}

.icon-end-container {
gap: var(--calcite-spacing-lg);
padding-inline-end: var(--calcite-spacing-lg);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -387,3 +387,12 @@ export const allScales = (): string =>
}
</style>
<div class="container">${blockHTML("s")} ${blockHTML("m")} ${blockHTML("l")}</div>`;

export const emptyHeader = (): string => html`
<calcite-block expanded calcite-hydrated>
<calcite-label layout="inline-space-between">
<div>Favorite vegetable</div>
<calcite-icon icon="information" />
</calcite-label>
</calcite-block>
`;
15 changes: 14 additions & 1 deletion packages/calcite-components/src/components/block/block.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -530,13 +530,26 @@ export class Block extends LitElement implements InteractiveComponent, OpenClose
setSize,
dragDisabled,
sortDisabled,
hasContentStart,
iconStart,
} = this;

const toggleLabel = expanded ? messages.collapse : messages.expand;
const headerHasContent = !!(
heading ||
description ||
hasContentStart ||
iconStart ||
loading ||
status
);

const headerContent = (
<header
class={{ [CSS.header]: true, [CSS.headerHasText]: !!(heading || description) }}
class={{
[CSS.header]: true,
[CSS.headerHasContent]: headerHasContent,
}}
id={IDS.header}
>
{this.renderIcon("start")}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const CSS = {
description: "description",
header: "header",
headerContainer: "header-container",
headerHasText: "header--has-text",
headerHasContent: "header--has-content",
heading: "heading",
icon: "icon",
iconStart: "icon--start",
Expand Down
Loading