@momentum-design/components 0.80.5 → 0.81.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/index.js +257 -220
- package/dist/browser/index.js.map +4 -4
- package/dist/components/skeleton/index.d.ts +7 -0
- package/dist/components/skeleton/index.js +4 -0
- package/dist/components/skeleton/skeleton.component.d.ts +46 -0
- package/dist/components/skeleton/skeleton.component.js +86 -0
- package/dist/components/skeleton/skeleton.constants.d.ts +11 -0
- package/dist/components/skeleton/skeleton.constants.js +12 -0
- package/dist/components/skeleton/skeleton.styles.d.ts +2 -0
- package/dist/components/skeleton/skeleton.styles.js +40 -0
- package/dist/components/skeleton/skeleton.types.d.ts +4 -0
- package/dist/components/skeleton/skeleton.types.js +1 -0
- package/dist/custom-elements.json +2401 -2319
- package/dist/index.d.ts +6 -3
- package/dist/index.js +4 -2
- package/dist/react/index.d.ts +5 -4
- package/dist/react/index.js +5 -4
- package/dist/react/skeleton/index.d.ts +25 -0
- package/dist/react/skeleton/index.js +34 -0
- package/package.json +1 -1
@@ -0,0 +1,46 @@
|
|
1
|
+
import type { PropertyValues } from 'lit';
|
2
|
+
import { CSSResult } from 'lit';
|
3
|
+
import { Component } from '../../models';
|
4
|
+
import type { SkeletonVariant } from './skeleton.types';
|
5
|
+
/**
|
6
|
+
* `mdc-skeleton` is a component that shows a grey placeholder area.
|
7
|
+
* It provides visual feedback to users that content is being loaded.
|
8
|
+
*
|
9
|
+
* **Skeleton Variants:**
|
10
|
+
* - **rectangular**: Default variant with 0.25rem border radius
|
11
|
+
* - **rounded**: Has 0.5rem border radius
|
12
|
+
* - **circular**: Has 50% border radius for circular shapes
|
13
|
+
* - **button**: Optimized for button placeholders with 1.25rem border radius
|
14
|
+
*
|
15
|
+
* **Sizing Behavior:**
|
16
|
+
* 1. If wrapping content, takes dimensions of wrapped content
|
17
|
+
* 2. Otherwise grows to fill parent container
|
18
|
+
*
|
19
|
+
* @tagname mdc-skeleton
|
20
|
+
*
|
21
|
+
* @slot - Content to wrap (optional). When provided, skeleton takes dimensions of this content.
|
22
|
+
*
|
23
|
+
* @cssproperty --mdc-skeleton-background-color - background color of the skeleton
|
24
|
+
* @cssproperty --mdc-skeleton-height - height of the skeleton
|
25
|
+
* @cssproperty --mdc-skeleton-width - width of the skeleton
|
26
|
+
*/
|
27
|
+
declare class Skeleton extends Component {
|
28
|
+
/**
|
29
|
+
* The variant of skeleton to display
|
30
|
+
* - **rectangular**: Default rectangular shape with 0.25rem border radius
|
31
|
+
* - **rounded**: Rounded rectangle with 0.5rem border radius
|
32
|
+
* - **circular**: Circular shape with 50% border radius
|
33
|
+
* - **button**: Button placeholder with 1.25rem border radius
|
34
|
+
* @default rectangular
|
35
|
+
*/
|
36
|
+
variant: SkeletonVariant;
|
37
|
+
/**
|
38
|
+
* Styles associated with this component.
|
39
|
+
*/
|
40
|
+
static styles: Array<CSSResult>;
|
41
|
+
connectedCallback(): void;
|
42
|
+
protected firstUpdated(changedProperties: PropertyValues): void;
|
43
|
+
private checkSlotContent;
|
44
|
+
protected render(): import("lit-html").TemplateResult<1>;
|
45
|
+
}
|
46
|
+
export default Skeleton;
|
@@ -0,0 +1,86 @@
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
6
|
+
};
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
9
|
+
};
|
10
|
+
import { html } from 'lit';
|
11
|
+
import { property } from 'lit/decorators.js';
|
12
|
+
import { Component } from '../../models';
|
13
|
+
import { DEFAULTS } from './skeleton.constants';
|
14
|
+
import styles from './skeleton.styles';
|
15
|
+
/**
|
16
|
+
* `mdc-skeleton` is a component that shows a grey placeholder area.
|
17
|
+
* It provides visual feedback to users that content is being loaded.
|
18
|
+
*
|
19
|
+
* **Skeleton Variants:**
|
20
|
+
* - **rectangular**: Default variant with 0.25rem border radius
|
21
|
+
* - **rounded**: Has 0.5rem border radius
|
22
|
+
* - **circular**: Has 50% border radius for circular shapes
|
23
|
+
* - **button**: Optimized for button placeholders with 1.25rem border radius
|
24
|
+
*
|
25
|
+
* **Sizing Behavior:**
|
26
|
+
* 1. If wrapping content, takes dimensions of wrapped content
|
27
|
+
* 2. Otherwise grows to fill parent container
|
28
|
+
*
|
29
|
+
* @tagname mdc-skeleton
|
30
|
+
*
|
31
|
+
* @slot - Content to wrap (optional). When provided, skeleton takes dimensions of this content.
|
32
|
+
*
|
33
|
+
* @cssproperty --mdc-skeleton-background-color - background color of the skeleton
|
34
|
+
* @cssproperty --mdc-skeleton-height - height of the skeleton
|
35
|
+
* @cssproperty --mdc-skeleton-width - width of the skeleton
|
36
|
+
*/
|
37
|
+
class Skeleton extends Component {
|
38
|
+
constructor() {
|
39
|
+
super(...arguments);
|
40
|
+
/**
|
41
|
+
* The variant of skeleton to display
|
42
|
+
* - **rectangular**: Default rectangular shape with 0.25rem border radius
|
43
|
+
* - **rounded**: Rounded rectangle with 0.5rem border radius
|
44
|
+
* - **circular**: Circular shape with 50% border radius
|
45
|
+
* - **button**: Button placeholder with 1.25rem border radius
|
46
|
+
* @default rectangular
|
47
|
+
*/
|
48
|
+
this.variant = DEFAULTS.VARIANT;
|
49
|
+
}
|
50
|
+
connectedCallback() {
|
51
|
+
super.connectedCallback();
|
52
|
+
this.setAttribute('aria-hidden', 'true');
|
53
|
+
}
|
54
|
+
firstUpdated(changedProperties) {
|
55
|
+
super.firstUpdated(changedProperties);
|
56
|
+
this.checkSlotContent();
|
57
|
+
}
|
58
|
+
checkSlotContent() {
|
59
|
+
var _a;
|
60
|
+
const slot = (_a = this.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('slot');
|
61
|
+
if (slot) {
|
62
|
+
const hasContent = slot.assignedNodes().length > 0;
|
63
|
+
if (hasContent) {
|
64
|
+
this.setAttribute('has-content', '');
|
65
|
+
}
|
66
|
+
else {
|
67
|
+
this.removeAttribute('has-content');
|
68
|
+
}
|
69
|
+
}
|
70
|
+
}
|
71
|
+
render() {
|
72
|
+
return html `<slot @slotchange=${this.checkSlotContent}></slot>`;
|
73
|
+
}
|
74
|
+
}
|
75
|
+
/**
|
76
|
+
* Styles associated with this component.
|
77
|
+
*/
|
78
|
+
Skeleton.styles = [
|
79
|
+
...Component.styles,
|
80
|
+
styles,
|
81
|
+
];
|
82
|
+
__decorate([
|
83
|
+
property({ type: String, reflect: true }),
|
84
|
+
__metadata("design:type", String)
|
85
|
+
], Skeleton.prototype, "variant", void 0);
|
86
|
+
export default Skeleton;
|
@@ -0,0 +1,11 @@
|
|
1
|
+
declare const TAG_NAME: "mdc-skeleton";
|
2
|
+
declare const SKELETON_VARIANTS: {
|
3
|
+
readonly BUTTON: "button";
|
4
|
+
readonly CIRCULAR: "circular";
|
5
|
+
readonly RECTANGULAR: "rectangular";
|
6
|
+
readonly ROUNDED: "rounded";
|
7
|
+
};
|
8
|
+
declare const DEFAULTS: {
|
9
|
+
VARIANT: "rectangular";
|
10
|
+
};
|
11
|
+
export { TAG_NAME, SKELETON_VARIANTS, DEFAULTS, };
|
@@ -0,0 +1,12 @@
|
|
1
|
+
import utils from '../../utils/tag-name';
|
2
|
+
const TAG_NAME = utils.constructTagName('skeleton');
|
3
|
+
const SKELETON_VARIANTS = {
|
4
|
+
BUTTON: 'button',
|
5
|
+
CIRCULAR: 'circular',
|
6
|
+
RECTANGULAR: 'rectangular',
|
7
|
+
ROUNDED: 'rounded',
|
8
|
+
};
|
9
|
+
const DEFAULTS = {
|
10
|
+
VARIANT: SKELETON_VARIANTS.RECTANGULAR,
|
11
|
+
};
|
12
|
+
export { TAG_NAME, SKELETON_VARIANTS, DEFAULTS, };
|
@@ -0,0 +1,40 @@
|
|
1
|
+
import { css } from 'lit';
|
2
|
+
const styles = css `
|
3
|
+
:host {
|
4
|
+
--mdc-skeleton-background-color: var(--mds-color-theme-background-skeleton-normal);
|
5
|
+
--mdc-skeleton-height: 100%;
|
6
|
+
--mdc-skeleton-width: 100%;
|
7
|
+
display: block;
|
8
|
+
overflow: hidden;
|
9
|
+
background-color: var(--mdc-skeleton-background-color);
|
10
|
+
height: var(--mdc-skeleton-height);
|
11
|
+
width: var(--mdc-skeleton-width);
|
12
|
+
}
|
13
|
+
|
14
|
+
:host([variant="rectangular"]) {
|
15
|
+
border-radius: 0.25rem;
|
16
|
+
}
|
17
|
+
|
18
|
+
:host([variant="rounded"]) {
|
19
|
+
border-radius: 0.5rem;
|
20
|
+
}
|
21
|
+
|
22
|
+
:host([variant="circular"]) {
|
23
|
+
border-radius: 50%;
|
24
|
+
}
|
25
|
+
|
26
|
+
:host([variant="button"]) {
|
27
|
+
border-radius: 1.25rem;
|
28
|
+
}
|
29
|
+
|
30
|
+
/* When there's slotted content, fit to content size */
|
31
|
+
:host([has-content]) {
|
32
|
+
width: fit-content;
|
33
|
+
height: fit-content;
|
34
|
+
}
|
35
|
+
|
36
|
+
::slotted(*) {
|
37
|
+
visibility: hidden;
|
38
|
+
}
|
39
|
+
`;
|
40
|
+
export default styles;
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|