Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[react-jss] Hooks #1089

Merged
merged 61 commits into from
Jun 7, 2019
Merged
Changes from 1 commit
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
1b3fade
Revert "Revert "Add dynamic rules to static sheet""
Mar 2, 2019
5dbc7dc
Fix adding dynamic rules to sheet
Mar 2, 2019
0768cae
Fix a few tests
Mar 2, 2019
d017126
Fix tests
Mar 2, 2019
85cec4e
Format code
Mar 2, 2019
91f6882
Add comments
Mar 6, 2019
b507aae
Merge branch 'master' into feat/move-dynamic-rules-into-static-sheet
Mar 10, 2019
61d465e
Merge branch 'master' into feat/move-dynamic-rules-into-static-sheet
Mar 10, 2019
2ca10eb
Update changelog
Mar 10, 2019
45215c6
Update size-snapshot
Mar 10, 2019
48f899d
Initial draft
Mar 10, 2019
b8284c0
Initial version of hook
Mar 15, 2019
7769334
Add missing dependency
Apr 13, 2019
8fed824
Fix some type issues
Apr 14, 2019
11b0fcf
Rename hook folder to create-use-styles and hoc to with-styles
Apr 14, 2019
b20f7ea
Unify some files
Apr 14, 2019
ae88758
Fix imports
Apr 14, 2019
cf23380
Fix some flow issues
Apr 14, 2019
d9b8452
Update size snapshots
Apr 14, 2019
cbef52d
Fix some eslint problems
Apr 14, 2019
9ee1369
Merge branch 'master' into react-jss/feature/hooks
Apr 14, 2019
ad05c90
Update packages/react-jss/src/create-use-styles.js
eps1lon Apr 15, 2019
ae7841a
Update file names and default exports
Apr 15, 2019
800a929
Use type instead of interface
Apr 15, 2019
4967ece
Fix linting
Apr 15, 2019
b49de75
Fixed PR comments
Apr 15, 2019
50725d3
Update size snapshots
Apr 20, 2019
8fcc455
fix linter, make all file names camel cased
kof Apr 23, 2019
01c0f54
Use state instead of relying on memo
May 4, 2019
76fa59a
Merge remote-tracking branch 'origin/react-jss/feature/hooks' into re…
May 4, 2019
02b641c
Use is-in-browser package
May 4, 2019
8a185ab
Fix some type issues and add support for recreating the sheet when th…
May 5, 2019
8b78a2b
Merge branch 'master' into react-jss/feature/hooks
kof May 6, 2019
7e2a92e
upgrade theming
kof May 7, 2019
b08cd37
add sheet to the registry when managing sheets, pass a theme when usi…
kof May 10, 2019
2036cf4
Fixed all tests
May 30, 2019
5aed3f8
Fix linting etc.
May 30, 2019
d4d372a
Use MIN_SAFE_INTEGER
May 30, 2019
965850b
Merge branch 'master' into react-jss/feature/hooks
kof Jun 2, 2019
afa04d8
remove the need for extra eslit rules
kof Jun 2, 2019
f6a9af4
Add tests for hooks and fix some issue
Jun 2, 2019
59e5a2c
Remove check for disableStylesGeneration
Jun 2, 2019
4f17fea
more explicit name for the hook
kof Jun 5, 2019
71b53e6
port class name prefix test
kof Jun 5, 2019
59c2560
reuse tests between hooks and hocs
kof Jun 5, 2019
aef6158
make dynamicStyles tests use hooks
kof Jun 5, 2019
32bb698
generate dynamic styles test using HOC
kof Jun 5, 2019
12b151c
migrate all dynamic styles tests to use createStyledComponent
kof Jun 5, 2019
62252f1
refactor theming tests
kof Jun 5, 2019
73964b6
Rewrite to useReducer
Jun 6, 2019
3dc8d2e
Fix JssProvider
Jun 6, 2019
e46bde6
port theming tests for hooks
kof Jun 6, 2019
af178af
Merge branch 'react-jss/feature/hooks' of github.com:cssinjs/jss into…
kof Jun 6, 2019
76d0964
move reducer to the module scope, since it doesn't need to be recreated
kof Jun 6, 2019
07322b5
Merge branch 'master' into react-jss/feature/hooks
kof Jun 7, 2019
1fd87da
reset module Id
kof Jun 7, 2019
11725ec
rename shallow-equal, add a note
kof Jun 7, 2019
86e5742
hooks docs
kof Jun 7, 2019
5b0af83
better description
kof Jun 7, 2019
95bef20
better wording
kof Jun 7, 2019
68bbae3
fix link
kof Jun 7, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Merge branch 'master' into react-jss/feature/hooks
* master: (24 commits)
  Fix #1084 (#1085)
  Update size snapshots
  [jss-plugin-expand]Added the ability to expand the attributes for border-bottom (#1083)
  Update react-jss.md (#1078)
  Fix typspec for default unit plugin (#1077)
  Delete CNAME
  Create CNAME
  v10.0.0-alpha.16
  fix versions manually
  update changelog, make build
  Add local yarn version (#1071)
  update snapshots
  Update size-snapshots
  v10.0.0-alpha.15
  update changelog, make build
  Update to [email protected] (#1068)
  Improve IE 11 support (#1065)
  fix changelog
  v10.0.0-alpha.14
  [jss] Add support for multiple referenced keyframes (#1063)
  ...

# Conflicts:
#	packages/jss-plugin-default-unit/.size-snapshot.json
#	packages/jss-preset-default/.size-snapshot.json
#	packages/jss-starter-kit/.size-snapshot.json
#	packages/jss/.size-snapshot.json
#	packages/react-jss/.size-snapshot.json
#	packages/react-jss/src/types.js
#	packages/react-jss/src/withStyles.js
Henri Beck committed Apr 14, 2019

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit 9ee13691a99f1174b6d5b81ec0be8bd3767e9f6e
173,313 changes: 173,313 additions & 0 deletions .yarn/releases/yarn-1.15.2.js

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions .yarnrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1


lastUpdateCheck 1553377279244
yarn-path ".yarn/releases/yarn-1.15.2.js"
25 changes: 25 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -2,10 +2,35 @@

### Bug fixes

- [jss-plugin-expand] Fix attributes spread for `border-bottom`, `border-top`, `border-left` and `border-right` ([#1083](https://github.com/cssinjs/jss/pull/1083))
- [jss-plugin-props-sort] Fix sorting in Node 11 ([#1084](https://github.com/cssinjs/jss/pull/1083))

## 10.0.0-alpha.16 (2019-3-24)

### Bug fixes

- [jss-plugin-camel-case] Fix some IE 11 regression ([#1065](https://github.com/cssinjs/jss/pull/1065))
- [jss-vendor-prefixer] Fix value prefixing, in particular `position: sticky` ([#1068](https://github.com/cssinjs/jss/pull/1068))

## 10.0.0-alpha.14 (2019-3-17)

### Improvements

- [jss] Add support for multiple referenced keyframes ([#1063](https://github.com/cssinjs/jss/pull/1063))

### Bug fixes

- [jss] Fix SSR aggregation regression ([#1064](https://github.com/cssinjs/jss/pull/1064))

## 10.0.0-alpha.13 (2019-3-12)

### Bug fixes

- [react-jss] Replace spaces inside the display name with hyphens ([#1049](https://github.com/cssinjs/jss/pull/1049))

### Improvements

- [jss] Remove VirtualRenderer and the option `virtual: true`. Now to simulate a non-browser environment, pass `create({Renderer: null})` when creating a Jss instance.
- [react-jss] Add dynamic rules to the static sheet ([#1048](https://github.com/cssinjs/jss/pull/1048))

## 10.0.0-alpha.12 (2019-2-27)
2 changes: 1 addition & 1 deletion docs/jss-api.md
Original file line number Diff line number Diff line change
@@ -47,7 +47,7 @@ Options:

- `createGenerateId` - a function which returns a function which generates unique class names.
- `plugins` - an array of functions, will be passed to `jss.use`.
- `virtual` - if true, JSS will use VirtualRenderer.
- `Renderer` - if null, JSS will not render to DOM, or pass a custom Renderer.
- `insertionPoint` - string value of a DOM comment node which marks the start of sheets or a rendered DOM node. Sheets rendered by this Jss instance are inserted after this point sequentially.

**Note**: Each `jss.setup()` call will perform a shallow merge with the old options except for `plugins`. Passed `plugins` will get added to the existing plugins.
2 changes: 2 additions & 0 deletions docs/react-jss.md
Original file line number Diff line number Diff line change
@@ -579,6 +579,8 @@ a `WithStyles` type which adds types for all of the injected props.
To use it, simply extend your existing props interface with
`WithStyles<typeof styles>`, where `styles` is your styles object.

> Note: To use WithStyles you must use react-jss version 10 or higher.

Example

```typescript
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"npmClient": "yarn",
"useWorkspaces": true,
"version": "10.0.0-alpha.12",
"version": "10.0.0-alpha.16",
"command": {
"publish": {
"allow-branch": ["master"]
4 changes: 2 additions & 2 deletions packages/jss-plugin-cache/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "jss-plugin-cache",
"description": "JSS plugin that caches the rules and delivers insane performance.",
"version": "10.0.0-alpha.12",
"version": "10.0.0-alpha.16",
"license": "MIT",
"homepage": "https://cssinjs.org/jss-plugin-cache",
"main": "dist/jss-plugin-cache.cjs.js",
@@ -39,6 +39,6 @@
},
"dependencies": {
"@babel/runtime": "^7.3.1",
"jss": "10.0.0-alpha.12"
"jss": "10.0.0-alpha.16"
}
}
2 changes: 1 addition & 1 deletion packages/jss-plugin-cache/readme.md
Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@

> JSS plugin that caches the rules and delivers insane performance.

See our website [jss-plugin-cache](https://cssinjs.org/jss-plugin-cache?v=v10.0.0-alpha.12) for more information.
See our website [jss-plugin-cache](https://cssinjs.org/jss-plugin-cache?v=v10.0.0-alpha.16) for more information.

## Install

24 changes: 12 additions & 12 deletions packages/jss-plugin-camel-case/.size-snapshot.json
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
{
"dist/jss-plugin-camel-case.js": {
"bundled": 2383,
"minified": 856,
"gzipped": 486
"bundled": 2389,
"minified": 858,
"gzipped": 488
},
"dist/jss-plugin-camel-case.min.js": {
"bundled": 2383,
"minified": 856,
"gzipped": 486
"bundled": 2389,
"minified": 858,
"gzipped": 488
},
"dist/jss-plugin-camel-case.cjs.js": {
"bundled": 1703,
"minified": 735,
"gzipped": 393
"bundled": 1709,
"minified": 737,
"gzipped": 398
},
"dist/jss-plugin-camel-case.esm.js": {
"bundled": 1485,
"minified": 563,
"gzipped": 307,
"bundled": 1491,
"minified": 565,
"gzipped": 309,
"treeshaked": {
"rollup": {
"code": 29,
6 changes: 3 additions & 3 deletions packages/jss-plugin-camel-case/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "jss-plugin-camel-case",
"description": "JSS plugin that allows to write camel cased rule properties",
"version": "10.0.0-alpha.12",
"version": "10.0.0-alpha.16",
"license": "MIT",
"homepage": "https://cssinjs.org/jss-camel-case",
"main": "dist/jss-plugin-camel-case.cjs.js",
@@ -37,11 +37,11 @@
"check-snapshot": "node ../../scripts/match-snapshot.js"
},
"devDependencies": {
"jss-plugin-rule-value-function": "10.0.0-alpha.12"
"jss-plugin-rule-value-function": "10.0.0-alpha.16"
},
"dependencies": {
"@babel/runtime": "^7.3.1",
"hyphenate-style-name": "^1.0.3",
"jss": "10.0.0-alpha.12"
"jss": "10.0.0-alpha.16"
}
}
2 changes: 1 addition & 1 deletion packages/jss-plugin-camel-case/readme.md
Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@

> JSS plugin that allows to write camel cased rule properties

See our website [jss-plugin-camel-case](https://cssinjs.org/jss-plugin-camel-case?v=v10.0.0-alpha.12) for more information.
See our website [jss-plugin-camel-case](https://cssinjs.org/jss-plugin-camel-case?v=v10.0.0-alpha.16) for more information.

## Install

4 changes: 2 additions & 2 deletions packages/jss-plugin-camel-case/src/index.js
Original file line number Diff line number Diff line change
@@ -12,7 +12,7 @@ function convertCase(style) {
const converted = {}

for (const prop in style) {
const key = prop.startsWith('--') ? prop : hyphenate(prop)
const key = prop.indexOf('--') === 0 ? prop : hyphenate(prop)

converted[key] = style[prop]
}
@@ -44,7 +44,7 @@ export default function camelCase(): Plugin {
}

function onChangeValue(value, prop, rule) {
if (prop.startsWith('--')) {
if (prop.indexOf('--') === 0) {
return value
}

4 changes: 2 additions & 2 deletions packages/jss-plugin-compose/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "jss-plugin-compose",
"description": "JSS plugin for classes composition",
"version": "10.0.0-alpha.12",
"version": "10.0.0-alpha.16",
"license": "MIT",
"homepage": "https://cssinjs.org/jss-compose",
"main": "dist/jss-plugin-compose.cjs.js",
@@ -39,7 +39,7 @@
},
"dependencies": {
"@babel/runtime": "^7.3.1",
"jss": "10.0.0-alpha.12",
"jss": "10.0.0-alpha.16",
"tiny-warning": "^1.0.2"
}
}
2 changes: 1 addition & 1 deletion packages/jss-plugin-compose/readme.md
Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@

> JSS plugin for classes composition

See our website [jss-plugin-compose](https://cssinjs.org/jss-plugin-compose?v=v10.0.0-alpha.12) for more information.
See our website [jss-plugin-compose](https://cssinjs.org/jss-plugin-compose?v=v10.0.0-alpha.16) for more information.

## Install

10 changes: 5 additions & 5 deletions packages/jss-plugin-default-unit/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "jss-plugin-default-unit",
"description": "JSS plugin that adds default custom unit to numeric values where needed",
"version": "10.0.0-alpha.12",
"version": "10.0.0-alpha.16",
"license": "MIT",
"homepage": "https://cssinjs.org/jss-default-unit",
"main": "dist/jss-plugin-default-unit.cjs.js",
@@ -39,12 +39,12 @@
"check-snapshot": "node ../../scripts/match-snapshot.js"
},
"devDependencies": {
"jss-plugin-expand": "10.0.0-alpha.12",
"jss-plugin-rule-value-function": "10.0.0-alpha.12",
"jss-plugin-rule-value-observable": "10.0.0-alpha.12"
"jss-plugin-expand": "10.0.0-alpha.16",
"jss-plugin-rule-value-function": "10.0.0-alpha.16",
"jss-plugin-rule-value-observable": "10.0.0-alpha.16"
},
"dependencies": {
"@babel/runtime": "^7.3.1",
"jss": "10.0.0-alpha.12"
"jss": "10.0.0-alpha.16"
}
}
2 changes: 1 addition & 1 deletion packages/jss-plugin-default-unit/readme.md
Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@

> JSS plugin that adds default custom unit to numeric values where needed

See our website [jss-plugin-default-unit](https://cssinjs.org/jss-plugin-default-unit?v=v10.0.0-alpha.12) for more information.
See our website [jss-plugin-default-unit](https://cssinjs.org/jss-plugin-default-unit?v=v10.0.0-alpha.16) for more information.

## Install

2 changes: 1 addition & 1 deletion packages/jss-plugin-default-unit/src/index.d.ts
Original file line number Diff line number Diff line change
@@ -2,4 +2,4 @@ import {Plugin} from 'jss'

export type Options = {[key: string]: string}

export default function jssPluginSyntaxDefaultUnit(options: Options): Plugin
export default function jssPluginSyntaxDefaultUnit(options?: Options): Plugin
12 changes: 3 additions & 9 deletions packages/jss-plugin-default-unit/src/index.js
Original file line number Diff line number Diff line change
@@ -2,6 +2,8 @@
import type {Plugin} from 'jss'
import defaultUnits from './defaultUnits'

export type Options = {[key: string]: string}

/**
* Clones the object and adds a camel cased property version.
*/
@@ -20,18 +22,12 @@ const units = addCamelCasedVersion(defaultUnits)

/**
* Recursive deep style passing function
*
* @param {String} current property
* @param {(Object|Array|Number|String)} property value
* @param {Object} options
* @return {(Object|Array|Number|String)} resulting value
*/
function iterate(prop, value, options) {
function iterate(prop: string, value: any, options: Options) {
if (!value) return value

if (Array.isArray(value)) {
for (let i = 0; i < value.length; i++) {
// $FlowFixMe
value[i] = iterate(prop, value[i], options)
}
} else if (typeof value === 'object') {
@@ -61,8 +57,6 @@ function iterate(prop, value, options) {
return value
}

export type Options = {[key: string]: string}

/**
* Add unit to numeric values.
*/
24 changes: 12 additions & 12 deletions packages/jss-plugin-expand/.size-snapshot.json
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
{
"dist/jss-plugin-expand.js": {
"bundled": 11144,
"minified": 4116,
"gzipped": 1452
"bundled": 10469,
"minified": 4500,
"gzipped": 1511
},
"dist/jss-plugin-expand.min.js": {
"bundled": 11144,
"minified": 4116,
"gzipped": 1452
"bundled": 10469,
"minified": 4500,
"gzipped": 1511
},
"dist/jss-plugin-expand.cjs.js": {
"bundled": 10144,
"minified": 4283,
"gzipped": 1451
"bundled": 9489,
"minified": 4667,
"gzipped": 1509
},
"dist/jss-plugin-expand.esm.js": {
"bundled": 10062,
"minified": 4214,
"gzipped": 1406,
"bundled": 9407,
"minified": 4598,
"gzipped": 1464,
"treeshaked": {
"rollup": {
"code": 0,
6 changes: 3 additions & 3 deletions packages/jss-plugin-expand/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "jss-plugin-expand",
"description": "JSS plugin that gives you a better syntax than CSS.",
"version": "10.0.0-alpha.12",
"version": "10.0.0-alpha.16",
"license": "MIT",
"homepage": "https://cssinjs.org/jss-expand",
"main": "dist/jss-plugin-expand.cjs.js",
@@ -37,10 +37,10 @@
"check-snapshot": "node ../../scripts/match-snapshot.js"
},
"devDependencies": {
"jss-plugin-rule-value-observable": "10.0.0-alpha.12"
"jss-plugin-rule-value-observable": "10.0.0-alpha.16"
},
"dependencies": {
"@babel/runtime": "^7.3.1",
"jss": "10.0.0-alpha.12"
"jss": "10.0.0-alpha.16"
}
}
2 changes: 1 addition & 1 deletion packages/jss-plugin-expand/readme.md
Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@

> JSS plugin that gives you a better syntax than CSS.

See our website [jss-plugin-expand](https://cssinjs.org/jss-plugin-expand?v=v10.0.0-alpha.12) for more information.
See our website [jss-plugin-expand](https://cssinjs.org/jss-plugin-expand?v=v10.0.0-alpha.16) for more information.

## Install

Loading
You are viewing a condensed version of this merge commit. You can view the full changes here.