Skip to content

Commit d497511

Browse files
committed
Prefer named exports for normalize color
1 parent 4fb5995 commit d497511

File tree

6 files changed

+15
-42
lines changed

6 files changed

+15
-42
lines changed

.size-snapshot.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
{
22
"dist/react-spring.es.js": {
3-
"bundled": 75051,
4-
"minified": 36209,
5-
"gzipped": 11302,
3+
"bundled": 75016,
4+
"minified": 36173,
5+
"gzipped": 11288,
66
"treeshaked": {
7-
"rollup": 28460,
8-
"webpack": 29468
7+
"rollup": 28404,
8+
"webpack": 29412
99
}
1010
},
1111
"dist/react-spring.umd.js": {
12-
"bundled": 88356,
13-
"minified": 38276,
14-
"gzipped": 12756
12+
"bundled": 88321,
13+
"minified": 38219,
14+
"gzipped": 12739
1515
},
1616
"dist/NumericalSpring.cjs.js": {
1717
"bundled": 33038,

examples/yarn.lock

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4987,21 +4987,6 @@ neo-async@^2.5.0:
49874987
version "2.5.0"
49884988
resolved "https://registry.yarnpkg.com/neo-async/-/neo-async-2.5.0.tgz#76b1c823130cca26acfbaccc8fbaf0a2fa33b18f"
49894989

4990-
4991-
version "1.2.15"
4992-
resolved "https://registry.yarnpkg.com/nerv-shared/-/nerv-shared-1.2.15.tgz#9e7c7f3e32447fe8ae40efdd2ddc85b395797e77"
4993-
4994-
4995-
version "1.2.15"
4996-
resolved "https://registry.yarnpkg.com/nerv-utils/-/nerv-utils-1.2.15.tgz#e6db2dc4f9ee1b7a4030920c19ebdd6ea9d86ae9"
4997-
4998-
nervjs@^1.2.17:
4999-
version "1.2.17"
5000-
resolved "https://registry.yarnpkg.com/nervjs/-/nervjs-1.2.17.tgz#cf3b02bc82cccc092257ab0f684ce3a6309b53ef"
5001-
dependencies:
5002-
nerv-shared "1.2.15"
5003-
nerv-utils "1.2.15"
5004-
50054990
nice-try@^1.0.4:
50064991
version "1.0.4"
50074992
resolved "https://registry.yarnpkg.com/nice-try/-/nice-try-1.0.4.tgz#d93962f6c52f2c1558c0fbda6d512819f1efe1c4"

src/animated/Interpolation.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import normalizeColor from '../normalize-css-color/index.js'
1+
import { normalizeColor, colorNames } from '../normalize-css-color/index.js'
22

33
var linear = t => t
44

@@ -122,10 +122,7 @@ var stringShapeRegex = /[0-9\.-]+/g
122122
// Taken from https://gist.github.com/olmokramer/82ccce673f86db7cda5e
123123
var colorRegex = /(#[\d\w]+|\w+\((?:\d+%?(?:,\s)*){3}(?:\d*\.?\d+)?\))/
124124
// Covers color names (transparent, blue, etc.)
125-
var colorNamesRegex = new RegExp(
126-
`(${Object.keys(normalizeColor.colorNames).join('|')})`,
127-
'g'
128-
)
125+
var colorNamesRegex = new RegExp(`(${Object.keys(colorNames).join('|')})`, 'g')
129126

130127
/**
131128
* Supports string shapes by extracting numbers so new values can be computed,

src/animated/targets/Interpolation.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import normalizeColor from '../../normalize-css-color/index.js'
1+
import { normalizeColor, colorNames } from '../../normalize-css-color/index.js'
22

33
var linear = t => t
44

@@ -122,10 +122,7 @@ var stringShapeRegex = /[0-9\.-]+/g
122122
// Taken from https://gist.github.com/olmokramer/82ccce673f86db7cda5e
123123
var colorRegex = /(#[\d\w]+|\w+\((?:\d+%?(?:,\s)*){3}(?:\d*\.?\d+)?\))/
124124
// Covers color names (transparent, blue, etc.)
125-
var colorNamesRegex = new RegExp(
126-
`(${Object.keys(normalizeColor.colorNames).join('|')})`,
127-
'g'
128-
)
125+
var colorNamesRegex = new RegExp(`(${Object.keys(colorNames).join('|')})`, 'g')
129126

130127
/**
131128
* Supports string shapes by extracting numbers so new values can be computed,

src/normalize-css-color/index.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export default function normalizeColor(color) {
1+
export function normalizeColor(color) {
22
var match
33

44
if (typeof color === 'number') {
@@ -10,7 +10,7 @@ export default function normalizeColor(color) {
1010
if ((match = matchers.hex6.exec(color)))
1111
return parseInt(match[1] + 'ff', 16) >>> 0
1212

13-
if (names.hasOwnProperty(color)) return names[color]
13+
if (colorNames.hasOwnProperty(color)) return colorNames[color]
1414

1515
if ((match = matchers.rgb.exec(color))) {
1616
return (
@@ -166,7 +166,7 @@ function parsePercentage(str) {
166166
return int / 100
167167
}
168168

169-
var names = {
169+
export const colorNames = {
170170
transparent: 0x00000000,
171171

172172
// http://www.w3.org/TR/css3-color/#svg-color
@@ -320,5 +320,3 @@ var names = {
320320
yellow: 0xffff00ff,
321321
yellowgreen: 0x9acd32ff,
322322
}
323-
324-
normalizeColor.colorNames = names

yarn.lock

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3216,10 +3216,6 @@ nopt@^4.0.1:
32163216
abbrev "1"
32173217
osenv "^0.1.4"
32183218

3219-
normalize-css-color@^1.0.2:
3220-
version "1.0.2"
3221-
resolved "https://registry.yarnpkg.com/normalize-css-color/-/normalize-css-color-1.0.2.tgz#02991e97cccec6623fe573afbbf0de6a1f3e9f8d"
3222-
32233219
normalize-package-data@^2.3.2:
32243220
version "2.4.0"
32253221
resolved "https://registry.yarnpkg.com/normalize-package-data/-/normalize-package-data-2.4.0.tgz#12f95a307d58352075a04907b84ac8be98ac012f"

0 commit comments

Comments
 (0)