Unverified Commit ba81b6ab authored by Sam Robbins's avatar Sam Robbins Committed by GitHub

Delete examples/with-style-sheet directory (#23609)

The underlying package [style-sheet](https://github.com/giuseppeg/style-sheet) has been archived, and the example doesn't currently work, so I think it's better deleted. Closes part of issue #23607 


## Documentation / Examples

- [x] Make sure the linting passes
parent 2ed54cdd
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
# dependencies
/node_modules
/.pnp
.pnp.js
# 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
.env.development.local
.env.test.local
.env.production.local
# vercel
.vercel
# Using the style-sheet CSS in JS library and extract CSS to file.
This example features an app using the [style-sheet](https://www.npmjs.com/package/style-sheet) CSS in JS library and demonstrates how it is possible to extract styles to file.
## Deploy your own
Deploy the example using [Vercel](https://vercel.com?utm_source=github&utm_medium=readme&utm_campaign=next-example):
[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/git/external?repository-url=https://github.com/vercel/next.js/tree/canary/examples/with-style-sheet&project-name=with-style-sheet&repository-name=with-style-sheet)
## 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) or [Yarn](https://yarnpkg.com/lang/en/docs/cli/create/) to bootstrap the example:
```bash
npx create-next-app --example with-style-sheet with-style-sheet-app
# or
yarn create next-app --example with-style-sheet with-style-sheet-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)).
const path = require('path')
module.exports = {
presets: [
[
'next/babel',
{
'preset-react': {
pragma: 'createElement',
},
},
],
],
plugins: [
[
'style-sheet/babel',
{
stylePropName: 'css',
stylePropPackageName: path.resolve('./lib/styleSheet.js'),
},
],
],
}
const StyleSheet = require('style-sheet')
const setup = require('style-sheet/lib/cjs/createElement')
const stylePropName = 'css'
module.exports.createElement = setup(StyleSheet, stylePropName)
const getCss = require('style-sheet/babel').getCss
const { RawSource } = require('webpack-sources')
class StyleSheetPlugin {
apply(compiler) {
compiler.hooks.emit.tap('StyleSheetPlugin', (compilation) => {
compilation.assets['static/bundle.css'] = new RawSource(getCss())
})
}
}
module.exports = {
webpack: (config, options) => {
config.plugins.push(new StyleSheetPlugin())
return config
},
}
{
"name": "with-style-sheet",
"version": "1.0.0",
"description": "This example features: style-sheet a CSS in JS library with static CSS extraction support.",
"main": "index.js",
"scripts": {
"dev": "next",
"build": "next build",
"start": "next start"
},
"dependencies": {
"next": "latest",
"react": "^16.7.0",
"react-dom": "^16.7.0",
"style-sheet": "^4.0.4"
},
"author": "Giuseppe Gurgone",
"license": "MIT"
}
import Document, { Html, Head, Main, NextScript } from 'next/document'
export default class MyDocument extends Document {
render() {
return (
<Html>
<Head>
<style>{`body { margin: 0 }`}</style>
<link
id="__style_sheet_extracted__"
rel="stylesheet"
href="/_next/static/bundle.css"
/>
</Head>
<body>
<Main />
<NextScript />
</body>
</Html>
)
}
}
import { useState, useEffect } from 'react'
import { StyleSheet, StyleResolver } from 'style-sheet'
const cls = StyleResolver.resolve
export default function Home() {
const [color, setColor] = useState('#111')
useEffect(() => {
setTimeout(() => {
setColor('#00f')
}, 2000)
})
return (
<div
className={cls([styles.root, styles.another])}
css={{
color,
}}
>
<div>
Hello from <span className={cls(styles.brand)}>Next.js</span>
</div>
</div>
)
}
const styles = StyleSheet.create({
root: {
fontSize: 16,
fontFamily: 'sans-serif',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
minHeight: '100vh',
backgroundImage:
'radial-gradient(circle, #D7D7D7, #D7D7D7 1px, #FFF 1px, #FFF)',
backgroundSize: '1em 1em',
},
another: {
fontSize: 30,
},
brand: {
fontWeight: 'bold',
},
})
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