Comparing version 1.3.0 to 1.4.0
{ | ||
"name": "csstype", | ||
"version": "1.3.0", | ||
"version": "1.4.0", | ||
"main": "index.d.ts", | ||
@@ -10,13 +10,13 @@ "description": "TypeScript definitions for CSS", | ||
"devDependencies": { | ||
"@types/chokidar": "^1.7.2", | ||
"@types/jest": "^22.0.1", | ||
"@types/node": "^9.3.0", | ||
"@types/prettier": "^1.6.1", | ||
"@types/chokidar": "^1.7.4", | ||
"@types/jest": "^22.1.1", | ||
"@types/node": "^9.4.0", | ||
"@types/prettier": "^1.10.0", | ||
"chokidar": "^2.0.0", | ||
"jest": "^22.0.6", | ||
"mdn-data": "1.0.0", | ||
"prettier": "^1.7.0", | ||
"jest": "^22.1.4", | ||
"mdn-data": "1.1.0", | ||
"prettier": "^1.10.2", | ||
"ts-node": "^4.1.0", | ||
"tslint": "^5.7.0", | ||
"typescript": "^2.5.2" | ||
"tslint": "^5.9.1", | ||
"typescript": "^2.7.1" | ||
}, | ||
@@ -26,5 +26,5 @@ "scripts": { | ||
"watch": "ts-node build.ts --watch", | ||
"pretty": "prettier --single-quote --write build.ts **/*.ts", | ||
"pretty": "prettier --write build.ts **/*.{ts,js,json}", | ||
"test": "jest --no-cache", | ||
"prepare": "npm run test && npm run build && tsc typecheck.ts --noEmit" | ||
"prepublish": "tsc && npm run test && npm run build && tsc typecheck.ts --noEmit" | ||
}, | ||
@@ -31,0 +31,0 @@ "files": [ |
@@ -6,6 +6,7 @@ # CSSType | ||
```ts | ||
import * as CSS from 'csstype'; | ||
const style: CSS.Properties = { | ||
flexDirection: 'columns', // -> Type '"rows"' is not assignable to type 'FlexDirection'. | ||
opacity: '10%', // -> Type 'string' is not assignable to type 'number'. | ||
bakground: 'red', // -> Object literal may only specify known properties, and 'bakground' does not exist in type 'Properties'. | ||
alignSelf: 'stretsh', // Type error on value | ||
colour: 'white', // Type error on property | ||
} | ||
@@ -17,4 +18,43 @@ ``` | ||
```bash | ||
$ npm install csstype@latest # For projects | ||
$ npm install csstype@* # For libraries | ||
$ npm install csstype@latest # For projects | ||
$ npm install csstype@* # For libraries | ||
``` | ||
## Usage | ||
Lengths defaults to `string`. But it's possible to add `number` as well using generics. | ||
```ts | ||
import * as CSS from 'csstype'; | ||
const style: CSS.Properties<string | number> = { | ||
padding: 10, | ||
margin: '1rem', | ||
} | ||
``` | ||
In some cases, like for CSS-in-JS libraries, an array of values is a way to provide fallback values in CSS. Using `CSS.PropertiesFallback` instead of `CSS.Properties` will add the possibility to use any property value as an array of values. | ||
```ts | ||
import * as CSS from 'csstype'; | ||
const style: CSS.PropertiesFallback = { | ||
display: [ | ||
'-webkit-flex', | ||
'flex', | ||
], | ||
color: 'white', | ||
} | ||
``` | ||
There's even string literals for pseudo selectors and elements. | ||
```ts | ||
import * as CSS from 'csstype'; | ||
const pseudos: { [P in CSS.Pseudos]?: CSS.Properties } = { | ||
':hover': { | ||
display: 'flex', | ||
}, | ||
} | ||
``` |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1572
59
75872