@justeattakeaway/pie-skeleton 0.3.0 → 0.3.1

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.
@@ -405,6 +405,16 @@
405
405
  "description": "The inline styles applied to the root element.",
406
406
  "readonly": true
407
407
  },
408
+ {
409
+ "kind": "field",
410
+ "name": "_hostWidth",
411
+ "type": {
412
+ "text": "string | undefined"
413
+ },
414
+ "privacy": "private",
415
+ "description": "The width applied to the host element. Applying the width to the host (rather than the inner\nelement) means a percentage width resolves against the skeleton's container, exactly like a\nplain block element, even inside a flex container that does not stretch its items.",
416
+ "readonly": true
417
+ },
408
418
  {
409
419
  "kind": "method",
410
420
  "name": "_renderTextLines",
package/dist/index.d.ts CHANGED
@@ -90,6 +90,14 @@ export declare class PieSkeleton extends PieElement implements SkeletonProps {
90
90
  * @private
91
91
  */
92
92
  private get _rootStyles();
93
+ /**
94
+ * The width applied to the host element. Applying the width to the host (rather than the inner
95
+ * element) means a percentage width resolves against the skeleton's container, exactly like a
96
+ * plain block element, even inside a flex container that does not stretch its items.
97
+ *
98
+ * @private
99
+ */
100
+ private get _hostWidth();
93
101
  /**
94
102
  * Renders the text lines for the `text` variant. When there's more than one line,
95
103
  * the last line is drawn at half width (handled in CSS through the `is-last` class).
@@ -110,6 +118,7 @@ export declare class PieSkeleton extends PieElement implements SkeletonProps {
110
118
  * @private
111
119
  */
112
120
  private _renderShapes;
121
+ protected updated(): void;
113
122
  render(): TemplateResult<1>;
114
123
  static styles: CSSResult;
115
124
  }
package/dist/index.js CHANGED
@@ -7,7 +7,7 @@ const f = class f extends x {
7
7
  this.getAttribute("v") || this.setAttribute("v", f.v);
8
8
  }
9
9
  };
10
- f.v = "0.3.0";
10
+ f.v = "0.3.1";
11
11
  let v = f;
12
12
  const y = `@charset "UTF-8";*,*:after,*:before{box-sizing:inherit}@keyframes skeletonShimmer{0%{background-position:150% 0}83.333%{background-position:-50% 0}to{background-position:-50% 0}}:host{display:block;pointer-events:none}.c-skeleton{--skeleton-bg: var(--dt-color-skeleton-01);--skeleton-border-radius: var(--dt-radius-rounded-b);--skeleton-text-radius: var(--dt-radius-rounded-a);--skeleton-star-size: var(--dt-spacing-e);--skeleton-shimmer: var(--dt-color-skeleton-shimmer-01);--skeleton-shimmer-color: color-mix(in srgb, var(--skeleton-shimmer) 50%, transparent);--skeleton-shimmer-duration: 1.2s;--skeleton-shimmer-direction: normal;position:relative;overflow:hidden;width:100%}:host(:dir(rtl)) .c-skeleton{--skeleton-shimmer-direction: reverse}.c-skeleton--backgroundDefault{--skeleton-bg: var(--dt-color-skeleton-01);--skeleton-shimmer: var(--dt-color-skeleton-shimmer-01)}.c-skeleton--backgroundStrong{--skeleton-bg: var(--dt-color-skeleton-02);--skeleton-shimmer: var(--dt-color-skeleton-shimmer-02)}.c-skeleton--backgroundSubtle{--skeleton-bg: var(--dt-color-skeleton-03);--skeleton-shimmer: var(--dt-color-skeleton-shimmer-03)}.c-skeleton--box,.c-skeleton--circle,.c-skeleton--pill,.c-skeleton-star{background-attachment:fixed;background-color:var(--skeleton-bg);background-image:linear-gradient(135deg,transparent 40%,var(--skeleton-shimmer-color) 50%,transparent 60%);background-position:150% 0;background-repeat:no-repeat;background-size:200% 100%;animation:skeletonShimmer var(--skeleton-shimmer-duration) linear infinite;animation-direction:var(--skeleton-shimmer-direction)}.c-skeleton--box{border-radius:var(--skeleton-border-radius)}.c-skeleton--radius-rounded-none{--skeleton-border-radius: var(--dt-radius-rounded-none)}.c-skeleton--radius-rounded-a{--skeleton-border-radius: var(--dt-radius-rounded-a)}.c-skeleton--radius-rounded-b{--skeleton-border-radius: var(--dt-radius-rounded-b)}.c-skeleton--radius-rounded-c{--skeleton-border-radius: var(--dt-radius-rounded-c)}.c-skeleton--radius-rounded-d{--skeleton-border-radius: var(--dt-radius-rounded-d)}.c-skeleton--radius-rounded-e{--skeleton-border-radius: var(--dt-radius-rounded-e)}.c-skeleton--radius-rounded-f{--skeleton-border-radius: var(--dt-radius-rounded-f)}.c-skeleton--radius-rounded-g{--skeleton-border-radius: var(--dt-radius-rounded-g)}.c-skeleton--1by1{aspect-ratio:1/1}.c-skeleton--4by3{aspect-ratio:4/3}.c-skeleton--16by9{aspect-ratio:16/9}.c-skeleton--3by4{aspect-ratio:3/4}.c-skeleton--9by16{aspect-ratio:9/16}.c-skeleton--circle{border-radius:50%;aspect-ratio:1/1}.c-skeleton--pill{box-sizing:border-box;border-radius:var(--dt-radius-rounded-e)}.c-skeleton--button-xsmall{--btn-padding-vertical-xsmall: 6px;--btn-padding-vertical-small-expressive: 8px;--btn-padding-vertical-small-productive: 10px;--btn-padding-vertical-medium: 12px;--btn-padding-vertical-large: 16px;--btn-padding-horizontal-small: var(--dt-spacing-b);--btn-padding-horizontal-medium: var(--dt-spacing-d);--btn-padding-horizontal-large: var(--dt-spacing-e);--btn-font-size: calc(var(--dt-font-interactive-xs-size) * 1px);--btn-line-height: calc(var(--dt-font-interactive-xs-line-height) * 1px);--btn-icon-size: 16px;--icon-size-override: 16px;padding:var(--btn-padding-vertical-xsmall) var(--btn-padding-horizontal-small)}@media(min-width:769px){.c-skeleton--button-xsmall.c-skeleton--responsive{--btn-font-size: calc(var(--dt-font-interactive-s-size) * 1px);--btn-line-height: calc(var(--dt-font-interactive-s-line-height) * 1px);--btn-icon-size: 20px;--icon-size-override: 20px;padding:var(--btn-padding-vertical-small-productive) var(--btn-padding-horizontal-medium)}.c-skeleton--button-xsmall.c-skeleton--responsive.c-skeleton--expressive{--btn-font-size: calc(var(--dt-font-interactive-l-size) * 1px);--btn-line-height: calc(var(--dt-font-interactive-l-line-height) * 1px);--btn-icon-size: 20px;--icon-size-override: 20px;padding:var(--btn-padding-vertical-small-expressive) var(--btn-padding-horizontal-medium)}}.c-skeleton--button-xsmall.c-skeleton--outline,.c-skeleton--button-xsmall.c-skeleton--outline-inverse{padding:calc(var(--btn-padding-vertical-xsmall) - 1px) var(--btn-padding-horizontal-small)}@media(min-width:769px){.c-skeleton--button-xsmall.c-skeleton--outline.c-skeleton--responsive,.c-skeleton--button-xsmall.c-skeleton--outline-inverse.c-skeleton--responsive{padding:calc(var(--btn-padding-vertical-small-productive) - 1px) var(--btn-padding-horizontal-medium)}.c-skeleton--button-xsmall.c-skeleton--outline.c-skeleton--responsive.c-skeleton--expressive,.c-skeleton--button-xsmall.c-skeleton--outline-inverse.c-skeleton--responsive.c-skeleton--expressive{padding:calc(var(--btn-padding-vertical-small-expressive) - 1px) var(--btn-padding-horizontal-medium)}}.c-skeleton--button-xsmall{line-height:var(--btn-line-height)}.c-skeleton--button-xsmall:before{content:"​"}.c-skeleton--button-small-productive{--btn-padding-vertical-xsmall: 6px;--btn-padding-vertical-small-expressive: 8px;--btn-padding-vertical-small-productive: 10px;--btn-padding-vertical-medium: 12px;--btn-padding-vertical-large: 16px;--btn-padding-horizontal-small: var(--dt-spacing-b);--btn-padding-horizontal-medium: var(--dt-spacing-d);--btn-padding-horizontal-large: var(--dt-spacing-e);--btn-font-size: calc(var(--dt-font-interactive-s-size) * 1px);--btn-line-height: calc(var(--dt-font-interactive-s-line-height) * 1px);--btn-icon-size: 20px;--icon-size-override: 20px;padding:var(--btn-padding-vertical-small-productive) var(--btn-padding-horizontal-medium)}@media(min-width:769px){.c-skeleton--button-small-productive.c-skeleton--responsive{--btn-font-size: calc(var(--dt-font-interactive-l-size) * 1px);--btn-line-height: calc(var(--dt-font-interactive-l-line-height) * 1px);--btn-icon-size: 24px;--icon-size-override: 24px;padding:var(--btn-padding-vertical-medium) var(--btn-padding-horizontal-large)}}.c-skeleton--button-small-productive.c-skeleton--outline,.c-skeleton--button-small-productive.c-skeleton--outline-inverse{padding:calc(var(--btn-padding-vertical-small-productive) - 1px) var(--btn-padding-horizontal-medium)}@media(min-width:769px){.c-skeleton--button-small-productive.c-skeleton--outline.c-skeleton--responsive,.c-skeleton--button-small-productive.c-skeleton--outline-inverse.c-skeleton--responsive{padding:calc(var(--btn-padding-vertical-medium) - 1px) var(--btn-padding-horizontal-large)}}.c-skeleton--button-small-productive{line-height:var(--btn-line-height)}.c-skeleton--button-small-productive:before{content:"​"}.c-skeleton--button-small-expressive{--btn-padding-vertical-xsmall: 6px;--btn-padding-vertical-small-expressive: 8px;--btn-padding-vertical-small-productive: 10px;--btn-padding-vertical-medium: 12px;--btn-padding-vertical-large: 16px;--btn-padding-horizontal-small: var(--dt-spacing-b);--btn-padding-horizontal-medium: var(--dt-spacing-d);--btn-padding-horizontal-large: var(--dt-spacing-e);--btn-font-size: calc(var(--dt-font-interactive-l-size) * 1px);--btn-line-height: calc(var(--dt-font-interactive-l-line-height) * 1px);--btn-icon-size: 20px;--icon-size-override: 20px;padding:var(--btn-padding-vertical-small-expressive) var(--btn-padding-horizontal-medium)}@media(min-width:769px){.c-skeleton--button-small-expressive.c-skeleton--responsive{--btn-font-size: calc(var(--dt-font-interactive-l-size) * 1px);--btn-line-height: calc(var(--dt-font-interactive-l-line-height) * 1px);--btn-icon-size: 24px;--icon-size-override: 24px;padding:var(--btn-padding-vertical-medium) var(--btn-padding-horizontal-large)}}.c-skeleton--button-small-expressive.c-skeleton--outline,.c-skeleton--button-small-expressive.c-skeleton--outline-inverse{padding:calc(var(--btn-padding-vertical-small-expressive) - 1px) var(--btn-padding-horizontal-medium)}@media(min-width:769px){.c-skeleton--button-small-expressive.c-skeleton--outline.c-skeleton--responsive,.c-skeleton--button-small-expressive.c-skeleton--outline-inverse.c-skeleton--responsive{padding:calc(var(--btn-padding-vertical-medium) - 1px) var(--btn-padding-horizontal-large)}}.c-skeleton--button-small-expressive{line-height:var(--btn-line-height)}.c-skeleton--button-small-expressive:before{content:"​"}.c-skeleton--button-medium{--btn-padding-vertical-xsmall: 6px;--btn-padding-vertical-small-expressive: 8px;--btn-padding-vertical-small-productive: 10px;--btn-padding-vertical-medium: 12px;--btn-padding-vertical-large: 16px;--btn-padding-horizontal-small: var(--dt-spacing-b);--btn-padding-horizontal-medium: var(--dt-spacing-d);--btn-padding-horizontal-large: var(--dt-spacing-e);--btn-font-size: calc(var(--dt-font-interactive-l-size) * 1px);--btn-line-height: calc(var(--dt-font-interactive-l-line-height) * 1px);--btn-icon-size: 24px;--icon-size-override: 24px;padding:var(--btn-padding-vertical-medium) var(--btn-padding-horizontal-large)}@media(min-width:769px){.c-skeleton--button-medium.c-skeleton--responsive{--btn-font-size: calc(var(--dt-font-interactive-l-size) * 1px);--btn-line-height: calc(var(--dt-font-interactive-l-line-height) * 1px);--btn-icon-size: 24px;--icon-size-override: 24px;padding:var(--btn-padding-vertical-large) var(--btn-padding-horizontal-large)}}.c-skeleton--button-medium.c-skeleton--outline,.c-skeleton--button-medium.c-skeleton--outline-inverse{padding:calc(var(--btn-padding-vertical-medium) - 1px) var(--btn-padding-horizontal-large)}@media(min-width:769px){.c-skeleton--button-medium.c-skeleton--outline.c-skeleton--responsive,.c-skeleton--button-medium.c-skeleton--outline-inverse.c-skeleton--responsive{padding:calc(var(--btn-padding-vertical-large) - 1px) var(--btn-padding-horizontal-large)}}.c-skeleton--button-medium{line-height:var(--btn-line-height)}.c-skeleton--button-medium:before{content:"​"}.c-skeleton--button-large{--btn-padding-vertical-xsmall: 6px;--btn-padding-vertical-small-expressive: 8px;--btn-padding-vertical-small-productive: 10px;--btn-padding-vertical-medium: 12px;--btn-padding-vertical-large: 16px;--btn-padding-horizontal-small: var(--dt-spacing-b);--btn-padding-horizontal-medium: var(--dt-spacing-d);--btn-padding-horizontal-large: var(--dt-spacing-e);--btn-font-size: calc(var(--dt-font-interactive-l-size) * 1px);--btn-line-height: calc(var(--dt-font-interactive-l-line-height) * 1px);--btn-icon-size: 24px;--icon-size-override: 24px;padding:var(--btn-padding-vertical-large) var(--btn-padding-horizontal-large)}.c-skeleton--button-large.c-skeleton--outline,.c-skeleton--button-large.c-skeleton--outline-inverse{padding:calc(var(--btn-padding-vertical-large) - 1px) var(--btn-padding-horizontal-large)}.c-skeleton--button-large{line-height:var(--btn-line-height)}.c-skeleton--button-large:before{content:"​"}.c-skeleton-line{font-family:var(--dt-font-body-l-family),var(--dt-font-family-secondary),sans-serif;font-weight:var(--dt-font-body-l-weight);font-size:calc(var(--dt-font-body-l-size) * 1px);line-height:calc(var(--dt-font-body-l-line-height) * 1px);position:relative;border-radius:var(--skeleton-text-radius)}.c-skeleton-line:before{content:"​"}.c-skeleton-line:after{background-attachment:fixed;background-color:var(--skeleton-bg);background-image:linear-gradient(135deg,transparent 40%,var(--skeleton-shimmer-color) 50%,transparent 60%);background-position:150% 0;background-repeat:no-repeat;background-size:200% 100%;animation:skeletonShimmer var(--skeleton-shimmer-duration) linear infinite;animation-direction:var(--skeleton-shimmer-direction);content:"";position:absolute;inset-inline:0;inset-block-start:calc(50% - .5em);block-size:1em;border-radius:var(--skeleton-text-radius)}.c-skeleton-line.is-last:after{inset-inline-end:50%}.c-skeleton-line--font-heading-xs{font-family:var(--dt-font-heading-xs-family),var(--dt-font-family-secondary),sans-serif;font-weight:var(--dt-font-heading-xs-weight);font-size:calc(var(--dt-font-heading-xs-size--narrow) * 1px);line-height:calc(var(--dt-font-heading-xs-line-height--narrow) * 1px)}@media(min-width:768px){.c-skeleton-line--font-heading-xs{font-size:calc(var(--dt-font-heading-xs-size--wide) * 1px);line-height:calc(var(--dt-font-heading-xs-line-height--wide) * 1px)}}.c-skeleton-line--font-heading-s{font-family:var(--dt-font-heading-s-family),var(--dt-font-family-secondary),sans-serif;font-weight:var(--dt-font-heading-s-weight);font-size:calc(var(--dt-font-heading-s-size--narrow) * 1px);line-height:calc(var(--dt-font-heading-s-line-height--narrow) * 1px)}@media(min-width:768px){.c-skeleton-line--font-heading-s{font-size:calc(var(--dt-font-heading-s-size--wide) * 1px);line-height:calc(var(--dt-font-heading-s-line-height--wide) * 1px)}}.c-skeleton-line--font-heading-m{font-family:var(--dt-font-heading-m-family),var(--dt-font-family-secondary),sans-serif;font-weight:var(--dt-font-heading-m-weight);font-size:calc(var(--dt-font-heading-m-size--narrow) * 1px);line-height:calc(var(--dt-font-heading-m-line-height--narrow) * 1px)}@media(min-width:768px){.c-skeleton-line--font-heading-m{font-size:calc(var(--dt-font-heading-m-size--wide) * 1px);line-height:calc(var(--dt-font-heading-m-line-height--wide) * 1px)}}.c-skeleton-line--font-heading-l{font-family:var(--dt-font-heading-l-family),var(--dt-font-family-secondary),sans-serif;font-weight:var(--dt-font-heading-l-weight);font-size:calc(var(--dt-font-heading-l-size--narrow) * 1px);line-height:calc(var(--dt-font-heading-l-line-height--narrow) * 1px)}@media(min-width:768px){.c-skeleton-line--font-heading-l{font-size:calc(var(--dt-font-heading-l-size--wide) * 1px);line-height:calc(var(--dt-font-heading-l-line-height--wide) * 1px)}}.c-skeleton-line--font-heading-xl{font-family:var(--dt-font-heading-xl-family),var(--dt-font-family-secondary),sans-serif;font-weight:var(--dt-font-heading-xl-weight);font-size:calc(var(--dt-font-heading-xl-size--narrow) * 1px);line-height:calc(var(--dt-font-heading-xl-line-height--narrow) * 1px)}@media(min-width:768px){.c-skeleton-line--font-heading-xl{font-size:calc(var(--dt-font-heading-xl-size--wide) * 1px);line-height:calc(var(--dt-font-heading-xl-line-height--wide) * 1px)}}.c-skeleton-line--font-heading-xxl{font-family:var(--dt-font-heading-xxl-family),var(--dt-font-family-secondary),sans-serif;font-weight:var(--dt-font-heading-xxl-weight);font-size:calc(var(--dt-font-heading-xxl-size--narrow) * 1px);line-height:calc(var(--dt-font-heading-xxl-line-height--narrow) * 1px)}@media(min-width:768px){.c-skeleton-line--font-heading-xxl{font-size:calc(var(--dt-font-heading-xxl-size--wide) * 1px);line-height:calc(var(--dt-font-heading-xxl-line-height--wide) * 1px)}}.c-skeleton-line--font-heading-xs-italic{font-family:var(--dt-font-heading-xs-italic-family),var(--dt-font-family-secondary),sans-serif;font-weight:var(--dt-font-heading-xs-italic-weight);font-style:var(--dt-font-heading-xs-italic-font-style);font-variation-settings:"slnt" -20;font-size:calc(var(--dt-font-heading-xs-italic-size--narrow) * 1px);line-height:calc(var(--dt-font-heading-xs-italic-line-height--narrow) * 1px)}@media(min-width:768px){.c-skeleton-line--font-heading-xs-italic{font-size:calc(var(--dt-font-heading-xs-italic-size--wide) * 1px);line-height:calc(var(--dt-font-heading-xs-italic-line-height--wide) * 1px)}}.c-skeleton-line--font-heading-s-italic{font-family:var(--dt-font-heading-s-italic-family),var(--dt-font-family-secondary),sans-serif;font-weight:var(--dt-font-heading-s-italic-weight);font-style:var(--dt-font-heading-s-italic-font-style);font-variation-settings:"slnt" -20;font-size:calc(var(--dt-font-heading-s-italic-size--narrow) * 1px);line-height:calc(var(--dt-font-heading-s-italic-line-height--narrow) * 1px)}@media(min-width:768px){.c-skeleton-line--font-heading-s-italic{font-size:calc(var(--dt-font-heading-s-italic-size--wide) * 1px);line-height:calc(var(--dt-font-heading-s-italic-line-height--wide) * 1px)}}.c-skeleton-line--font-heading-m-italic{font-family:var(--dt-font-heading-m-italic-family),var(--dt-font-family-secondary),sans-serif;font-weight:var(--dt-font-heading-m-italic-weight);font-style:var(--dt-font-heading-m-italic-font-style);font-variation-settings:"slnt" -20;font-size:calc(var(--dt-font-heading-m-italic-size--narrow) * 1px);line-height:calc(var(--dt-font-heading-m-italic-line-height--narrow) * 1px)}@media(min-width:768px){.c-skeleton-line--font-heading-m-italic{font-size:calc(var(--dt-font-heading-m-italic-size--wide) * 1px);line-height:calc(var(--dt-font-heading-m-italic-line-height--wide) * 1px)}}.c-skeleton-line--font-heading-l-italic{font-family:var(--dt-font-heading-l-italic-family),var(--dt-font-family-secondary),sans-serif;font-weight:var(--dt-font-heading-l-italic-weight);font-style:var(--dt-font-heading-l-italic-font-style);font-variation-settings:"slnt" -20;font-size:calc(var(--dt-font-heading-l-italic-size--narrow) * 1px);line-height:calc(var(--dt-font-heading-l-italic-line-height--narrow) * 1px)}@media(min-width:768px){.c-skeleton-line--font-heading-l-italic{font-size:calc(var(--dt-font-heading-l-italic-size--wide) * 1px);line-height:calc(var(--dt-font-heading-l-italic-line-height--wide) * 1px)}}.c-skeleton-line--font-heading-xl-italic{font-family:var(--dt-font-heading-xl-italic-family),var(--dt-font-family-secondary),sans-serif;font-weight:var(--dt-font-heading-xl-italic-weight);font-style:var(--dt-font-heading-xl-italic-font-style);font-variation-settings:"slnt" -20;font-size:calc(var(--dt-font-heading-xl-italic-size--narrow) * 1px);line-height:calc(var(--dt-font-heading-xl-italic-line-height--narrow) * 1px)}@media(min-width:768px){.c-skeleton-line--font-heading-xl-italic{font-size:calc(var(--dt-font-heading-xl-italic-size--wide) * 1px);line-height:calc(var(--dt-font-heading-xl-italic-line-height--wide) * 1px)}}.c-skeleton-line--font-heading-xxl-italic{font-family:var(--dt-font-heading-xxl-italic-family),var(--dt-font-family-secondary),sans-serif;font-weight:var(--dt-font-heading-xxl-italic-weight);font-style:var(--dt-font-heading-xxl-italic-font-style);font-variation-settings:"slnt" -20;font-size:calc(var(--dt-font-heading-xxl-italic-size--narrow) * 1px);line-height:calc(var(--dt-font-heading-xxl-italic-line-height--narrow) * 1px)}@media(min-width:768px){.c-skeleton-line--font-heading-xxl-italic{font-size:calc(var(--dt-font-heading-xxl-italic-size--wide) * 1px);line-height:calc(var(--dt-font-heading-xxl-italic-line-height--wide) * 1px)}}.c-skeleton-line--font-subheading-s{font-family:var(--dt-font-subheading-s-family),var(--dt-font-family-secondary),sans-serif;font-weight:var(--dt-font-subheading-s-weight);font-size:calc(var(--dt-font-subheading-s-size--narrow) * 1px);line-height:calc(var(--dt-font-subheading-s-line-height--narrow) * 1px)}@media(min-width:768px){.c-skeleton-line--font-subheading-s{font-size:calc(var(--dt-font-subheading-s-size--wide) * 1px);line-height:calc(var(--dt-font-subheading-s-line-height--wide) * 1px)}}.c-skeleton-line--font-subheading-l{font-family:var(--dt-font-subheading-l-family),var(--dt-font-family-secondary),sans-serif;font-weight:var(--dt-font-subheading-l-weight);font-size:calc(var(--dt-font-subheading-l-size--narrow) * 1px);line-height:calc(var(--dt-font-subheading-l-line-height--narrow) * 1px)}@media(min-width:768px){.c-skeleton-line--font-subheading-l{font-size:calc(var(--dt-font-subheading-l-size--wide) * 1px);line-height:calc(var(--dt-font-subheading-l-line-height--wide) * 1px)}}.c-skeleton-line--font-interactive-xs{font-family:var(--dt-font-interactive-xs-family),var(--dt-font-family-secondary),sans-serif;font-weight:var(--dt-font-interactive-xs-weight);font-size:calc(var(--dt-font-interactive-xs-size) * 1px);line-height:calc(var(--dt-font-interactive-xs-line-height) * 1px)}.c-skeleton-line--font-interactive-s{font-family:var(--dt-font-interactive-s-family),var(--dt-font-family-secondary),sans-serif;font-weight:var(--dt-font-interactive-s-weight);font-size:calc(var(--dt-font-interactive-s-size) * 1px);line-height:calc(var(--dt-font-interactive-s-line-height) * 1px)}.c-skeleton-line--font-interactive-l{font-family:var(--dt-font-interactive-l-family),var(--dt-font-family-secondary),sans-serif;font-weight:var(--dt-font-interactive-l-weight);font-size:calc(var(--dt-font-interactive-l-size) * 1px);line-height:calc(var(--dt-font-interactive-l-line-height) * 1px)}.c-skeleton-line--font-body-s{font-family:var(--dt-font-body-s-family),var(--dt-font-family-secondary),sans-serif;font-weight:var(--dt-font-body-s-weight);font-size:calc(var(--dt-font-body-s-size) * 1px);line-height:calc(var(--dt-font-body-s-line-height) * 1px)}.c-skeleton-line--font-body-s-link{font-family:var(--dt-font-body-s-link-family),var(--dt-font-family-secondary),sans-serif;font-weight:var(--dt-font-body-s-link-weight);text-decoration:var(--dt-font-body-s-link-text-decoration);font-size:calc(var(--dt-font-body-s-link-size) * 1px);line-height:calc(var(--dt-font-body-s-link-line-height) * 1px)}.c-skeleton-line--font-body-l{font-family:var(--dt-font-body-l-family),var(--dt-font-family-secondary),sans-serif;font-weight:var(--dt-font-body-l-weight);font-size:calc(var(--dt-font-body-l-size) * 1px);line-height:calc(var(--dt-font-body-l-line-height) * 1px)}.c-skeleton-line--font-body-l-link{font-family:var(--dt-font-body-l-link-family),var(--dt-font-family-secondary),sans-serif;font-weight:var(--dt-font-body-l-link-weight);text-decoration:var(--dt-font-body-l-link-text-decoration);font-size:calc(var(--dt-font-body-l-link-size) * 1px);line-height:calc(var(--dt-font-body-l-link-line-height) * 1px)}.c-skeleton-line--font-body-strong-s{font-family:var(--dt-font-body-strong-s-family),var(--dt-font-family-secondary),sans-serif;font-weight:var(--dt-font-body-strong-s-weight);font-size:calc(var(--dt-font-body-strong-s-size) * 1px);line-height:calc(var(--dt-font-body-strong-s-line-height) * 1px)}.c-skeleton-line--font-body-strong-s-link{font-family:var(--dt-font-body-strong-s-link-family),var(--dt-font-family-secondary),sans-serif;font-weight:var(--dt-font-body-strong-s-link-weight);text-decoration:var(--dt-font-body-strong-s-link-text-decoration);font-size:calc(var(--dt-font-body-strong-s-link-size) * 1px);line-height:calc(var(--dt-font-body-strong-s-link-line-height) * 1px)}.c-skeleton-line--font-body-strong-l{font-family:var(--dt-font-body-strong-l-family),var(--dt-font-family-secondary),sans-serif;font-weight:var(--dt-font-body-strong-l-weight);font-size:calc(var(--dt-font-body-strong-l-size) * 1px);line-height:calc(var(--dt-font-body-strong-l-line-height) * 1px)}.c-skeleton-line--font-body-strong-l-link{font-family:var(--dt-font-body-strong-l-link-family),var(--dt-font-family-secondary),sans-serif;font-weight:var(--dt-font-body-strong-l-link-weight);text-decoration:var(--dt-font-body-strong-l-link-text-decoration);font-size:calc(var(--dt-font-body-strong-l-link-size) * 1px);line-height:calc(var(--dt-font-body-strong-l-link-line-height) * 1px)}.c-skeleton-line--font-caption{font-family:var(--dt-font-caption-family),var(--dt-font-family-secondary),sans-serif;font-weight:var(--dt-font-caption-weight);font-size:calc(var(--dt-font-caption-size) * 1px);line-height:calc(var(--dt-font-caption-line-height) * 1px)}.c-skeleton-line--font-caption-link{font-family:var(--dt-font-caption-link-family),var(--dt-font-family-secondary),sans-serif;font-weight:var(--dt-font-caption-link-weight);text-decoration:var(--dt-font-caption-link-text-decoration);font-size:calc(var(--dt-font-caption-link-size) * 1px);line-height:calc(var(--dt-font-caption-link-line-height) * 1px)}.c-skeleton-line--font-caption-strong{font-family:var(--dt-font-caption-strong-family),var(--dt-font-family-secondary),sans-serif;font-weight:var(--dt-font-caption-strong-weight);font-size:calc(var(--dt-font-caption-strong-size) * 1px);line-height:calc(var(--dt-font-caption-strong-line-height) * 1px)}.c-skeleton-line--font-caption-strong-italic{font-family:var(--dt-font-caption-strong-italic-family),var(--dt-font-family-secondary),sans-serif;font-weight:var(--dt-font-caption-strong-italic-weight);font-style:var(--dt-font-caption-strong-italic-font-style);font-variation-settings:"slnt" -20;font-size:calc(var(--dt-font-caption-strong-italic-size) * 1px);line-height:calc(var(--dt-font-caption-strong-italic-line-height) * 1px)}.c-skeleton-line--font-caption-strong-link{font-family:var(--dt-font-caption-strong-link-family),var(--dt-font-family-secondary),sans-serif;font-weight:var(--dt-font-caption-strong-link-weight);text-decoration:var(--dt-font-caption-strong-link-text-decoration);font-size:calc(var(--dt-font-caption-strong-link-size) * 1px);line-height:calc(var(--dt-font-caption-strong-link-line-height) * 1px)}.c-skeleton-line--font-display-xl{font-family:var(--dt-font-display-xl-family),var(--dt-font-family-secondary),sans-serif;font-weight:var(--dt-font-display-xl-weight);font-style:var(--dt-font-display-xl-font-style);font-variation-settings:"slnt" -20;font-size:calc(var(--dt-font-display-xl-size--narrow) * 1px);line-height:calc(var(--dt-font-display-xl-line-height--narrow) * 1px)}@media(min-width:768px){.c-skeleton-line--font-display-xl{font-size:calc(var(--dt-font-display-xl-size--wide) * 1px);line-height:calc(var(--dt-font-display-xl-line-height--wide) * 1px)}}.c-skeleton-line--font-display-l{font-family:var(--dt-font-display-l-family),var(--dt-font-family-secondary),sans-serif;font-weight:var(--dt-font-display-l-weight);font-style:var(--dt-font-display-l-font-style);font-variation-settings:"slnt" -20;font-size:calc(var(--dt-font-display-l-size--narrow) * 1px);line-height:calc(var(--dt-font-display-l-line-height--narrow) * 1px)}@media(min-width:768px){.c-skeleton-line--font-display-l{font-size:calc(var(--dt-font-display-l-size--wide) * 1px);line-height:calc(var(--dt-font-display-l-line-height--wide) * 1px)}}.c-skeleton-line--font-display-m{font-family:var(--dt-font-display-m-family),var(--dt-font-family-secondary),sans-serif;font-weight:var(--dt-font-display-m-weight);font-style:var(--dt-font-display-m-font-style);font-variation-settings:"slnt" -20;font-size:calc(var(--dt-font-display-m-size--narrow) * 1px);line-height:calc(var(--dt-font-display-m-line-height--narrow) * 1px)}@media(min-width:768px){.c-skeleton-line--font-display-m{font-size:calc(var(--dt-font-display-m-size--wide) * 1px);line-height:calc(var(--dt-font-display-m-line-height--wide) * 1px)}}.c-skeleton-line--font-display-s{font-family:var(--dt-font-display-s-family),var(--dt-font-family-secondary),sans-serif;font-weight:var(--dt-font-display-s-weight);font-style:var(--dt-font-display-s-font-style);font-variation-settings:"slnt" -20;font-size:calc(var(--dt-font-display-s-size--narrow) * 1px);line-height:calc(var(--dt-font-display-s-line-height--narrow) * 1px)}@media(min-width:768px){.c-skeleton-line--font-display-s{font-size:calc(var(--dt-font-display-s-size--wide) * 1px);line-height:calc(var(--dt-font-display-s-line-height--wide) * 1px)}}.c-skeleton-line--font-display-xs{font-family:var(--dt-font-display-xs-family),var(--dt-font-family-secondary),sans-serif;font-weight:var(--dt-font-display-xs-weight);font-style:var(--dt-font-display-xs-font-style);font-variation-settings:"slnt" -20;font-size:calc(var(--dt-font-display-xs-size--narrow) * 1px);line-height:calc(var(--dt-font-display-xs-line-height--narrow) * 1px)}@media(min-width:768px){.c-skeleton-line--font-display-xs{font-size:calc(var(--dt-font-display-xs-size--wide) * 1px);line-height:calc(var(--dt-font-display-xs-line-height--wide) * 1px)}}.c-skeleton--star{display:flex;gap:0;width:fit-content}.c-skeleton-star{flex:0 0 auto;inline-size:var(--skeleton-star-size);block-size:var(--skeleton-star-size);-webkit-mask-image:url("data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2016%2016'%3E%3Cpath%20d='m12.288%2014.449-4.183-2.197a.22.22%200%200%200-.21%200L3.713%2014.45%204.5%209.794a.25.25%200%200%200%200-.193L1.07%206.302l4.673-.682a.23.23%200%200%200%20.166-.114L8%201.271l2.091%204.235a.23.23%200%200%200%20.167.114l4.672.682-3.386%203.3a.25.25%200%200%200-.061.192z'/%3E%3C/svg%3E");mask-image:url("data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2016%2016'%3E%3Cpath%20d='m12.288%2014.449-4.183-2.197a.22.22%200%200%200-.21%200L3.713%2014.45%204.5%209.794a.25.25%200%200%200%200-.193L1.07%206.302l4.673-.682a.23.23%200%200%200%20.166-.114L8%201.271l2.091%204.235a.23.23%200%200%200%20.167.114l4.672.682-3.386%203.3a.25.25%200%200%200-.061.192z'/%3E%3C/svg%3E");-webkit-mask-position:center;mask-position:center;-webkit-mask-repeat:no-repeat;mask-repeat:no-repeat;-webkit-mask-size:contain;mask-size:contain}@media(prefers-reduced-motion:reduce){.c-skeleton--box,.c-skeleton--circle,.c-skeleton--pill,.c-skeleton-star,.c-skeleton-line:after{background-image:none;animation:none}}@media(forced-colors:active){.c-skeleton{--skeleton-bg: CanvasText}.c-skeleton--box,.c-skeleton--circle,.c-skeleton--pill,.c-skeleton-star,.c-skeleton-line:after{background-image:none;animation:none}}`, z = ["box", "circle", "pill", "text", "star"], w = ["default", "strong", "subtle"], _ = {
13
13
  default: "c-skeleton--backgroundDefault",
@@ -50,13 +50,13 @@ const y = `@charset "UTF-8";*,*:after,*:before{box-sizing:inherit}@keyframes ske
50
50
  aspectRatio: "1by1",
51
51
  isResponsive: !1
52
52
  };
53
- var M = Object.defineProperty, I = Object.getOwnPropertyDescriptor, r = (t, n, i, e) => {
54
- for (var o = e > 1 ? void 0 : e ? I(n, i) : n, c = t.length - 1, s; c >= 0; c--)
55
- (s = t[c]) && (o = (e ? s(n, i, o) : s(o)) || o);
56
- return e && o && M(n, i, o), o;
53
+ var M = Object.defineProperty, I = Object.getOwnPropertyDescriptor, r = (t, e, n, a) => {
54
+ for (var o = a > 1 ? void 0 : a ? I(e, n) : e, c = t.length - 1, s; c >= 0; c--)
55
+ (s = t[c]) && (o = (a ? s(e, n, o) : s(o)) || o);
56
+ return a && o && M(e, n, o), o;
57
57
  };
58
58
  const g = "pie-skeleton", T = /^\d*\.?\d+(px|rem|em|%|vh|vw)$/;
59
- let a = class extends v {
59
+ let i = class extends v {
60
60
  constructor() {
61
61
  super(...arguments), this.variant = l.variant, this.backgroundColor = l.backgroundColor, this.lines = l.lines, this.stars = l.stars, this.borderRadius = l.borderRadius, this.aspectRatio = l.aspectRatio, this.isResponsive = l.isResponsive;
62
62
  }
@@ -65,9 +65,9 @@ let a = class extends v {
65
65
  *
66
66
  * @private
67
67
  */
68
- _clamp(t, n, i) {
69
- const e = Math.trunc(Number(t));
70
- return Number.isFinite(e) ? Math.min(Math.max(e, n), i) : n;
68
+ _clamp(t, e, n) {
69
+ const a = Math.trunc(Number(t));
70
+ return Number.isFinite(a) ? Math.min(Math.max(a, e), n) : e;
71
71
  }
72
72
  /**
73
73
  * The number of text lines to draw, clamped between 1 and 10.
@@ -110,10 +110,10 @@ let a = class extends v {
110
110
  * @private
111
111
  */
112
112
  _resolveHeight() {
113
- const { height: t, variant: n } = this;
113
+ const { height: t, variant: e } = this;
114
114
  if (t) {
115
115
  if (this._isSpacingIdentifier(t)) return `var(--dt-${t})`;
116
- if (!(n === "pill" && this._isButtonSize(t)) && !(n === "star" && t.endsWith("%")))
116
+ if (!(e === "pill" && this._isButtonSize(t)) && !(e === "star" && t.endsWith("%")))
117
117
  return T.test(t) ? t : void 0;
118
118
  }
119
119
  }
@@ -125,17 +125,17 @@ let a = class extends v {
125
125
  get _rootClasses() {
126
126
  const {
127
127
  variant: t,
128
- backgroundColor: n,
129
- borderRadius: i,
130
- aspectRatio: e,
128
+ backgroundColor: e,
129
+ borderRadius: n,
130
+ aspectRatio: a,
131
131
  isResponsive: o,
132
132
  height: c
133
133
  } = this, s = {
134
134
  "c-skeleton": !0,
135
135
  [`c-skeleton--${t}`]: !0,
136
- [_[n]]: !0
136
+ [_[e]]: !0
137
137
  };
138
- return t === "box" && (s[`c-skeleton--${i}`] = !0, s[`c-skeleton--${e}`] = !0), t === "pill" && (this._isButtonSize(c) ? s[`c-skeleton--${c}`] = !0 : this._resolveHeight() || (s["c-skeleton--button-medium"] = !0), s["c-skeleton--responsive"] = o), s;
138
+ return t === "box" && (s[`c-skeleton--${n}`] = !0, s[`c-skeleton--${a}`] = !0), t === "pill" && (this._isButtonSize(c) ? s[`c-skeleton--${c}`] = !0 : this._resolveHeight() || (s["c-skeleton--button-medium"] = !0), s["c-skeleton--responsive"] = o), s;
139
139
  }
140
140
  /**
141
141
  * The inline styles applied to the root element.
@@ -143,19 +143,31 @@ let a = class extends v {
143
143
  * @private
144
144
  */
145
145
  get _rootStyles() {
146
- const { variant: t, width: n } = this, i = [];
147
- if (n && t !== "circle" && t !== "star" && i.push(`width: ${n}`), t === "circle") {
148
- const e = this._resolveHeight();
149
- e && i.push(`width: ${e}`, `height: ${e}`);
146
+ const { variant: t } = this, e = [];
147
+ if (t === "circle") {
148
+ const n = this._resolveHeight();
149
+ n && e.push(`width: ${n}`, `height: ${n}`);
150
150
  } else if (t === "box" || t === "pill") {
151
- const e = this._resolveHeight();
152
- e && i.push(`height: ${e}`);
151
+ const n = this._resolveHeight();
152
+ n && e.push(`height: ${n}`);
153
153
  }
154
154
  if (t === "star") {
155
- const e = this._resolveHeight();
156
- e && i.push(`--skeleton-star-size: ${e}`);
155
+ const n = this._resolveHeight();
156
+ n && e.push(`--skeleton-star-size: ${n}`);
157
157
  }
158
- return i.join("; ");
158
+ return e.join("; ");
159
+ }
160
+ /**
161
+ * The width applied to the host element. Applying the width to the host (rather than the inner
162
+ * element) means a percentage width resolves against the skeleton's container, exactly like a
163
+ * plain block element, even inside a flex container that does not stretch its items.
164
+ *
165
+ * @private
166
+ */
167
+ get _hostWidth() {
168
+ const { variant: t, width: e } = this;
169
+ if (!(t === "circle" || t === "star"))
170
+ return e || "100%";
159
171
  }
160
172
  /**
161
173
  * Renders the text lines for the `text` variant. When there's more than one line,
@@ -164,12 +176,12 @@ let a = class extends v {
164
176
  * @private
165
177
  */
166
178
  _renderTextLines() {
167
- const t = this._linesCount, { height: n } = this;
168
- return Array.from({ length: t }, (i, e) => {
169
- const o = t > 1 && e === t - 1, c = m({
179
+ const t = this._linesCount, { height: e } = this;
180
+ return Array.from({ length: t }, (n, a) => {
181
+ const o = t > 1 && a === t - 1, c = m({
170
182
  "c-skeleton-line": !0,
171
183
  "is-last": o,
172
- [`c-skeleton-line--${n}`]: !!n
184
+ [`c-skeleton-line--${e}`]: !!e
173
185
  });
174
186
  return p`<div class="${c}"></div>`;
175
187
  });
@@ -191,6 +203,10 @@ let a = class extends v {
191
203
  _renderShapes() {
192
204
  return this.variant === "text" ? this._renderTextLines() : this.variant === "star" ? this._renderStars() : u;
193
205
  }
206
+ updated() {
207
+ const t = this._hostWidth;
208
+ t ? this.style.width = t : this.style.removeProperty("width");
209
+ }
194
210
  render() {
195
211
  return p`
196
212
  <div
@@ -203,45 +219,45 @@ let a = class extends v {
203
219
  `;
204
220
  }
205
221
  };
206
- a.styles = b(y);
222
+ i.styles = b(y);
207
223
  r([
208
224
  d({ type: String }),
209
225
  h(g, z, l.variant)
210
- ], a.prototype, "variant", 2);
226
+ ], i.prototype, "variant", 2);
211
227
  r([
212
228
  d({ type: String }),
213
229
  h(g, w, l.backgroundColor)
214
- ], a.prototype, "backgroundColor", 2);
230
+ ], i.prototype, "backgroundColor", 2);
215
231
  r([
216
232
  d({ type: String })
217
- ], a.prototype, "width", 2);
233
+ ], i.prototype, "width", 2);
218
234
  r([
219
235
  d({ type: String })
220
- ], a.prototype, "height", 2);
236
+ ], i.prototype, "height", 2);
221
237
  r([
222
238
  d({ type: Number })
223
- ], a.prototype, "lines", 2);
239
+ ], i.prototype, "lines", 2);
224
240
  r([
225
241
  d({ type: Number })
226
- ], a.prototype, "stars", 2);
242
+ ], i.prototype, "stars", 2);
227
243
  r([
228
244
  d({ type: String }),
229
245
  h(g, C, l.borderRadius)
230
- ], a.prototype, "borderRadius", 2);
246
+ ], i.prototype, "borderRadius", 2);
231
247
  r([
232
248
  d({ type: String }),
233
249
  h(g, S, l.aspectRatio)
234
- ], a.prototype, "aspectRatio", 2);
250
+ ], i.prototype, "aspectRatio", 2);
235
251
  r([
236
252
  d({ type: Boolean })
237
- ], a.prototype, "isResponsive", 2);
238
- a = r([
253
+ ], i.prototype, "isResponsive", 2);
254
+ i = r([
239
255
  k("pie-skeleton")
240
- ], a);
256
+ ], i);
241
257
  export {
242
258
  E as LINES_MAX,
243
259
  L as LINES_MIN,
244
- a as PieSkeleton,
260
+ i as PieSkeleton,
245
261
  A as STARS_MAX,
246
262
  N as STARS_MIN,
247
263
  S as aspectRatios,
package/dist/react.d.ts CHANGED
@@ -93,6 +93,14 @@ declare class PieSkeleton_2 extends PieElement implements SkeletonProps {
93
93
  * @private
94
94
  */
95
95
  private get _rootStyles();
96
+ /**
97
+ * The width applied to the host element. Applying the width to the host (rather than the inner
98
+ * element) means a percentage width resolves against the skeleton's container, exactly like a
99
+ * plain block element, even inside a flex container that does not stretch its items.
100
+ *
101
+ * @private
102
+ */
103
+ private get _hostWidth();
96
104
  /**
97
105
  * Renders the text lines for the `text` variant. When there's more than one line,
98
106
  * the last line is drawn at half width (handled in CSS through the `is-last` class).
@@ -113,6 +121,7 @@ declare class PieSkeleton_2 extends PieElement implements SkeletonProps {
113
121
  * @private
114
122
  */
115
123
  private _renderShapes;
124
+ protected updated(): void;
116
125
  render(): TemplateResult<1>;
117
126
  static styles: CSSResult;
118
127
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@justeattakeaway/pie-skeleton",
3
3
  "description": "PIE Design System Skeleton built using Web Components",
4
- "version": "0.3.0",
4
+ "version": "0.3.1",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",
package/src/index.ts CHANGED
@@ -177,14 +177,9 @@ export class PieSkeleton extends PieElement implements SkeletonProps {
177
177
  * @private
178
178
  */
179
179
  private get _rootStyles (): string {
180
- const { variant, width } = this;
180
+ const { variant } = this;
181
181
  const styles: string[] = [];
182
182
 
183
- // `width` is ignored by the circle and star variants.
184
- if (width && variant !== 'circle' && variant !== 'star') {
185
- styles.push(`width: ${width}`);
186
- }
187
-
188
183
  if (variant === 'circle') {
189
184
  // A circle is sized by its height; width follows so it stays 1:1.
190
185
  const height = this._resolveHeight();
@@ -205,6 +200,20 @@ export class PieSkeleton extends PieElement implements SkeletonProps {
205
200
  return styles.join('; ');
206
201
  }
207
202
 
203
+ /**
204
+ * The width applied to the host element. Applying the width to the host (rather than the inner
205
+ * element) means a percentage width resolves against the skeleton's container, exactly like a
206
+ * plain block element, even inside a flex container that does not stretch its items.
207
+ *
208
+ * @private
209
+ */
210
+ private get _hostWidth (): string | undefined {
211
+ const { variant, width } = this;
212
+ // `width` is ignored by the circle and star variants.
213
+ if (variant === 'circle' || variant === 'star') return undefined;
214
+ return width || '100%';
215
+ }
216
+
208
217
  /**
209
218
  * Renders the text lines for the `text` variant. When there's more than one line,
210
219
  * the last line is drawn at half width (handled in CSS through the `is-last` class).
@@ -249,6 +258,16 @@ export class PieSkeleton extends PieElement implements SkeletonProps {
249
258
  return nothing;
250
259
  }
251
260
 
261
+ protected updated (): void {
262
+ const hostWidth = this._hostWidth;
263
+
264
+ if (hostWidth) {
265
+ this.style.width = hostWidth;
266
+ } else {
267
+ this.style.removeProperty('width');
268
+ }
269
+ }
270
+
252
271
  render () {
253
272
  return html`
254
273
  <div