Unverified Commit 7dd1fcfc authored by Jam Balaya's avatar Jam Balaya Committed by GitHub

chore(examples): remove `with-styletron` example (#81842)

## Summary

Remove
[with-styletron](https://github.com/vercel/next.js/tree/canary/examples/with-styletron)
example and its references from the repository.

Documentation:
- Remove the Styletron link from the CSS-in-JS examples list in the docs

Tests:
- Remove the Styletron entry from the
turbopack-dev-examples-manifest.json

Chores:
- Delete the examples/with-styletron directory and its contents

## Why?

[styletron](https://github.com/styletron/styletron) package hasn't been
maintained in 2 years.

## Adding or Updating Examples

- [x] The "examples guidelines" are followed from our contributing doc
https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md
- [x] Make sure the linting passes by running `pnpm build && pnpm lint`.
See
https://github.com/vercel/next.js/blob/canary/contributing/repository/linting.md

cc: @samcx
Co-authored-by: 's avatarJoseph <joseph.chamochumbi@vercel.com>
parent b55dc5f0
......@@ -258,7 +258,6 @@ export default function RootLayout({ children }) {
- [Styled Components](https://github.com/vercel/next.js/tree/canary/examples/with-styled-components)
- [Emotion](https://github.com/vercel/next.js/tree/canary/examples/with-emotion)
- [Linaria](https://github.com/vercel/next.js/tree/canary/examples/with-linaria)
- [Styletron](https://github.com/vercel/next.js/tree/canary/examples/with-styletron)
- [Cxs](https://github.com/vercel/next.js/tree/canary/examples/with-cxs)
- [Fela](https://github.com/vercel/next.js/tree/canary/examples/with-fela)
- [Stitches](https://github.com/vercel/next.js/tree/canary/examples/with-stitches)
......
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
# dependencies
/node_modules
/.pnp
.pnp.*
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/versions
# testing
/coverage
# next.js
/.next/
/out/
# production
/build
# misc
.DS_Store
*.pem
# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# local env files
.env*.local
# vercel
.vercel
# typescript
*.tsbuildinfo
next-env.d.ts
# Example app with styletron
This example features how yo use a different styling solution than [styled-jsx](https://github.com/vercel/styled-jsx) that also supports universal styles. That means we can serve the required styles for the first render within the HTML and then load the rest in the client. In this case we are using [styletron](https://github.com/rtsao/styletron).
For this purpose we wrap the root layout with the [`Provider`](https://styletron.org/api-reference#provider).
## Deploy your own
[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/clone?repository-url=https://github.com/vercel/next.js/tree/canary/examples/with-styletron&project-name=with-styletron&repository-name=with-styletron)
## How to use
Execute [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app) with [npm](https://docs.npmjs.com/cli/init), [Yarn](https://yarnpkg.com/lang/en/docs/cli/create/), or [pnpm](https://pnpm.io) to bootstrap the example:
```bash
npx create-next-app --example with-styletron with-styletron-app
```
```bash
yarn create next-app --example with-styletron with-styletron-app
```
```bash
pnpm create next-app --example with-styletron with-styletron-app
```
Deploy it to the cloud with [Vercel](https://vercel.com/new?utm_source=github&utm_medium=readme&utm_campaign=next-example) ([Documentation](https://nextjs.org/docs/deployment)).
"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>
);
}
// DOCUMENTATION: http://styletron.org
"use client";
import { styled, useStyletron } from "styletron-react";
// Statically styled component
const Title = styled("h1", {
color: "red",
fontSize: "82px",
});
// Dynamically styled component
const SubTitle = styled("h2", ({ $size }: { $size: number }) => ({
color: "blue",
fontSize: `${$size}px`,
}));
export default function Home() {
// An alternative hook-based API
const [css] = useStyletron();
return (
<div>
<Title>Title</Title>
<SubTitle $size={50}>Subtitle</SubTitle>
<p className={css({ fontSize: "32px" })}>Styled by hook</p>
</div>
);
}
/** @type {import('next').NextConfig} */
module.exports = {
webpack: function (config) {
config.externals = config.externals || {};
config.externals["styletron-server"] = "styletron-server";
return config;
},
};
{
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start"
},
"dependencies": {
"next": "latest",
"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"
}
}
import { Client, Server } from "styletron-engine-atomic";
const getHydrateClass = () =>
document.getElementsByClassName("_styletron_hydrate_");
export const styletron =
typeof window === "undefined"
? new Server()
: new Client({
hydrate: getHydrateClass(),
});
{
"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": "react-jsx",
"plugins": [
{
"name": "next"
}
]
},
"include": ["next-env.d.ts", ".next/types/**/*.ts", "**/*.ts", "**/*.tsx"],
"exclude": ["node_modules"]
}
......@@ -167,7 +167,6 @@
"with-stripe-typescript": true,
"with-styled-components": true,
"with-styled-jsx": true,
"with-styletron": true,
"with-supabase": true,
"with-supertokens": true,
"with-three-js": true,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment