Skip to content

Commit a97ee39

Browse files
author
rofrischmann
committed
1.0.3 relase
1 parent de52666 commit a97ee39

File tree

7 files changed

+55
-15
lines changed

7 files changed

+55
-15
lines changed

.eslintrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
"no-plusplus": [ 0 ],
2626
"no-continue": [ 0 ],
2727
"no-restricted-syntax": [ 0 ],
28+
"no-prototype-builtins": [ 0 ],
2829
"consistent-return": [ 0 ],
2930
"guard-for-in": [ 0 ]
3031
}

Changelog.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Changelog
22

3+
### 1.0.3
4+
* performance improvements
5+
36
### 1.0.2
47
* added `resolveArrayValue` and `assignStyle`
58

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ By now I have authored and collaborated on many different libraries and found I
1919
## Utilities
2020
* [`camelCaseProperty(property)`](#camelcasepropertyproperty)
2121
* [`cssifyDeclaration(property, value)`](#cssifydeclarationproperty-value)
22-
* [`cssifyObject(object)`](#cssifyobjectproperty)
22+
* [`cssifyObject(object)`](#cssifyobjectobject)
2323
* [`hyphenateProperty(property)`](#hyphenatepropertyproperty)
2424
* [`isPrefixedProperty(property)`](#isprefixedpropertyproperty)
2525
* [`isPrefixedValue(value)`](#isprefixedvaluevalue)
26-
* [`isUnitlessProperty(property)`](#isunitlessproperty)
26+
* [`isUnitlessProperty(property)`](#isunitlesspropertyproperty)
2727
* [`normalizeProperty(property)`](#normalizepropertyproperty)
2828
* [`resolveArrayValue(property, value)`](#resolvearrayvalueproperty-value)
2929
* [`unprefixProperty(property)`](#unprefixpropertyproperty)
@@ -127,7 +127,6 @@ isPrefixedValue('-webkit-calc(100% - 50px)')
127127

128128
### `isUnitlessProperty(property)`
129129
Checks if a `property` accepts unitless values.
130-
> Directly mirrors [unitless-css-property](https://github.com/rofrischmann/unitless-css-property).
131130

132131
```javascript
133132
import { isUnitlessProperty } from 'css-in-js-utils'
@@ -137,6 +136,7 @@ isUnitlessProperty('width')
137136

138137
isUnitlessProperty('flexGrow')
139138
isUnitlessProperty('lineHeight')
139+
isUnitlessProperty('line-height')
140140
// => true
141141
```
142142

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import isUnitlessProperty from '../isUnitlessProperty'
2+
3+
describe('Checking for unitless CSS properties', () => {
4+
it('should return true for unitless properties', () => {
5+
expect(isUnitlessProperty('fontWeight')).toEqual(true)
6+
expect(isUnitlessProperty('flex')).toEqual(true)
7+
expect(isUnitlessProperty('gridColumn')).toEqual(true)
8+
})
9+
10+
it('should return true for hypenated unitless properties', () => {
11+
expect(isUnitlessProperty('font-weight')).toEqual(true)
12+
expect(isUnitlessProperty('grid-column')).toEqual(true)
13+
})
14+
15+
it('should return true for prefixed unitless properties', () => {
16+
expect(isUnitlessProperty('WebkitFlex')).toEqual(true)
17+
expect(isUnitlessProperty('msFlex')).toEqual(true)
18+
expect(isUnitlessProperty('WebkitColumnCount')).toEqual(true)
19+
expect(isUnitlessProperty('msColumnCount')).toEqual(true)
20+
})
21+
22+
it('should return true for hypenated prefixed unitless properties', () => {
23+
expect(isUnitlessProperty('-webkit-flex')).toEqual(true)
24+
expect(isUnitlessProperty('-ms-flex')).toEqual(true)
25+
expect(isUnitlessProperty('-webkit-column-count')).toEqual(true)
26+
expect(isUnitlessProperty('-ms-column-count')).toEqual(true)
27+
})
28+
29+
it('should equal false for other properties', () => {
30+
expect(isUnitlessProperty('fontSize')).toEqual(false)
31+
expect(isUnitlessProperty('font-size')).toEqual(false)
32+
expect(isUnitlessProperty('-webkit-border-radius')).toEqual(false)
33+
expect(isUnitlessProperty('-ms-border-radius')).toEqual(false)
34+
expect(isUnitlessProperty('WebkitBorderRadius')).toEqual(false)
35+
expect(isUnitlessProperty('msBorderRadius')).toEqual(false)
36+
})
37+
})

modules/assignStyle.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* @flow */
2-
export default function assignStyle(base, ...extendingStyles) {
2+
export default function assignStyle(base: Object, ...extendingStyles: Array<Object>) {
33
for (let i = 0, len = extendingStyles.length; i < len; ++i) {
44
const style = extendingStyles[i]
55

modules/isUnitlessProperty.js

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* @flow */
22
import hyphenateProperty from './hyphenateProperty'
33

4-
const unitlessProperties = {
4+
const unitlessProperties: Object = {
55
borderImageOutset: true,
66
borderImageSlice: true,
77
borderImageWidth: true,
@@ -13,7 +13,6 @@ const unitlessProperties = {
1313
widows: true,
1414
zIndex: true,
1515
zoom: true,
16-
1716
// SVG-related properties
1817
fillOpacity: true,
1918
floodOpacity: true,
@@ -25,8 +24,8 @@ const unitlessProperties = {
2524
strokeWidth: true
2625
}
2726

28-
const prefixedUnitlessProperties = [
29-
'animationIterationCount',
27+
const prefixedUnitlessProperties: Array<string> = [
28+
'animationIterationCount',
3029
'boxFlex',
3130
'boxFlexGroup',
3231
'boxOrdinalGroup',
@@ -43,25 +42,25 @@ const prefixedUnitlessProperties = [
4342
'lineClamp'
4443
]
4544

46-
const prefixes = ['Webkit', 'ms', 'Moz', 'O']
45+
const prefixes: Array<string> = ['Webkit', 'ms', 'Moz', 'O']
4746

48-
function getPrefixedProperty(prefix, property) {
47+
function getPrefixedProperty(prefix: string, property: string): string {
4948
return prefix + property.charAt(0).toUpperCase() + property.slice(1)
5049
}
5150

5251
// add all prefixed properties to the unitless properties
5352
for (let i = 0, len = prefixedUnitlessProperties.length; i < len; ++i) {
53+
const property = prefixedUnitlessProperties[i]
5454
unitlessProperties[property] = true
5555

56-
for (let j = 0, jLen = prefixes.length; j < jLen; ++i) {
57-
unitlessProperties[getPrefixedProperty(prefix, property)] = true
56+
for (let j = 0, jLen = prefixes.length; j < jLen; ++j) {
57+
unitlessProperties[getPrefixedProperty(prefixes[j], property)] = true
5858
}
5959
}
6060

61-
6261
// add all hypenated properties as well
6362
for (const property in unitlessProperties) {
64-
unitlessProperties[hyphenateStyleName(property)] = true
63+
unitlessProperties[hyphenateProperty(property)] = true
6564
}
6665

6766
export default function isUnitlessProperty(property: string): boolean {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "css-in-js-utils",
3-
"version": "1.0.2",
3+
"version": "1.0.3",
44
"description": "Useful utility functions for CSS in JS solutions",
55
"main": "lib/index.js",
66
"files": [

0 commit comments

Comments
 (0)