Skip to content

Commit 6ccdd2e

Browse files
authored
Merge pull request #46 from eryue0220/feat/solid-example
feat: add solid-example
2 parents 200666e + 300c9e5 commit 6ccdd2e

File tree

13 files changed

+271
-8
lines changed

13 files changed

+271
-8
lines changed

examples/esbuild-example/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
{
22
"name": "esbuild-example",
3-
"version": "0.0.1",
43
"private": true,
54
"scripts": {
65
"build": "node scripts/build.mjs",

examples/farm-example/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
{
22
"name": "farm-example",
3-
"version": "0.0.1",
43
"private": true,
54
"type": "module",
65
"scripts": {

examples/rollup-example/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
{
22
"name": "rollup-example",
3-
"version": "0.0.1",
43
"private": true,
54
"type": "module",
65
"scripts": {

examples/rsbuild-example/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
{
22
"name": "rsbuild-example",
3-
"version": "0.0.1",
43
"private": true,
54
"scripts": {
65
"dev": "rsbuild dev",

examples/rspack-example/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
{
22
"name": "rspack-example",
3-
"version": "0.0.1",
43
"private": true,
54
"scripts": {
65
"dev": "rspack serve",

examples/solid-example/index.html

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
4+
<head>
5+
<meta charset="UTF-8">
6+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
7+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
8+
<title>StyleX with Solid</title>
9+
<style>
10+
@layer reset {
11+
body {
12+
box-sizing: border-box;
13+
padding: 0;
14+
margin: 0;
15+
}
16+
}
17+
</style>
18+
</head>
19+
20+
<body>
21+
<div id="root"></div>
22+
<script type="module" src="./src/index.jsx"></script>
23+
</body>
24+
25+
</html>

examples/solid-example/package.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"name": "solid-example",
3+
"private": true,
4+
"type": "module",
5+
"scripts": {
6+
"dev": "vite",
7+
"build": "vite build"
8+
},
9+
"dependencies": {
10+
"@stylexjs/open-props": "^0.6.0",
11+
"@stylexjs/stylex": "^0.6.0",
12+
"solid-js": "^1.8.18"
13+
},
14+
"devDependencies": {
15+
"unplugin-stylex": "workspace:*",
16+
"vite": "^5.3.3",
17+
"vite-plugin-solid": "^2.10.2"
18+
}
19+
}

examples/solid-example/src/index.jsx

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import { render } from 'solid-js/web'
2+
import * as stylex from '@stylexjs/stylex'
3+
import { colors } from '@stylexjs/open-props/lib/colors.stylex'
4+
import { sizes } from '@stylexjs/open-props/lib/sizes.stylex'
5+
import { fonts } from '@stylexjs/open-props/lib/fonts.stylex'
6+
7+
const styles = stylex.create({
8+
main: {
9+
width: '100vw',
10+
height: '100vh',
11+
display: 'flex',
12+
alignItems: 'center',
13+
justifyContent: 'center',
14+
backgroundColor: colors.pink7,
15+
},
16+
card: {
17+
backgroundColor: colors.blue9,
18+
padding: sizes.spacing5,
19+
borderRadius: sizes.spacing2,
20+
justifyContent: 'center',
21+
display: 'flex',
22+
alignItems: 'center',
23+
color: colors.gray0,
24+
fontFamily: fonts.mono,
25+
},
26+
})
27+
28+
function App() {
29+
return (
30+
<div {...stylex.props(styles.main)}>
31+
<div {...stylex.props(styles.card)}>
32+
<span>Blue rounded rectangle</span>
33+
</div>
34+
</div>
35+
)
36+
}
37+
38+
const root = document.getElementById('root')
39+
40+
if (root) {
41+
render(() => <App />, root)
42+
}

examples/solid-example/vite.config.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { defineConfig } from 'vite'
2+
import solid from 'vite-plugin-solid'
3+
import stylexVitePlugin from 'unplugin-stylex/vite'
4+
5+
export default defineConfig({
6+
build: {
7+
outDir: 'dist'
8+
},
9+
plugins: [
10+
solid(),
11+
stylexVitePlugin({
12+
dev: true,
13+
stylex: {
14+
useCSSLayers: true,
15+
genConditionalClasses: true,
16+
treeshakeCompensation: true,
17+
},
18+
}),
19+
],
20+
})

examples/vite-example/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
{
22
"name": "vite-example",
3-
"version": "0.0.1",
43
"private": true,
54
"scripts": {
65
"dev": "vite",

0 commit comments

Comments
 (0)