Skip to content

Commit

Permalink
feat(block): add icon start/end properties (deprecate icon slot a…
Browse files Browse the repository at this point in the history
…nd `status`), add `actions-end` slot (deprecate `control`), add `content-start` (#9535)

**Related Issue:** #4932

## Summary

- Add `icon-start` and `icon-end` properties. 
- Deprecate `status`.
- Deprecate `icon` in favor of `icon-start`.
- Add `actions-end` slot and deprecate `control` slot.
- Add `content-start`.
  • Loading branch information
Elijbet committed Jun 17, 2024
1 parent 801152c commit 7117c6b
Show file tree
Hide file tree
Showing 6 changed files with 234 additions and 22 deletions.
26 changes: 26 additions & 0 deletions packages/calcite-components/src/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -610,6 +610,18 @@ export namespace Components {
* Specifies the heading level of the component's `heading` for proper document structure, without affecting visual styling.
*/
"headingLevel": HeadingLevel;
/**
* Specifies an icon to display at the end of the component.
*/
"iconEnd": string;
/**
* Displays the `iconStart` and/or `iconEnd` as flipped when the element direction is right-to-left (`"rtl"`).
*/
"iconFlipRtl": FlipContext;
/**
* Specifies an icon to display at the start of the component.
*/
"iconStart": string;
/**
* When `true`, a busy indicator is displayed.
*/
Expand All @@ -636,6 +648,7 @@ export namespace Components {
"setFocus": () => Promise<void>;
/**
* Displays a status-related indicator icon.
* @deprecated Use `icon-start` instead.
*/
"status": Status;
}
Expand Down Expand Up @@ -8337,6 +8350,18 @@ declare namespace LocalJSX {
* Specifies the heading level of the component's `heading` for proper document structure, without affecting visual styling.
*/
"headingLevel"?: HeadingLevel;
/**
* Specifies an icon to display at the end of the component.
*/
"iconEnd"?: string;
/**
* Displays the `iconStart` and/or `iconEnd` as flipped when the element direction is right-to-left (`"rtl"`).
*/
"iconFlipRtl"?: FlipContext;
/**
* Specifies an icon to display at the start of the component.
*/
"iconStart"?: string;
/**
* When `true`, a busy indicator is displayed.
*/
Expand Down Expand Up @@ -8380,6 +8405,7 @@ declare namespace LocalJSX {
"overlayPositioning"?: OverlayPositioning;
/**
* Displays a status-related indicator icon.
* @deprecated Use `icon-start` instead.
*/
"status"?: Status;
}
Expand Down
56 changes: 45 additions & 11 deletions packages/calcite-components/src/components/block/block.scss
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
@import "../../assets/styles/header";

.header {
@apply justify-start p-0;
@apply justify-start;
padding: var(--calcite-spacing-md);
}

.header,
Expand All @@ -31,11 +32,33 @@
.header-container {
@apply grid items-stretch;
grid-template: auto / auto 1fr auto auto;
grid-template-areas: "handle header control menu";
grid-column: header-start / menu-end;
grid-template-areas: "handle header control menu actions-end";
grid-column: header-start / actions-end;
grid-row: 1 / 2;
}

.content-start,
.icon,
.icon--start,
.icon--end {
margin-inline-end: var(--calcite-spacing-md);
}

.icon {
& calcite-loader {
margin-inline-end: var(--calcite-spacing-xxxs);
}
}

.icon--start,
.icon--end {
@apply text-color-3;
}

.actions-end {
grid-area: actions-end;
}

.toggle {
@apply font-sans
focus-base
Expand All @@ -47,9 +70,10 @@
justify-between
border-none
p-0;
text-align: initial;

text-align: initial;
background-color: transparent;

&:hover {
@apply bg-foreground-2;
}
Expand All @@ -69,7 +93,6 @@ calcite-handle {

.title {
@apply m-0;
padding: theme("spacing.3");
}

.header .title .heading {
Expand All @@ -93,9 +116,7 @@ calcite-handle {
}

.icon {
display: flex;
margin-inline-start: theme("spacing.3");
margin-inline-end: 0px;
@apply flex;
}

.status-icon.valid {
Expand All @@ -118,16 +139,21 @@ calcite-handle {
}
}

.icon-end-container {
@apply flex items-center;

margin-inline-start: auto;
}

.toggle-icon {
@apply text-color-3
transition-color
my-3
self-center
justify-self-end
duration-150
ease-in-out;
margin-inline-end: theme("spacing.3");
margin-inline-start: auto;

margin-inline-end: var(--calcite-spacing-md);
}

.toggle:hover .toggle-icon {
Expand All @@ -144,6 +170,10 @@ calcite-handle {
padding-inline: var(--calcite-block-padding, var(--calcite-spacing-md));
}

.content-start {
@apply text-color-3 flex items-center;
}

.control-container {
@apply m-0 flex;
grid-area: control;
Expand All @@ -153,6 +183,10 @@ calcite-action-menu {
grid-area: menu;
}

.actions-end {
@apply flex items-stretch;
}

:host([open]) {
@apply my-2;

Expand Down
35 changes: 35 additions & 0 deletions packages/calcite-components/src/components/block/block.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -271,3 +271,38 @@ export const icons_TestOnly = (): string => html`
</calcite-block-section>
</calcite-block>
`;

export const iconStartEnd = (): string => html`
<h1>content-start and actions-end</h1>
<calcite-block
heading="Valid status"
description="summary"
collapsible
icon-start="pen"
icon-end="pen"
style="width: 500px"
>
<calcite-icon
icon="compass"
slot="content-start"
style="color: var(--calcite-color-status-success)"
scale="s"
></calcite-icon>
<calcite-action appearance="transparent" icon="ellipsis" text="menu" label="menu" slot="actions-end" />
</calcite-block>
<h1>loading and actions-end</h1>
<calcite-block
heading="Valid status"
collapsible
status="valid"
icon-start="pen"
icon-end="pen"
loading
style="width: 500px"
>
<calcite-action appearance="transparent" icon="ellipsis" text="menu" label="menu" slot="actions-end" />
</calcite-block>
`;
Loading

0 comments on commit 7117c6b

Please sign in to comment.