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

fix(block): removes extra loading indicator #7239

Merged
merged 8 commits into from
Jun 29, 2023
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={{
Elijbet marked this conversation as resolved.
Show resolved Hide resolved
[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"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✨🧹✨

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";