You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Merge remote-tracking branch 'origin/add-ts-typings' into add-ts-typings
* origin/add-ts-typings:
Scoped keyframes (#888)
Update readme.md (#897)
Use CSSTOM in default unit plugin (#893)
Added .nvmrc (#896)
[WIP] DONT MERGE Fix ci (#895)
Update ci (#894)
Support plugins processing for observables by default (#892)
Typed CSSOM values support (#887)
Dynamic values full syntax (#878)
[jss-plugin-cache] Use WeakMap for cache plugin (#890)
Copy file name to clipboardExpand all lines: changelog.md
+10Lines changed: 10 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,16 @@
1
1
## Next / 2018-09-16
2
2
3
3
- Fix multiple cases where linking CSS rules didn't work (#815, #710, #664)
4
+
- Added support for Typed CSSOM values (#882)
5
+
- Added scoped keyframes support (#346)
6
+
- Function values and function rules support now fallbacks, media queries, nesting, global styles (#682)
7
+
8
+
### Breaking changes
9
+
10
+
- Observables, function values and rules are now standalone packages, not part of the core. They are still part of the default preset though.
11
+
- Function values, rules and observables apply plugins by default now, which means they can support all plugin defined syntaxes, but they are also slower by default. To speed them up use `sheet.update(data, {process: false})` for fn values/rules and `jss.use(pluginObservable({process: false}))` when setting up observables plugin. (#682)
12
+
- Rule @keyframes has now scoped name by default, which means that you can access it using `$ref` from the same sheet and generate global one as before using `@global` rule ((#346).
13
+
- Options `createGenerateClassName` and `generateClassName` are renamed to `createGenerateId` and `generateId` since th same function is now used to scope @keyframes rules. This affects both JSS and React-JSS.
Copy file name to clipboardExpand all lines: docs/js-api.md
+6-6Lines changed: 6 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -32,7 +32,7 @@ export default jss
32
32
33
33
Options:
34
34
35
-
-`createGenerateClassName` - a function which returns a function which generates unique class names.
35
+
-`createGenerateId` - a function which returns a function which generates unique class names.
36
36
-`plugins` - an array of functions, will be passed to `jss.use`.
37
37
-`virtual` - if true, JSS will use VirtualRenderer.
38
38
-`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.
@@ -74,7 +74,7 @@ Options:
74
74
-`link` - link jss `Rule` instances with DOM `CSSRule` instances so that styles, can be modified dynamically, false by default because it has some performance cost.
75
75
-`element` - style element, will create one by default.
76
76
-`index` - 0 by default - determines DOM rendering order, higher number = higher specificity (inserted after).
77
-
-`generateClassName` - a function that generates a unique class name.
77
+
-`generateId` - a function that generates a unique class name.
78
78
-`classNamePrefix` - a string, which will be added at the beginning of the class name.
Option `createGenerateClassName` allows you to specify a function which returns a class name generator function `generateClassName(rule, sheet)`. This pattern is used to allow JSS reset the counter upon factory invocation, when needed. For example, it is used in [React-JSS](https://github.com/cssinjs/react-jss) to reset the counter on each request for server-side rendering.
363
+
Option `createGenerateId` allows you to specify a function which returns a class name generator function `generateId(rule, sheet)`. This pattern is used to allow JSS reset the counter upon factory invocation, when needed. For example, it is used in [React-JSS](https://github.com/cssinjs/react-jss) to reset the counter on each request for server-side rendering.
364
364
365
365
By default class names generator uses a simple counter to ensure uniqueness of the class names. It consists of `classNamePrefix` Style Sheet option + rule name + counter. **Note**: in production (`NODE_ENV=production`) it uses just the `c` + rules counter.
Copy file name to clipboardExpand all lines: docs/json-api.md
+23-80Lines changed: 23 additions & 80 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -22,72 +22,6 @@ Compiles to:
22
22
}
23
23
```
24
24
25
-
## Function values
26
-
27
-
If you want dynamic behavior for your Style Sheet, you can use functions as a value which return the actual value. If function values returns `null|undefined|false` - property will be removed. Use [sheet.update(data)](./js-api.md#update-function-values) in order to pass the data object. [Sheet option](./js-api.md#create-style-sheet)`link: true` is required for this to function.
28
-
29
-
```javascript
30
-
conststyles= {
31
-
button: {
32
-
color:data=>data.color
33
-
}
34
-
}
35
-
```
36
-
37
-
### Support of "!important"
38
-
39
-
To use the `!important` modifier with function values, you must use [array syntax](#alternative-syntax-for-space-and-comma-separated-values):
40
-
41
-
```javascript
42
-
conststyles= {
43
-
button: {
44
-
color:data=> [[data.color], '!important']
45
-
}
46
-
}
47
-
```
48
-
49
-
## Function rules
50
-
51
-
Similar to function values, you can use a function to return a dynamic style object. Use [sheet.update(data)](./js-api.md#update-function-values) in order to pass the data object. Sheet option `link: true` is required for this to function.
52
-
53
-
```javascript
54
-
conststyles= {
55
-
button:data=> ({
56
-
display:'flex',
57
-
color:data.color
58
-
})
59
-
}
60
-
```
61
-
62
-
## Observable values
63
-
64
-
In order to create highly dynamic animations, you may want to use streams. Take a look at the [tc39 observable proposal](https://github.com/tc39/proposal-observable). Sheet option `link: true` is required for this to function.
65
-
66
-
```javascript
67
-
conststyles= {
68
-
button: {
69
-
color:newObservable(observer=> {
70
-
observer.next('red')
71
-
})
72
-
}
73
-
}
74
-
```
75
-
76
-
## Observable rules
77
-
78
-
Similar to observable values, you can declare observable rules. Stream should contain in this case the style object. Sheet option `link: true` is required for this to function.
79
-
80
-
```javascript
81
-
conststyles= {
82
-
button:newObservable(observer=> {
83
-
observer.next({
84
-
color:'red',
85
-
opacity:1
86
-
})
87
-
})
88
-
}
89
-
```
90
-
91
25
## Media Queries
92
26
93
27
```javascript
@@ -135,41 +69,38 @@ Compiles to:
135
69
136
70
## Keyframes Animation
137
71
138
-
Note: keyframe id is still global and may conflict.
72
+
Keyframes name will use the same id generator function as the class names. Animation name will be scoped by default. In order to access it within the same style sheet, you can use `$ref` syntax as a value of `animationName` or `animation` property.
139
73
140
-
```javascript
141
-
conststyles= {
142
-
'@keyframes my-animation': {
143
-
from: {opacity:0},
144
-
to: {opacity:1}
145
-
}
146
-
}
147
-
```
74
+
Additionally generated name can be accessed through `sheet.keyframes.{name}` map.
148
75
149
-
### ES6 with generated keyframe id
76
+
In order to generate a global animation name, you can use `@global` rule.
150
77
151
78
```javascript
152
-
constanimationId=Math.random()
153
-
154
79
conststyles= {
155
-
[`@keyframes ${animationId}`]: {
80
+
'@keyframes slideRight': {
156
81
from: {opacity:0},
157
82
to: {opacity:1}
83
+
},
84
+
container: {
85
+
animationName:'$slideRight'
158
86
}
159
87
}
160
88
```
161
89
162
90
Compiles to:
163
91
164
92
```css
165
-
@keyframesmy-animation {
93
+
@keyframeskeyframes-slideRight-0-1-2 {
166
94
from {
167
95
opacity: 0;
168
96
}
169
97
to {
170
98
opacity: 1;
171
99
}
172
100
}
101
+
.container-0-1-3 {
102
+
animation-name: keyframes-slideRight-0-1-2;
103
+
}
173
104
```
174
105
175
106
## Fallbacks
@@ -421,6 +352,18 @@ Compiles to:
421
352
}
422
353
```
423
354
355
+
## Typed CSSOM (Houdini)
356
+
357
+
Typed CSSOM values are supported. You can learn more about them [here](https://developers.google.com/web/updates/2018/03/cssom) and track the standardization progress [here](https://ishoudinireadyyet.com/). Also make sure you use a [polyfill](https://github.com/csstools/css-typed-om) for browsers without support. It will make most sence when used together with function values and observables for frequent updates.
358
+
359
+
```javascript
360
+
conststyles= {
361
+
button: {
362
+
margin:CSS.px(10)
363
+
}
364
+
}
365
+
```
366
+
424
367
## Plugins
425
368
426
369
JSS plugins give you even more features, [read about them](plugins.md).
0 commit comments