Skip to content

Commit

Permalink
fix(block): removes extra loading indicator (#7239)
Browse files Browse the repository at this point in the history
**Related Issue:** #6485

## Summary

`calcite-block header` had two loading indicators. This removes the
extra `calcite-loader` from the right end, and places it as an option in
`icon-slot`,`statusIcons: valid or invalid` as well as `controls` now
appear regardless of `loading` state.
  • Loading branch information
Elijbet authored Jun 29, 2023
1 parent bf0ff67 commit a334a75
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 21 deletions.
7 changes: 4 additions & 3 deletions packages/calcite-components/src/components/block/block.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -252,9 +252,10 @@ describe("calcite-block", () => {
expect(headerIconEle).toBeNull();

const statusIcon = await page.find(`calcite-block >>> .${CSS.statusIcon}`);
const loadingIcon = await page.find(`calcite-block >>> .${CSS.loading}`);
expect(statusIcon).not.toBeNull();
expect(loadingIcon).not.toBeNull();
const loader = await page.find(`calcite-block >>> calcite-loader`);

expect(statusIcon).toBeNull();
expect(loader).not.toBeNull();
});

it("allows users to slot in actions in a header menu", async () => {
Expand Down
4 changes: 0 additions & 4 deletions packages/calcite-components/src/components/block/block.scss
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,6 @@ calcite-handle {
color: theme("colors.danger");
}

.status-icon.loading {
animation: spin scaleDuration(--calcite-internal-animation-timing-slow, 2) linear infinite;
}

@keyframes spin {
0% {
transform: rotate(0deg);
Expand Down
15 changes: 6 additions & 9 deletions packages/calcite-components/src/components/block/block.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -237,23 +237,22 @@ export class Block
}

renderIcon(): VNode[] {
const { el, status } = this;
const { el, loading, messages, status } = this;

const showingLoadingStatus = this.loading && !this.open;

const statusIcon = showingLoadingStatus ? ICONS.refresh : ICONS[status];
const statusIcon = ICONS[status];

const hasIcon = getSlotted(el, SLOTS.icon) || statusIcon;

const iconEl = !statusIcon ? (
<slot key="icon-slot" name={SLOTS.icon} />
) : loading ? (
<calcite-loader inline label={messages.loading} />
) : (
<calcite-icon
class={{
[CSS.statusIcon]: true,
[CSS.valid]: status == "valid",
[CSS.invalid]: status == "invalid",
[CSS.loading]: showingLoadingStatus
[CSS.invalid]: status == "invalid"
}}
icon={statusIcon}
scale="m"
Expand Down Expand Up @@ -321,9 +320,7 @@ export class Block
) : (
headerContent
)}
{loading ? (
<calcite-loader inline label={messages.loading} />
) : hasControl ? (
{hasControl ? (
<div class={CSS.controlContainer}>
<slot name={SLOTS.control} />
</div>
Expand Down
6 changes: 2 additions & 4 deletions packages/calcite-components/src/components/block/resources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ export const CSS = {
description: "description",
controlContainer: "control-container",
valid: "valid",
invalid: "invalid",
loading: "loading"
invalid: "invalid"
};

export const TEXT = {
Expand All @@ -35,6 +34,5 @@ export const ICONS = {
opened: "chevron-up",
closed: "chevron-down",
valid: "check-circle",
invalid: "exclamation-mark-triangle",
refresh: "refresh"
invalid: "exclamation-mark-triangle"
};
1 change: 0 additions & 1 deletion packages/calcite-components/src/components/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,4 @@ export type SelectionMode =
| "multiple";
export type Scale = "s" | "m" | "l";
export type Status = "invalid" | "valid" | "idle";

export type Width = "auto" | "half" | "full";

0 comments on commit a334a75

Please sign in to comment.