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

feat: add @stylexjs/stylex example #286

Merged
merged 16 commits into from
Dec 21, 2023
4 changes: 3 additions & 1 deletion examples/12_css/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
},
"dependencies": {
"@hono/node-server": "1.3.3",
"@stylexjs/stylex": "^0.3.0",
himself65 marked this conversation as resolved.
Show resolved Hide resolved
"hono": "3.11.7",
"react": "18.3.0-canary-0cdfef19b-20231211",
"react-dom": "18.3.0-canary-0cdfef19b-20231211",
Expand All @@ -24,6 +25,7 @@
"@vanilla-extract/vite-plugin": "3.9.3",
"@vitejs/plugin-react": "4.2.1",
"typescript": "5.3.3",
"vite": "5.0.9"
"vite": "5.0.9",
"vite-plugin-stylex": "^0.4.0"
himself65 marked this conversation as resolved.
Show resolved Hide resolved
}
}
2 changes: 2 additions & 0 deletions examples/12_css/src/components/App.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
@stylex stylesheet;

h1 {
color: red;
}
2 changes: 2 additions & 0 deletions examples/12_css/src/components/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import styles from './App.module.css';
import './App.css';
import { container } from './styles.css.js';
import { Counter } from './Counter.js';
import { Banner } from './Banner.js';

const App = ({ name }: { name: string }) => {
return (
Expand All @@ -11,6 +12,7 @@ const App = ({ name }: { name: string }) => {
<h1 className={styles.title}>Hello {name}!!</h1>
<h3 className={container}>This is a server component.</h3>
<Counter />
<Banner />
</div>
);
};
Expand Down
14 changes: 14 additions & 0 deletions examples/12_css/src/components/Banner.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { create, props } from '@stylexjs/stylex';

const styles = create({
root: {
backgroundColor: '#000',
color: '#fff',
padding: '10px',
textAlign: 'center',
},
});

export const Banner = () => {
return <div {...props(styles.root)}>This is a banner by StyleX CSS</div>;
};
6 changes: 5 additions & 1 deletion examples/12_css/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import { defineConfig } from 'vite';
import { vanillaExtractPlugin } from '@vanilla-extract/vite-plugin';
import styleX from 'vite-plugin-stylex';

export default defineConfig({
plugins: [vanillaExtractPlugin({ emitCssInSsr: true })],
ssr: {
external: ['@stylexjs/stylex'],
},
himself65 marked this conversation as resolved.
Show resolved Hide resolved
plugins: [vanillaExtractPlugin({ emitCssInSsr: true }), styleX()],
});
90 changes: 90 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading