Skip to content

Commit

Permalink
fix(SkeletonText): support SSR (carbon-design-system#2095)
Browse files Browse the repository at this point in the history
* fix(SkeletonText): support SSR

Fixes carbon-design-system#2013.

* chore: update bundle size threshold
  • Loading branch information
asudoh authored Mar 27, 2019
1 parent e76d696 commit 8a31df2
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/components/SkeletonText/SkeletonText.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ import { settings } from 'carbon-components';

const { prefix } = settings;

const randoms = [0.973051493507435, 0.15334737213558558, 0.5671034553053769];

function getRandomInt(min, max, n) {
return Math.floor(randoms[n % 3] * (max - min + 1)) + min;
}

const SkeletonText = ({
paragraph,
lineCount,
Expand All @@ -32,14 +38,10 @@ const SkeletonText = ({

const widthPercent = width.includes('%');

function getRandomInt(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}

if (widthPercent && paragraph) {
const lines = [];
for (var i = 0; i < lineCount; i++) {
const randomWidth = getRandomInt(0, 75) + 'px';
const randomWidth = getRandomInt(0, 75, i) + 'px';
lines.push(
<p
className={skeletonTextClasses}
Expand All @@ -55,7 +57,7 @@ const SkeletonText = ({
if (widthPx && paragraph) {
const lines = [];
for (var j = 0; j < lineCount; j++) {
const randomWidth = getRandomInt(widthNum - 75, widthNum) + 'px';
const randomWidth = getRandomInt(widthNum - 75, widthNum, j) + 'px';
lines.push(
<p
className={skeletonTextClasses}
Expand Down

0 comments on commit 8a31df2

Please sign in to comment.