@primer/react
Version:
An implementation of GitHub's Primer Design System using React
114 lines (111 loc) • 2.18 kB
JavaScript
import { c } from 'react-compiler-runtime';
import React, { useState, useEffect } from 'react';
import { clsx } from 'clsx';
import classes from './SkeletonBox.module.css.js';
import { jsx } from 'react/jsx-runtime';
const SkeletonBox = /*#__PURE__*/React.forwardRef(function SkeletonBox(t0, ref) {
const $ = c(23);
let className;
let delay;
let height;
let props;
let style;
let width;
if ($[0] !== t0) {
({
height,
width,
className,
style,
delay,
...props
} = t0);
$[0] = t0;
$[1] = className;
$[2] = delay;
$[3] = height;
$[4] = props;
$[5] = style;
$[6] = width;
} else {
className = $[1];
delay = $[2];
height = $[3];
props = $[4];
style = $[5];
width = $[6];
}
const [isVisible, setIsVisible] = useState(!delay);
let t1;
let t2;
if ($[7] !== delay) {
t1 = () => {
if (delay) {
const timeoutId = setTimeout(() => {
setIsVisible(true);
}, typeof delay === "number" ? delay : delay === "short" ? 300 : 1000);
return () => clearTimeout(timeoutId);
}
};
t2 = [delay];
$[7] = delay;
$[8] = t1;
$[9] = t2;
} else {
t1 = $[8];
t2 = $[9];
}
useEffect(t1, t2);
if (!isVisible) {
return null;
}
const t3 = ref;
let t4;
if ($[10] !== className) {
t4 = clsx(className, classes.SkeletonBox);
$[10] = className;
$[11] = t4;
} else {
t4 = $[11];
}
let t5;
if ($[12] !== style) {
t5 = style || {};
$[12] = style;
$[13] = t5;
} else {
t5 = $[13];
}
let t6;
if ($[14] !== height || $[15] !== t5 || $[16] !== width) {
t6 = {
height,
width,
...t5
};
$[14] = height;
$[15] = t5;
$[16] = width;
$[17] = t6;
} else {
t6 = $[17];
}
let t7;
if ($[18] !== props || $[19] !== t3 || $[20] !== t4 || $[21] !== t6) {
t7 = /*#__PURE__*/jsx("div", {
ref: t3,
className: t4,
style: t6,
...props
});
$[18] = props;
$[19] = t3;
$[20] = t4;
$[21] = t6;
$[22] = t7;
} else {
t7 = $[22];
}
return t7;
});
export { SkeletonBox };