diff --git a/packages/web-components/src/components/inline-loading/inline-loading.ts b/packages/web-components/src/components/inline-loading/inline-loading.ts index d37b46085158..0d5ecfd425b0 100644 --- a/packages/web-components/src/components/inline-loading/inline-loading.ts +++ b/packages/web-components/src/components/inline-loading/inline-loading.ts @@ -13,7 +13,6 @@ import { classMap } from 'lit/directives/class-map.js'; import CheckmarkFilled16 from '@carbon/icons/lib/checkmark--filled/16.js'; import ErrorFilled16 from '@carbon/icons/lib/error--filled/16.js'; import { prefix } from '../../globals/settings'; -import LOADING_TYPE from '../loading/types'; import getLoadingIcon from '../loading/loading-icon'; import { INLINE_LOADING_STATE } from './defs'; import styles from './inline-loading.scss?lit'; @@ -60,7 +59,7 @@ class CDSInlineLoading extends LitElement { }); return html`
- ${getLoadingIcon({ assistiveText, type: LOADING_TYPE.SMALL })} + ${getLoadingIcon({ description: assistiveText, small: true })}
`; } diff --git a/packages/web-components/src/components/loading/loading-icon.ts b/packages/web-components/src/components/loading/loading-icon.ts index 5e95a4118ee5..b53e9a14fb13 100644 --- a/packages/web-components/src/components/loading/loading-icon.ts +++ b/packages/web-components/src/components/loading/loading-icon.ts @@ -9,7 +9,6 @@ import { html } from 'lit'; import { prefix } from '../../globals/settings'; -import LOADING_TYPE from './types'; /** * @param Object options The options. @@ -18,18 +17,18 @@ import LOADING_TYPE from './types'; * @returns The spinner icon. */ export default ({ - assistiveText, - type, + description, + small, }: { - assistiveText?: string; - type?: string; + description?: string; + small?: boolean; }) => { - const radius = type === LOADING_TYPE.SMALL ? '42' : '44'; + const radius = small ? '42' : '44'; return html` - ${!assistiveText ? undefined : html` ${assistiveText} `} + ${!description ? undefined : html` ${description} `} html` + render: ({ + active, + inactive, + assistiveText, + description, + type, + withOverlay, + small, + }) => html` `, }; diff --git a/packages/web-components/src/components/loading/loading.ts b/packages/web-components/src/components/loading/loading.ts index 7b44cf3d0cf1..d7f3212677f4 100644 --- a/packages/web-components/src/components/loading/loading.ts +++ b/packages/web-components/src/components/loading/loading.ts @@ -21,19 +21,40 @@ import { carbonElement as customElement } from '../../globals/decorators/carbon- * * @element cds-loading */ + @customElement(`${prefix}-loading`) class CDSLoading extends LitElement { /** - * The assistive text for the spinner icon. + * @deprecated The 'assistive-text' property will be deprecated in the next major release. Please use `description` instead. */ @property({ attribute: 'assistive-text' }) - assistiveText = 'Loading'; - + get assistiveText() { + return this.description; + } + set assistiveText(value) { + this.description = value; + } + /** + * Specify a description that would be used to best describe the loading state + */ + @property({ reflect: true }) + description = 'Loading'; /** - * Spinner type. + * + * @deprecated The 'type' property will be deprecated in the next major release. Please use `small` instead. */ @property() - type = LOADING_TYPE.REGULAR; + get type() { + return this.small ? LOADING_TYPE.SMALL : LOADING_TYPE.REGULAR; + } + set type(value) { + this.small = value == LOADING_TYPE.SMALL; + } + /** + * Specify whether you would like the small variant of + */ + @property({ type: Boolean, reflect: true }) + small = false; /** * `true` if overlay should be applied. @@ -44,17 +65,34 @@ class CDSLoading extends LitElement { /** * `true` if spinner should stop. */ + + /** + * + * @deprecated The 'inactive' property will be deprecated in the next major release. Please use `active` instead. + */ + @property({ type: Boolean, reflect: true }) + get inactive(): boolean { + return !this.active; + } + + set inactive(value: boolean) { + this.active = !value; + } + /** + * Specify whether you want the loading indicator to be spinning or not + */ @property({ type: Boolean, reflect: true }) - inactive = false; + active = false; render() { - const { inactive, assistiveText, type, overlay } = this; + const { active, description, small, overlay } = this; + const innerClasses = classMap({ [`${prefix}--loading`]: true, - [`${prefix}--loading--stop`]: inactive, - [`${prefix}--loading--small`]: type === LOADING_TYPE.SMALL, + [`${prefix}--loading--stop`]: !active, + [`${prefix}--loading--small`]: small, }); - const icon = getLoadingIcon({ assistiveText, type }); + const icon = getLoadingIcon({ description, small }); return overlay ? html`
${icon}
` : icon; }