Skip to content

Commit fe956bb

Browse files
committed
Merge remote-tracking branch 'origin/main' into fix/2014-tabs-weird-behavior-in-safari-ff
2 parents cdc307c + be15fea commit fe956bb

File tree

14 files changed

+74
-66
lines changed

14 files changed

+74
-66
lines changed

.changeset/hip-pianos-teach.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@sl-design-system/skeleton': minor
3+
---
4+
5+
Refactor component to use contextual tokens

packages/components/skeleton/src/skeleton.scss

Lines changed: 21 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,44 @@
11
:host {
2-
--_animation-duration: var(--sl-skeleton-animation-duration, 3000ms);
3-
--_background: var(--sl-color-skeleton-base);
4-
--_border-radius-circle: var(--sl-border-radius-circle);
5-
--_border-radius: var(--sl-border-radius-skeleton-default);
6-
--_min-block-size: var(--sl-size-skeleton-min-height);
7-
--_shine-color: var(--sl-color-skeleton-effect);
8-
9-
background: var(--_background);
2+
background: linear-gradient(
3+
to right,
4+
var(--sl-color-skeleton-plain) 4%,
5+
var(--sl-color-skeleton-subtle) 25%,
6+
var(--sl-color-skeleton-plain) 36%
7+
);
8+
background-size: 2000px 100%;
9+
border-radius: var(--sl-size-borderRadius-default);
1010
display: block;
11-
min-block-size: var(--_min-block-size);
12-
}
11+
min-block-size: var(--sl-size-100);
1312

14-
:host([variant='default']) {
15-
border-radius: var(--_border-radius);
13+
@media (prefers-reduced-motion: no-preference) {
14+
animation: shimmer-effect 3s linear infinite;
15+
}
1616
}
1717

1818
:host([variant='circle']) {
19-
border-radius: var(--_border-radius-circle);
20-
}
21-
22-
:host([effect='shimmer']) {
23-
background: linear-gradient(to right, var(--_background) 4%, var(--_shine-color) 25%, var(--_background) 36%);
24-
background-size: 2000px 100%;
25-
26-
@media (prefers-reduced-motion: no-preference) {
27-
animation: shimmer-effect var(--_animation-duration) linear infinite;
28-
}
19+
border-radius: 50%;
2920
}
3021

3122
:host([effect='sheen']) {
3223
background-image: linear-gradient(
3324
100deg,
34-
var(--_shine-color),
35-
var(--_background),
36-
var(--_background),
37-
var(--_shine-color)
25+
var(--sl-color-skeleton-subtle),
26+
var(--sl-color-skeleton-plain),
27+
var(--sl-color-skeleton-plain),
28+
var(--sl-color-skeleton-subtle)
3829
);
3930
background-size: 200% 100%;
4031

4132
@media (prefers-reduced-motion: no-preference) {
42-
animation: sheen-effect var(--_animation-duration) linear infinite;
33+
animation: sheen-effect 3s linear infinite;
4334
}
4435
}
4536

4637
:host([effect='pulse']) {
38+
background: var(--sl-color-skeleton-plain);
39+
4740
@media (prefers-reduced-motion: no-preference) {
48-
animation: pulse-effect var(--_animation-duration) ease-in-out 0.5s infinite;
41+
animation: pulse-effect 3s ease-in-out 0.5s infinite;
4942
}
5043
}
5144

packages/components/skeleton/src/skeleton.spec.ts

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,47 +10,52 @@ describe('sl-skeleton', () => {
1010
el = await fixture(html`<sl-skeleton></sl-skeleton>`);
1111
});
1212

13-
it('should render correctly', () => {
14-
expect(el).shadowDom.to.equalSnapshot();
15-
});
16-
1713
it('should have an aria busy', () => {
1814
expect(el).to.have.attribute('aria-busy', 'true');
1915
});
2016

21-
it('should have a shimmer effect by default', () => {
22-
expect(el).to.have.attribute('effect', 'shimmer');
17+
it('should not have a default effect', () => {
18+
expect(el).not.to.have.attribute('effect');
19+
expect(el.effect).to.be.undefined;
2320
});
2421

2522
it('should have a pulse effect when set', async () => {
2623
el.effect = 'pulse';
2724
await el.updateComplete;
2825

29-
const effect = el.getAttribute('effect');
30-
expect(effect).to.equal('pulse');
26+
expect(el).to.have.attribute('effect', 'pulse');
3127
});
3228

3329
it('should have a shimmer effect when set', async () => {
3430
el.effect = 'shimmer';
3531
await el.updateComplete;
3632

37-
const effect = el.getAttribute('effect');
38-
expect(effect).to.equal('shimmer');
33+
expect(el).to.have.attribute('effect', 'shimmer');
3934
});
4035

4136
it('should have a sheen effect when set', async () => {
4237
el.effect = 'sheen';
4338
await el.updateComplete;
4439

45-
const effect = el.getAttribute('effect');
46-
expect(effect).to.equal('sheen');
40+
expect(el).to.have.attribute('effect', 'sheen');
4741
});
4842

4943
it('should have no effect when set to none', async () => {
5044
el.effect = 'none';
5145
await el.updateComplete;
5246

53-
const effect = el.getAttribute('effect');
54-
expect(effect).to.equal('none');
47+
expect(el).to.have.attribute('effect', 'none');
48+
});
49+
50+
it('should not have a default variant', () => {
51+
expect(el).not.to.have.attribute('variant');
52+
expect(el.variant).to.be.undefined;
53+
});
54+
55+
it('should have a circle variant when set', async () => {
56+
el.variant = 'circle';
57+
await el.updateComplete;
58+
59+
expect(el).to.have.attribute('variant', 'circle');
5560
});
5661
});

packages/components/skeleton/src/skeleton.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,26 @@ declare global {
99
}
1010

1111
export type SkeletonEffect = 'none' | 'shimmer' | 'pulse' | 'sheen';
12-
1312
export type SkeletonVariant = 'circle' | 'default';
1413

14+
/**
15+
* Skeletons are used as a temporary placeholder while content is loading to improve the user experience.
16+
*/
1517
export class Skeleton extends LitElement {
1618
/** @internal */
1719
static override styles: CSSResultGroup = styles;
1820

1921
/**
2022
* Skeleton's effect.
21-
* @type {'none' | 'shimmer' | 'pulse' | 'sheen'}
23+
* @default 'shimmer'
2224
*/
23-
@property({ reflect: true }) effect: SkeletonEffect = 'shimmer';
25+
@property({ reflect: true }) effect?: SkeletonEffect;
2426

2527
/**
2628
* Skeleton's variant.
27-
* @type {'circle' | 'default'}
29+
* @default 'default'
2830
*/
29-
@property({ reflect: true }) variant: SkeletonVariant = 'default';
31+
@property({ reflect: true }) variant?: SkeletonVariant;
3032

3133
override connectedCallback(): void {
3234
super.connectedCallback();

packages/tokens/src/clickedu/light-new.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -692,12 +692,12 @@
692692
"skeleton": {
693693
"plain": {
694694
"$type": "color",
695-
"$value": "{clickedu.color.background.accent.grey.subtlest}",
695+
"$value": "{clickedu.color.palette.grey.100}",
696696
"$description": "Use for skeleton loading states."
697697
},
698698
"subtle": {
699699
"$type": "color",
700-
"$value": "{clickedu.color.background.accent.grey.subtle}",
700+
"$value": "{clickedu.color.palette.grey.050}",
701701
"$description": "Use for the pulse or shimmer effect in skeleton loading states."
702702
}
703703
},

packages/tokens/src/editorial-suite/light-new.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -692,12 +692,12 @@
692692
"skeleton": {
693693
"plain": {
694694
"$type": "color",
695-
"$value": "{editorial-suite.color.background.accent.grey.subtlest}",
695+
"$value": "{editorial-suite.color.palette.grey.100}",
696696
"$description": "Use for skeleton loading states."
697697
},
698698
"subtle": {
699699
"$type": "color",
700-
"$value": "{editorial-suite.color.background.accent.grey.subtle}",
700+
"$value": "{editorial-suite.color.palette.grey.050}",
701701
"$description": "Use for the pulse or shimmer effect in skeleton loading states."
702702
}
703703
},

packages/tokens/src/itslearning/light-new.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -692,12 +692,12 @@
692692
"skeleton": {
693693
"plain": {
694694
"$type": "color",
695-
"$value": "{itslearning.color.background.accent.grey.subtlest}",
695+
"$value": "{itslearning.color.palette.grey.100}",
696696
"$description": "Use for skeleton loading states."
697697
},
698698
"subtle": {
699699
"$type": "color",
700-
"$value": "{itslearning.color.background.accent.grey.subtle}",
700+
"$value": "{itslearning.color.palette.grey.050}",
701701
"$description": "Use for the pulse or shimmer effect in skeleton loading states."
702702
}
703703
},

packages/tokens/src/magister/light-new.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -692,12 +692,12 @@
692692
"skeleton": {
693693
"plain": {
694694
"$type": "color",
695-
"$value": "{magister.color.background.accent.grey.subtlest}",
695+
"$value": "{magister.color.palette.grey.100}",
696696
"$description": "Use for skeleton loading states."
697697
},
698698
"subtle": {
699699
"$type": "color",
700-
"$value": "{magister.color.background.accent.grey.subtle}",
700+
"$value": "{magister.color.palette.grey.050}",
701701
"$description": "Use for the pulse or shimmer effect in skeleton loading states."
702702
}
703703
},

packages/tokens/src/neon/light-new.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -692,12 +692,12 @@
692692
"skeleton": {
693693
"plain": {
694694
"$type": "color",
695-
"$value": "{neon.color.background.accent.grey.subtlest}",
695+
"$value": "{neon.color.palette.grey.100}",
696696
"$description": "Use for skeleton loading states."
697697
},
698698
"subtle": {
699699
"$type": "color",
700-
"$value": "{neon.color.background.accent.grey.subtle}",
700+
"$value": "{neon.color.palette.grey.050}",
701701
"$description": "Use for the pulse or shimmer effect in skeleton loading states."
702702
}
703703
},

packages/tokens/src/sanoma-learning/dark-new.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -692,12 +692,12 @@
692692
"skeleton": {
693693
"plain": {
694694
"$type": "color",
695-
"$value": "{sanoma-learning.color.background.accent.grey.subtlest}",
695+
"$value": "rgba( {sanoma-learning.color.palette.grey.900}, 5%)",
696696
"$description": "Use for skeleton loading states."
697697
},
698698
"subtle": {
699699
"$type": "color",
700-
"$value": "{sanoma-learning.color.background.accent.grey.subtle}",
700+
"$value": "{sanoma-learning.color.palette.grey.000}",
701701
"$description": "Use for the pulse or shimmer effect in skeleton loading states."
702702
}
703703
},

0 commit comments

Comments
 (0)