styled-tools
Advanced tools
Comparing version 1.2.0 to 1.3.0
@@ -5,2 +5,12 @@ # Change Log | ||
<a name="1.3.0"></a> | ||
# [1.3.0](https://github.com/diegohaz/styled-tools/compare/v1.2.0...v1.3.0) (2018-08-18) | ||
### Features | ||
* Add `theme` method ([#47](https://github.com/diegohaz/styled-tools/issues/47)) ([1514664](https://github.com/diegohaz/styled-tools/commit/1514664)) | ||
<a name="1.2.0"></a> | ||
@@ -7,0 +17,0 @@ # [1.2.0](https://github.com/diegohaz/styled-tools/compare/v1.1.0...v1.2.0) (2018-08-18) |
@@ -6,3 +6,3 @@ "use strict"; | ||
}); | ||
exports.withProp = exports.switchProp = exports.prop = exports.ifProp = exports.ifNotProp = undefined; | ||
exports.withProp = exports.theme = exports.switchProp = exports.prop = exports.ifProp = exports.ifNotProp = undefined; | ||
@@ -25,2 +25,6 @@ var _ifNotProp2 = require("./ifNotProp"); | ||
var _theme2 = require("./theme"); | ||
var _theme3 = _interopRequireDefault(_theme2); | ||
var _withProp2 = require("./withProp"); | ||
@@ -36,2 +40,3 @@ | ||
exports.switchProp = _switchProp3.default; | ||
exports.theme = _theme3.default; | ||
exports.withProp = _withProp3.default; |
@@ -9,3 +9,5 @@ import _ifNotProp from "./ifNotProp"; | ||
export { _switchProp as switchProp }; | ||
import _theme from "./theme"; | ||
export { _theme as theme }; | ||
import _withProp from "./withProp"; | ||
export { _withProp as withProp }; |
{ | ||
"name": "styled-tools", | ||
"version": "1.2.0", | ||
"version": "1.3.0", | ||
"description": "Utilities for styled-components", | ||
@@ -52,3 +52,3 @@ "license": "MIT", | ||
"babel-eslint": "^8.2.6", | ||
"babel-jest": "^23.4.0", | ||
"babel-jest": "^23.4.2", | ||
"babel-plugin-transform-flow-strip-types": "^6.21.0", | ||
@@ -59,23 +59,23 @@ "babel-preset-env": "^1.7.0", | ||
"cross-env": "^5.2.0", | ||
"documentation": "^8.0.0", | ||
"eslint": "^5.1.0", | ||
"eslint-config-airbnb-base": "^13.0.0", | ||
"eslint-config-prettier": "^2.9.0", | ||
"documentation": "^8.1.1", | ||
"eslint": "^5.4.0", | ||
"eslint-config-airbnb-base": "^13.1.0", | ||
"eslint-config-prettier": "^3.0.1", | ||
"eslint-plugin-flowtype": "^2.50.0", | ||
"eslint-plugin-flowtype-errors": "^3.6.0", | ||
"eslint-plugin-import": "^2.13.0", | ||
"eslint-plugin-import": "^2.14.0", | ||
"eslint-plugin-prettier": "^2.6.2", | ||
"flow-bin": "^0.76.0", | ||
"flow-bin": "^0.79.1", | ||
"flow-typed": "^2.5.1", | ||
"jest-cli": "^23.4.1", | ||
"jest-cli": "^23.5.0", | ||
"opn-cli": "^3.1.0", | ||
"prettier": "^1.13.7", | ||
"react": "^16.4.1", | ||
"react-dom": "^16.4.1", | ||
"prettier": "^1.14.2", | ||
"react": "^16.4.2", | ||
"react-dom": "^16.4.2", | ||
"rimraf": "^2.6.2", | ||
"standard-version": "^4.4.0", | ||
"styled-components": "^3.3.3", | ||
"styled-tools": "^1.0.0", | ||
"styled-components": "^3.4.2", | ||
"styled-tools": "^1.2.0", | ||
"typescript": "^3.0.1" | ||
} | ||
} |
@@ -84,14 +84,17 @@ # styled-tools 💅 | ||
- [Examples](#examples) | ||
- [ifProp](#ifprop) | ||
- [theme](#theme) | ||
- [Parameters](#parameters-1) | ||
- [Examples](#examples-1) | ||
- [ifNotProp](#ifnotprop) | ||
- [ifProp](#ifprop) | ||
- [Parameters](#parameters-2) | ||
- [Examples](#examples-2) | ||
- [withProp](#withprop) | ||
- [ifNotProp](#ifnotprop) | ||
- [Parameters](#parameters-3) | ||
- [Examples](#examples-3) | ||
- [switchProp](#switchprop) | ||
- [withProp](#withprop) | ||
- [Parameters](#parameters-4) | ||
- [Examples](#examples-4) | ||
- [switchProp](#switchprop) | ||
- [Parameters](#parameters-5) | ||
- [Examples](#examples-5) | ||
- [Types](#types) | ||
@@ -119,2 +122,22 @@ - [Needle](#needle) | ||
### theme | ||
Same as `prop`, except that it returns `props.theme[path]` instead of | ||
`props[path]`. | ||
#### Parameters | ||
- `path` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** | ||
- `defaultValue` **any** | ||
#### Examples | ||
```javascript | ||
const Button = styled.button` | ||
color: ${theme("button.color", "red")}; | ||
`; | ||
``` | ||
Returns **PropsWithThemeFn** | ||
### ifProp | ||
@@ -121,0 +144,0 @@ |
@@ -5,2 +5,6 @@ type Dictionary<T = any> = { [key: string]: T }; | ||
type PropsWithThemeFn<ReturnType = any> = ( | ||
props: Dictionary & { theme: Dictionary } | ||
) => ReturnType; | ||
export function ifProp<Pass = string, Fail = string>( | ||
@@ -26,2 +30,4 @@ test: Needle | Needle[] | Dictionary, | ||
export function theme(path: string, defaultValue?: any): PropsWithThemeFn; | ||
export function withProp<T = any>( | ||
@@ -28,0 +34,0 @@ needle: Needle | Needle[], |
@@ -1,2 +0,2 @@ | ||
import { ifProp, ifNotProp, prop, switchProp, withProp } from ".."; | ||
import { ifProp, ifNotProp, prop, switchProp, withProp, theme } from ".."; | ||
@@ -19,3 +19,6 @@ ifProp("a", true)({ a: true }); | ||
theme("a")({ theme: { a: true } }) | ||
theme("a", "b")({ theme: { a: true } }) | ||
withProp("a", (a: boolean) => a)({ a: false }); | ||
withProp(["a", "b"], (a: number, b: string) => b)({ a: false }); |
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
29682
20
478
263