Skip to content

Commit 088ad28

Browse files
authored
Convert plugin examples to codesandbox (#1316)
* Migrate plugin examples to codesandbox * Fix examples * Add links to plugin examples
1 parent 3f35178 commit 088ad28

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+616
-3
lines changed

docs/jss-plugin-camel-case.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,7 @@ Compiles to:
1919
font-size: 12px;
2020
}
2121
```
22+
23+
### Demo
24+
25+
[CodeSandbox](//codesandbox.io/s/github/cssinjs/jss/tree/master/examples/plugins/jss-plugin-camel-case?fontsize=14)

docs/jss-plugin-compose.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,3 +179,7 @@ It renders to:
179179
- It doesn't work within [global Style Sheets](https://github.com/cssinjs/jss/tree/master/packages/jss-plugin-global).
180180
- It does not work inside of [nested rules](https://github.com/cssinjs/jss/tree/master/packages/jss-plugin-nested).
181181
- When composing local rules, they need to be defined first. Otherwise, you get wrong CSS selector order and specificity.
182+
183+
### Demo
184+
185+
[CodeSandbox](//codesandbox.io/s/github/cssinjs/jss/tree/master/examples/plugins/jss-plugin-compose?fontsize=14)

docs/jss-plugin-default-unit.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,7 @@ Compiles to:
6060
z-index: 1;
6161
}
6262
```
63+
64+
### Demo
65+
66+
[CodeSandbox](//codesandbox.io/s/github/cssinjs/jss/tree/master/examples/plugins/jss-plugin-default-unit?fontsize=14)

docs/jss-plugin-expand.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -400,3 +400,7 @@ const styles = {
400400
}
401401
}
402402
```
403+
404+
### Demo
405+
406+
[CodeSandbox](//codesandbox.io/s/github/cssinjs/jss/tree/master/examples/plugins/jss-plugin-expand?fontsize=14)

docs/jss-plugin-extend.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,5 +76,4 @@ const styles = {
7676

7777
### Demo
7878

79-
[Simple demo](http://cssinjs.github.io/examples/plugins/jss-extend/simple/)
80-
[Multi objects demo](http://cssinjs.github.io/examples/plugins/jss-extend/multi/)
79+
[CodeSandbox](//codesandbox.io/s/github/cssinjs/jss/tree/master/examples/plugins/jss-plugin-extend?fontsize=14)

docs/jss-plugin-global.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,3 +73,7 @@ Compiles to:
7373
color: red;
7474
}
7575
```
76+
77+
### Demo
78+
79+
[CodeSandbox](//codesandbox.io/s/github/cssinjs/jss/tree/master/examples/plugins/jss-plugin-global?fontsize=14)

docs/jss-plugin-isolate.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ jss.use(
183183

184184
### Demo
185185

186-
[Simple](http://cssinjs.github.io/examples/plugins/jss-plugin-isolate/simple/index.html)
186+
[CodeSandbox](//codesandbox.io/s/github/cssinjs/jss/tree/master/examples/plugins/jss-plugin-isolate?fontsize=14)
187187

188188
### Reseted properties
189189

docs/jss-plugin-nested.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,3 +142,7 @@ Compiles to:
142142
background: red;
143143
}
144144
```
145+
146+
### Demo
147+
148+
[CodeSandbox](//codesandbox.io/s/github/cssinjs/jss/tree/master/examples/plugins/jss-plugin-nested?fontsize=14)

docs/jss-plugin-props-sort.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,7 @@ Compiles to:
1919
border-left: 1px solid red;
2020
}
2121
```
22+
23+
### Demo
24+
25+
[CodeSandbox](//codesandbox.io/s/github/cssinjs/jss/tree/master/examples/plugins/jss-plugin-props-sort?fontsize=14)

docs/jss-plugin-rule-value-function.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,3 +66,7 @@ const sheet = jss
6666

6767
sheet.update({color: 'red'})
6868
```
69+
70+
### Demo
71+
72+
[CodeSandbox](//codesandbox.io/s/github/cssinjs/jss/tree/master/examples/plugins/jss-plugin-rule-value-function?fontsize=14)

docs/jss-plugin-rule-value-observable.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,3 +71,7 @@ jss.setup(
7171
})
7272
)
7373
```
74+
75+
### Demo
76+
77+
[CodeSandbox](//codesandbox.io/s/github/cssinjs/jss/tree/master/examples/plugins/jss-plugin-rule-value-observable?fontsize=14)

docs/jss-plugin-template.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,7 @@ const styles = {
2424
}
2525
}
2626
```
27+
28+
### Demo
29+
30+
[CodeSandbox](//codesandbox.io/s/github/cssinjs/jss/tree/master/examples/plugins/jss-plugin-template?fontsize=14)

docs/jss-plugin-vendor-prefixer.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,7 @@ Compiles to:
1919
transform: -webkit-translateX(100px);
2020
}
2121
```
22+
23+
### Demo
24+
25+
[CodeSandbox](//codesandbox.io/s/github/cssinjs/jss/tree/master/examples/plugins/jss-plugin-vendor-prefixer?fontsize=14)
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import jss from 'jss'
2+
import jssPluginCamelCase from 'jss-plugin-camel-case'
3+
4+
const styles = {
5+
button: {
6+
fontSize: '50px',
7+
zIndex: 1,
8+
lineHeight: 1.2
9+
}
10+
}
11+
12+
// JSS Setup
13+
jss.use(jssPluginCamelCase())
14+
const {classes} = jss.createStyleSheet(styles).attach()
15+
16+
// Application logic.
17+
const div = document.body.appendChild(document.createElement('div'))
18+
div.innerHTML = `<button class="${classes.button}">Button</button>`
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>Example - jss-plugin-camel-case</title>
5+
<meta charset="UTF-8" />
6+
</head>
7+
<body>
8+
<div id="app"></div>
9+
<script src="app.js"></script>
10+
</body>
11+
</html>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"name": "jss-plugin-camel-case-example",
3+
"license": "ISC",
4+
"dependencies": {
5+
"jss": "^10.0.3",
6+
"jss-plugin-camel-case": "10.1.1"
7+
},
8+
"devDependencies": {
9+
"parcel-bundler": "^1.6.1"
10+
}
11+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import jss from 'jss'
2+
import jssPluginCompose from 'jss-plugin-compose'
3+
4+
const styles = {
5+
button: {
6+
composes: 'btn btn-primary',
7+
color: 'red'
8+
},
9+
buttonActive: {
10+
composes: ['btn', 'btn-primary'],
11+
color: 'blue'
12+
},
13+
buttonActiveDisabled: {
14+
composes: '$buttonActive',
15+
opacity: 0.5
16+
}
17+
}
18+
19+
// JSS Setup
20+
jss.use(jssPluginCompose())
21+
const {classes} = jss.createStyleSheet(styles).attach()
22+
23+
// Application logic.
24+
const div = document.body.appendChild(document.createElement('div'))
25+
div.innerHTML = `
26+
<button class="${classes.button}">Button</button>
27+
<button class="${classes.buttonActive}">Active Button</button>
28+
<button class="${classes.buttonActiveDisabled}">Disabled Active Button</button>
29+
`
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>Example - jss-plugin-compose</title>
5+
<meta charset="UTF-8" />
6+
</head>
7+
<body>
8+
<div id="app"></div>
9+
<script src="app.js"></script>
10+
</body>
11+
</html>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"name": "jss-plugin-compose-example",
3+
"license": "ISC",
4+
"dependencies": {
5+
"jss": "^10.0.3",
6+
"jss-plugin-compose": "10.1.1"
7+
},
8+
"devDependencies": {
9+
"parcel-bundler": "^1.6.1"
10+
}
11+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import jss from 'jss'
2+
import jssPluginDefaultUnit from 'jss-plugin-default-unit'
3+
4+
const styles = {
5+
button: {
6+
'font-size': 20,
7+
'z-index': 1,
8+
'line-height': 2
9+
}
10+
}
11+
12+
// JSS Setup
13+
jss.use(jssPluginDefaultUnit())
14+
const {classes} = jss.createStyleSheet(styles).attach()
15+
16+
// Application logic.
17+
const div = document.body.appendChild(document.createElement('div'))
18+
div.innerHTML = `<button class="${classes.button}">Button</button>`
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>Example - jss-plugin-default-unit</title>
5+
<meta charset="UTF-8" />
6+
</head>
7+
<body>
8+
<div id="app"></div>
9+
<script src="app.js"></script>
10+
</body>
11+
</html>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"name": "jss-plugin-default-unit-example",
3+
"license": "ISC",
4+
"dependencies": {
5+
"jss": "^10.0.3",
6+
"jss-plugin-default-unit": "10.1.1"
7+
},
8+
"devDependencies": {
9+
"parcel-bundler": "^1.6.1"
10+
}
11+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import jss from 'jss'
2+
import jssPluginExpand from 'jss-plugin-expand'
3+
4+
const styles = {
5+
button: {
6+
border: {
7+
color: 'black',
8+
width: 1,
9+
style: 'solid'
10+
}
11+
}
12+
}
13+
14+
// JSS Setup
15+
jss.use(jssPluginExpand())
16+
const {classes} = jss.createStyleSheet(styles).attach()
17+
18+
// Application logic.
19+
const div = document.body.appendChild(document.createElement('div'))
20+
div.innerHTML = `<button class="${classes.button}">Button</button>`
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>Example - jss-plugin-expand</title>
5+
<meta charset="UTF-8" />
6+
</head>
7+
<body>
8+
<div id="app"></div>
9+
<script src="app.js"></script>
10+
</body>
11+
</html>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"name": "jss-plugin-expand-example",
3+
"license": "ISC",
4+
"dependencies": {
5+
"jss": "^10.0.3",
6+
"jss-plugin-expand": "10.1.1"
7+
},
8+
"devDependencies": {
9+
"parcel-bundler": "^1.6.1"
10+
}
11+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import jss from 'jss'
2+
import jssPluginExtend from 'jss-plugin-extend'
3+
4+
const button0 = {
5+
padding: '20px',
6+
background: 'blue'
7+
}
8+
9+
const redButton = {
10+
background: 'red'
11+
}
12+
13+
const styles = {
14+
button0,
15+
button1: {
16+
extend: [button0, redButton],
17+
'font-size': '20px'
18+
}
19+
}
20+
21+
// JSS Setup
22+
jss.use(jssPluginExtend())
23+
const {classes} = jss.createStyleSheet(styles).attach()
24+
25+
// Application logic.
26+
const div = document.body.appendChild(document.createElement('div'))
27+
div.innerHTML = `\
28+
<button class="${classes.button0}">Button 1</button>\
29+
<button class="${classes.button1}">Button 2</button>\
30+
`
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>Example - jss-plugin-extend</title>
5+
<meta charset="UTF-8" />
6+
</head>
7+
<body>
8+
<div id="app"></div>
9+
<script src="app.js"></script>
10+
</body>
11+
</html>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"name": "jss-plugin-extend-example",
3+
"license": "ISC",
4+
"dependencies": {
5+
"jss": "^10.0.3",
6+
"jss-plugin-extend": "10.1.1"
7+
},
8+
"devDependencies": {
9+
"parcel-bundler": "^1.6.1"
10+
}
11+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import jss from 'jss'
2+
import jssPluginGlobal from 'jss-plugin-global'
3+
4+
const styles = {
5+
'@global': {
6+
body: {
7+
background: 'green'
8+
},
9+
button: {
10+
background: 'yellow'
11+
}
12+
}
13+
}
14+
15+
// JSS Setup
16+
jss.use(jssPluginGlobal())
17+
jss.createStyleSheet(styles).attach()
18+
19+
// Application logic.
20+
const div = document.body.appendChild(document.createElement('div'))
21+
div.innerHTML = `<button>Button</button>`
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>Example - jss-plugin-global</title>
5+
<meta charset="UTF-8" />
6+
</head>
7+
<body>
8+
<div id="app"></div>
9+
<script src="app.js"></script>
10+
</body>
11+
</html>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"name": "jss-plugin-global-example",
3+
"license": "ISC",
4+
"dependencies": {
5+
"jss": "^10.0.3",
6+
"jss-plugin-global": "10.1.1"
7+
},
8+
"devDependencies": {
9+
"parcel-bundler": "^1.6.1"
10+
}
11+
}

0 commit comments

Comments
 (0)