From f42aff9bf483ef0bb6ef624c4248edff12011e69 Mon Sep 17 00:00:00 2001 From: Cameron Chamberlain Date: Thu, 5 Mar 2020 09:48:13 +1100 Subject: [PATCH] [patch] fix pointcount to be randomish (#6) * [patch] fix pointcount to be randomish * [patch] update example --- README.md | 2 +- package-lock.json | 2 +- src/underline-emphasis/index.tsx | 15 +++++++++------ .../underline-emphasis.test.tsx.snap | 2 +- 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 393f1ce..2e64100 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ This component draws a purple squiggly underline underneath whatever text children are passed in. -![image](https://user-images.githubusercontent.com/4197647/75850834-4ceef980-5e3c-11ea-98cf-ee05b8da9535.png) +![image](https://user-images.githubusercontent.com/4197647/75930183-283f6400-5ec6-11ea-82b9-c0740b3f9f06.png) Package uses [tsdx](https://github.com/jaredpalmer/tsdx) as the build system. diff --git a/package-lock.json b/package-lock.json index 3e12671..8daa257 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "underline-emphasis", - "version": "0.1.0", + "version": "0.1.2", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/src/underline-emphasis/index.tsx b/src/underline-emphasis/index.tsx index 435db59..c563cbf 100644 --- a/src/underline-emphasis/index.tsx +++ b/src/underline-emphasis/index.tsx @@ -29,12 +29,15 @@ export const UnderlineEmphasis: React.FunctionComponent<{ getArrayValue: lcGenerator, length: 3, }); - const normalisedPointCountArray = normaliseArray({ - array: pointCountArray, - max: height, - min: 0, - }); - const pointCount = 3 + Math.floor(normalisedPointCountArray[0]); + const minPointCount = 3; + const maxPointCount = 5; + const pointCount = Math.floor( + normaliseArray({ + array: pointCountArray, + max: maxPointCount + 1, + min: minPointCount, + }).sort()[1] + ); const xArray = getArrayByFunction({ getArrayValue: lcGenerator, length: pointCount, diff --git a/test/__snapshots__/underline-emphasis.test.tsx.snap b/test/__snapshots__/underline-emphasis.test.tsx.snap index 98e6e20..5780636 100644 --- a/test/__snapshots__/underline-emphasis.test.tsx.snap +++ b/test/__snapshots__/underline-emphasis.test.tsx.snap @@ -4,7 +4,7 @@ exports[`it renders with children 1`] = `