Unverified Commit 8a308602 authored by Tim Neutkens's avatar Tim Neutkens Committed by GitHub

Remove deprecated library example (#62813)

## What?

Per the readme here: https://github.com/airbnb/react-with-styles#readme
the library is no longer used.

<!-- Thanks for opening a PR! Your contribution is much appreciated.
To make sure your PR is handled as smoothly as possible we request that
you follow the checklist sections below.
Choose the right checklist for the change(s) that you're making:

## For Contributors

### Improving Documentation

- Run `pnpm prettier-fix` to fix formatting issues before opening the
PR.
- Read the Docs Contribution Guide to ensure your contribution follows
the docs guidelines:
https://nextjs.org/docs/community/contribution-guide

### Adding or Updating Examples

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

### Fixing a bug

- Related issues linked using `fixes #number`
- Tests added. See:
https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md

### Adding a feature

- Implements an existing feature request or RFC. Make sure the feature
request has been accepted for implementation before opening a PR. (A
discussion must be opened, see
https://github.com/vercel/next.js/discussions/new?category=ideas)
- Related issues/discussions are linked using `fixes #number`
- e2e tests added
(https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs)
- Documentation added
- Telemetry added. In case of a feature if it's used or not.
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md


## For Maintainers

- Minimal description (aim for explaining to someone not on the team to
understand the PR)
- When linking to a Slack thread, you might want to share details of the
conclusion
- Link both the Linear (Fixes NEXT-xxx) and the GitHub issues
- Add review comments if necessary to explain to the reviewer the logic
behind a change

### What?

### Why?

### How?

Closes NEXT-
Fixes #

-->


Closes NEXT-2684
parent 83c09e5b
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
# dependencies
/node_modules
/.pnp
.pnp.js
.yarn/install-state.gz
# 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 react-with-styles
This example features how you 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 [react-with-styles](https://github.com/airbnb/react-with-styles).
For this purpose we are extending the `<Document />` and injecting the server side rendered styles into the `<head>`.
We are using `pages/_index.js` from this example [with-aphrodite](https://github.com/vercel/next.js/tree/canary/examples/with-aphrodite).
## Deploy your own
Deploy the example using [Vercel](https://vercel.com?utm_source=github&utm_medium=readme&utm_campaign=next-example) or preview live with [StackBlitz](https://stackblitz.com/github/vercel/next.js/tree/canary/examples/with-react-with-styles)
[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/clone?repository-url=https://github.com/vercel/next.js/tree/canary/examples/with-react-with-styles&project-name=with-react-with-styles&repository-name=with-react-with-styles)
## 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-react-with-styles with-react-with-styles-app
```
```bash
yarn create next-app --example with-react-with-styles with-react-with-styles-app
```
```bash
pnpm create next-app --example with-react-with-styles with-react-with-styles-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)).
export default {
color: {
primary: "salmon",
},
};
{
"private": true,
"scripts": {
"dev": "next",
"build": "next build",
"start": "next start"
},
"dependencies": {
"aphrodite": "^1.2.5",
"next": "latest",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-with-direction": "^1.3.1",
"react-with-styles": "^4.1.0",
"react-with-styles-interface-aphrodite": "^6.0.1"
}
}
import { DIRECTIONS } from "react-with-direction";
import AphroditeInterface from "react-with-styles-interface-aphrodite";
import WithStylesContext from "react-with-styles/lib/WithStylesContext";
import ThemedStyleSheet from "react-with-styles/lib/ThemedStyleSheet";
import defaultTheme from "../defaultTheme";
function MyApp(props) {
const { Component, pageProps } = props;
ThemedStyleSheet.registerInterface(AphroditeInterface);
return (
<WithStylesContext.Provider
value={{
stylesInterface: AphroditeInterface,
stylesTheme: defaultTheme,
direction: DIRECTIONS.LTR,
}}
>
<Component {...pageProps} />
</WithStylesContext.Provider>
);
}
export default MyApp;
import Document, { Html, Head, Main, NextScript } from "next/document";
import { StyleSheetServer } from "aphrodite";
class MyDocument extends Document {
static async getInitialProps({ renderPage }) {
const { html, css } = StyleSheetServer.renderStatic(() => renderPage());
const ids = css.renderedClassNames;
return { ...html, css, ids };
}
render() {
/* Make sure to use data-aphrodite attribute in the style tag here
so that aphrodite knows which style tag it's in control of when
the client goes to render styles. If you don't you'll get a second
<style> tag */
const { css, ids } = this.props;
return (
<Html>
<Head>
<style
data-aphrodite
dangerouslySetInnerHTML={{ __html: css.content }}
/>
</Head>
<body>
<Main />
<NextScript />
{ids && (
<script
dangerouslySetInnerHTML={{
__html: `
window.__REHYDRATE_IDS = ${JSON.stringify(ids)}
`,
}}
/>
)}
</body>
</Html>
);
}
}
export default MyDocument;
import { css, withStyles } from "react-with-styles";
function Home({ styles }) {
return (
<div>
<h1 {...css(styles.title)}>My page</h1>
</div>
);
}
export default withStyles(({ color }) => ({
title: {
color: color.primary,
},
}))(Home);
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