Skip to content

Commit

Permalink
[patch] fix pointcount to be randomish (#6)
Browse files Browse the repository at this point in the history
* [patch] fix pointcount to be randomish

* [patch] update example
  • Loading branch information
camjc authored Mar 4, 2020
1 parent 72a0703 commit f42aff9
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 9 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 9 additions & 6 deletions src/underline-emphasis/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion test/__snapshots__/underline-emphasis.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ exports[`it renders with children 1`] = `
<em
style={
Object {
"backgroundImage": "url('data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjYwIiBoZWlnaHQ9IjE2IiB2aWV3Qm94PSIwIDAgMjYwIDE2IiBmaWxsPSJub25lIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPgogICAgPHBvbHlsaW5lIHBvaW50cz0iMTY2LjgyNjU4OTY5MjA0MjUsMTIgNCw2Ljg4NjY0NTI5NDk3NjEzIDI1Niw0IiBzdHJva2U9IiM5ODU1RDQiIHN0cm9rZS13aWR0aD0iNCIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbGluZWpvaW49InJvdW5kIiAvPgogIDwvc3ZnPg==')",
"backgroundImage": "url('data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjYwIiBoZWlnaHQ9IjE2IiB2aWV3Qm94PSIwIDAgMjYwIDE2IiBmaWxsPSJub25lIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPgogICAgPHBvbHlsaW5lIHBvaW50cz0iMTkxLjk1MTE1MjU5MzMwODk2LDEyIDM3LjIxNzY4OTI4NzYwMTYyLDguODc5NTAwMzAwMzcxMzYyIDI1Niw3LjE4ODc4NjE0NjcyODIyMyA0LDQiIHN0cm9rZT0iIzk4NTVENCIgc3Ryb2tlLXdpZHRoPSI0IiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiIC8+CiAgPC9zdmc+')",
"backgroundPosition": "bottom",
"backgroundRepeat": "no-repeat",
"backgroundSize": "100% auto",
Expand Down

0 comments on commit f42aff9

Please sign in to comment.