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

Commit

Permalink
fix: calcite-block disabled state doesn't 'hide' slider handle #560 (#…
Browse files Browse the repository at this point in the history
…567)

* handle zIndex issues for CalciteScrim

* scrim for panel

* apply to other components.

* cleanup

* revert stuff

* set loading prop

* more legible code

* self closing tags
  • Loading branch information
driskull authored Nov 15, 2019
1 parent d426a40 commit 8d823db
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 15 deletions.
5 changes: 3 additions & 2 deletions src/components/calcite-block/calcite-block.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,9 @@ export class CalciteBlock {
<article aria-expanded={collapsible ? (open ? "true" : "false") : null} aria-busy={loading}>
{headerNode}
<div class={CSS.content} hidden={!hasContent || !open}>
<slot />
{loading || disabled ? <CalciteScrim loading={false}></CalciteScrim> : null}
<CalciteScrim loading={loading} disabled={disabled}>
<slot />
</CalciteScrim>
</div>
</article>
</Host>
Expand Down
10 changes: 2 additions & 8 deletions src/components/calcite-panel/calcite-panel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -189,14 +189,8 @@ export class CalcitePanel {
);
}

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

render() {
const { dismissed, dismissible, el, loading, panelKeyUpHandler } = this;
const { dismissed, disabled, dismissible, el, loading, panelKeyUpHandler } = this;

const rtl = getElementDir(el) === "rtl";

Expand All @@ -215,7 +209,7 @@ export class CalcitePanel {
{this.renderContent()}
{this.renderFooter()}
</article>
{this.renderScrim()}
<CalciteScrim loading={loading} disabled={disabled} />
</Host>
);
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/calcite-pick-list/shared-list-render.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { VNode } from "@esri/calcite-components/dist/types/stencil.core";
import { CSS } from "./resources";

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

export const List = ({ props, text, ...rest }): VNode => {
Expand Down
23 changes: 19 additions & 4 deletions src/components/utils/CalciteScrim.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { FunctionalComponent, h } from "@stencil/core";
const divStyle = {
const scrimDivStyle = {
alignItems: "center",
animation:
"calcite-app-fade-in var(--calcite-app-animation-time) var(--calcite-app-easing-function)",
Expand All @@ -16,10 +16,25 @@ const divStyle = {

interface ScrimProps {
loading: boolean;
disabled: boolean;
}

export const CalciteScrim: FunctionalComponent<ScrimProps> = ({ loading }) => (
<div style={divStyle}>{loading ? <calcite-loader is-active></calcite-loader> : null}</div>
);
const containerDivStyle = {
position: "relative",
zIndex: "1"
};

export const CalciteScrim: FunctionalComponent<ScrimProps> = ({ loading, disabled }, children) => {
const renderScrim = disabled || loading;
const hasChildren = children?.length;

const loaderNode = loading ? <calcite-loader is-active></calcite-loader> : null;

const scrimContainerNode = <div style={scrimDivStyle}>{loaderNode}</div>;

const childContainerNode = hasChildren ? <div style={containerDivStyle}>{children}</div> : null;

return renderScrim ? [scrimContainerNode, childContainerNode] : children;
};

export default CalciteScrim;

0 comments on commit 8d823db

Please sign in to comment.