mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-15 10:21:05 +00:00
fix(skeleton-text): fix reactivity in paragraph
variant (#1794)
Fixes #1793
This commit is contained in:
parent
e5675eb203
commit
bc97ce5e1b
1 changed files with 7 additions and 10 deletions
|
@ -13,24 +13,21 @@
|
|||
|
||||
const RANDOM = [0.973, 0.153, 0.567];
|
||||
|
||||
$: rows = [];
|
||||
$: widthNum = parseInt(width, 10);
|
||||
$: widthPx = width.includes("px");
|
||||
$: if (paragraph) {
|
||||
for (let i = 0; i < lines; i++) {
|
||||
const min = widthPx ? widthNum - 75 : 0;
|
||||
const max = widthPx ? widthNum : 75;
|
||||
const rand = Math.floor(RANDOM[i % 3] * (max - min + 1)) + min + "px";
|
||||
rows = [...rows, { width: widthPx ? rand : `calc(${width} - ${rand})` }];
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<!-- svelte-ignore a11y-mouse-events-have-key-events -->
|
||||
{#if paragraph}
|
||||
<!-- svelte-ignore a11y-no-static-element-interactions -->
|
||||
<div {...$$restProps} on:click on:mouseover on:mouseenter on:mouseleave>
|
||||
{#each rows as { width }}
|
||||
{#each Array.from({ length: lines }).map((_, i) => {
|
||||
const min = widthPx ? widthNum - 75 : 0;
|
||||
const max = widthPx ? widthNum : 75;
|
||||
const rand = Math.floor(RANDOM[i % 3] * (max - min + 1)) + min + "px";
|
||||
|
||||
return widthPx ? rand : `calc(${width} - ${rand})`;
|
||||
}) as width}
|
||||
<p
|
||||
class:bx--skeleton__text="{true}"
|
||||
class:bx--skeleton__heading="{heading}"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue