Skip to content
This repository has been archived by the owner on Jun 29, 2023. It is now read-only.

Commit

Permalink
feat(block): use Scrim for loading & disabled.
Browse files Browse the repository at this point in the history
  • Loading branch information
asangma committed Oct 17, 2019
1 parent 808a63f commit 9ddab6a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 25 deletions.
19 changes: 0 additions & 19 deletions src/components/calcite-block/calcite-block.scss
Original file line number Diff line number Diff line change
Expand Up @@ -10,29 +10,10 @@
box-shadow: 0 0 0 1px var(--calcite-app-border);
}

:host([loading]) .content:after,
:host([disabled]) .content:after {
content: "";
background-color: var(--calcite-app-scrim);
position: absolute;
z-index: 1;
left: 0;
right: 0;
bottom: 0;
top: 0;
}

calcite-loader[inline] {
color: var(--calcite-app-foreground-subtle);
}

:host([disabled]) {
.header-container {
opacity: var(--calcite-app-disabled-opacity);
pointer-events: none;
}
}

.header-container {
& > .header {
padding: var(--calcite-app-cap-spacing-half) var(--calcite-app-side-spacing-half);
Expand Down
18 changes: 12 additions & 6 deletions src/components/calcite-block/calcite-block.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { Component, Element, Event, EventEmitter, Prop, h } from "@stencil/core";
import { Component, Element, Event, EventEmitter, Host, Prop, h } from "@stencil/core";
import { chevronDown16, chevronUp16 } from "@esri/calcite-ui-icons";
import { CSS, TEXT } from "./resources";
import CalciteIcon from "../utils/CalciteIcon";
import { CalciteTheme } from "../interfaces";
import { VNode } from "@esri/calcite-components/dist/types/stencil.core";
import CalciteScrim from "../utils/CalciteScrim";

const CONTROL_SLOT_NAME = "control";

Expand Down Expand Up @@ -116,6 +118,12 @@ export class CalciteBlock {
this.calciteBlockToggle.emit();
};

renderScrim(): VNode {
return this.loading || this.disabled ? (
<CalciteScrim loading={this.loading}></CalciteScrim>
) : null;
}

// --------------------------------------------------------------------------
//
// Render Methods
Expand All @@ -142,11 +150,8 @@ export class CalciteBlock {
<h3 class={CSS.heading}>{heading}</h3>
{summary ? <div class={CSS.summary}>{summary}</div> : null}
</div>
{!this.loading ? (
<slot name={CONTROL_SLOT_NAME} />
) : (
<calcite-loader inline is-active></calcite-loader>
)}
{loading || disabled ? null : <slot name={CONTROL_SLOT_NAME} />}
{loading ? <calcite-loader inline is-active></calcite-loader> : null}
</header>
);

Expand Down Expand Up @@ -184,6 +189,7 @@ export class CalciteBlock {
{headerNode}
<div class={CSS.content} hidden={!hasContent || !open}>
<slot />
{loading || disabled ? <CalciteScrim loading={false}></CalciteScrim> : null}
</div>
</article>
</Host>
Expand Down

0 comments on commit 9ddab6a

Please sign in to comment.