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

updated with-styletron example to utilize the app router. #73252

Merged
merged 15 commits into from
Nov 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
18 changes: 18 additions & 0 deletions examples/with-styletron/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
"use client";

import { Provider as StyletronProvider } from "styletron-react";
import { styletron } from "../styletron";

export default function RootLayout({
children,
}: Readonly<{
children: React.ReactNode;
}>) {
return (
<html lang="en">
<StyletronProvider value={styletron}>
<body>{children}</body>
</StyletronProvider>
</html>
);
}
Original file line number Diff line number Diff line change
@@ -1,22 +1,25 @@
// DOCUMENTATION: http://styletron.org

"use client";

import { styled, useStyletron } from "styletron-react";

// statically styled component
// Statically styled component
const Title = styled("h1", {
color: "red",
fontSize: "82px",
});

// dynamically styled component
const SubTitle = styled("h2", ({ $size }) => ({
// Dynamically styled component
const SubTitle = styled("h2", ({ $size }: { $size: number }) => ({
color: "blue",
fontSize: `${$size}px`,
}));

export default function Home() {
// an alternative hook based API
// An alternative hook-based API
const [css] = useStyletron();

return (
<div>
<Title>Title</Title>
Expand Down
15 changes: 10 additions & 5 deletions examples/with-styletron/package.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
{
"private": true,
"scripts": {
"dev": "next",
"dev": "next dev",
"build": "next build",
"start": "next start"
},
"dependencies": {
"next": "latest",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"styletron-engine-atomic": "1.4.6",
"styletron-react": "6.1.0"
"react": "^18.3.1",
"react-dom": "^18.3.1",
"styletron-engine-atomic": "^1.6.2",
"styletron-react": "^6.1.1"
},
"devDependencies": {
"@types/node": "^22.10.0",
"@types/react": "^18.3.12",
"typescript": "^5.7.2"
}
}
10 changes: 0 additions & 10 deletions examples/with-styletron/pages/_app.js

This file was deleted.

47 changes: 0 additions & 47 deletions examples/with-styletron/pages/_document.js

This file was deleted.

24 changes: 24 additions & 0 deletions examples/with-styletron/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"compilerOptions": {
"target": "ES2017",
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
"strict": false,
"noEmit": true,
"incremental": true,
"module": "esnext",
"esModuleInterop": true,
"moduleResolution": "bundler",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve",
"plugins": [
{
"name": "next"
}
]
},
"include": ["next-env.d.ts", ".next/types/**/*.ts", "**/*.ts", "**/*.tsx"],
"exclude": ["node_modules"]
}
Loading