forked from geist-org/geist-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support for render styles to html on the server side (geist-org…
…#738) * feat: support for render styles to html on the server side * chore: release v2.3.2 * docs(examples): add example for remix
- Loading branch information
Showing
16 changed files
with
171 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Remix demo for Geist UI | ||
|
||
## Getting Started | ||
|
||
First, run the development server: | ||
|
||
```bash | ||
npm run dev | ||
# or | ||
yarn dev | ||
``` | ||
|
||
Open [http://localhost:3000](http://localhost:3000) with your browser to see the result. | ||
|
||
You can start editing the page by modifying `app/routes/index.tsx`. The page auto-updates as you edit the file. | ||
|
||
## Learn More | ||
|
||
To learn more about Remix, take a look at the following resources: | ||
|
||
- [Remix v1](https://remix.run/docs/en/v1) - learn about Next.js features and API. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
const { createRequestHandler } = require('@remix-run/vercel') | ||
|
||
module.exports = createRequestHandler({ | ||
build: require('./_build'), | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import { hydrate } from 'react-dom' | ||
import { RemixBrowser } from 'remix' | ||
|
||
hydrate(<RemixBrowser />, document) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { renderToString } from 'react-dom/server' | ||
import { RemixServer } from 'remix' | ||
import type { EntryContext } from 'remix' | ||
import { CssBaseline } from '@geist-ui/core' | ||
|
||
export default function handleRequest( | ||
request: Request, | ||
responseStatusCode: number, | ||
responseHeaders: Headers, | ||
remixContext: EntryContext, | ||
) { | ||
let markup = renderToString(<RemixServer context={remixContext} url={request.url} />) | ||
markup = markup.replace('__STYLES__', CssBaseline.flushToHTML()) | ||
|
||
responseHeaders.set('Content-Type', 'text/html') | ||
|
||
return new Response('<!DOCTYPE html>' + markup, { | ||
status: responseStatusCode, | ||
headers: responseHeaders, | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { Links, LiveReload, Meta, Outlet, Scripts, ScrollRestoration } from 'remix' | ||
import type { MetaFunction } from 'remix' | ||
import { CssBaseline, GeistProvider } from '@geist-ui/core' | ||
|
||
export const meta: MetaFunction = () => { | ||
return { title: 'Geist with Remix' } | ||
} | ||
|
||
export default function App() { | ||
return ( | ||
<html lang="en"> | ||
<head> | ||
<meta charSet="utf-8" /> | ||
<meta name="viewport" content="width=device-width,initial-scale=1" /> | ||
<Meta /> | ||
<Links /> | ||
{typeof document === 'undefined' ? '__STYLES__' : null} | ||
</head> | ||
<body> | ||
<GeistProvider> | ||
<CssBaseline /> | ||
<Outlet /> | ||
</GeistProvider> | ||
<ScrollRestoration /> | ||
<Scripts /> | ||
{process.env.NODE_ENV === 'development' && <LiveReload />} | ||
</body> | ||
</html> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { Card, Page, Text } from '@geist-ui/core' | ||
|
||
export default function Index() { | ||
return ( | ||
<Page> | ||
<Card> | ||
<Text>Hello, Geist with Remix</Text> | ||
</Card> | ||
</Page> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
{ | ||
"name": "geist-remix", | ||
"license": "MIT", | ||
"scripts": { | ||
"build": "remix build", | ||
"dev": "remix dev", | ||
"postinstall": "remix setup node" | ||
}, | ||
"prettier": "@geist-ui/prettier-config", | ||
"dependencies": { | ||
"@geist-ui/core": "latest", | ||
"@remix-run/react": "^1.1.3", | ||
"@remix-run/serve": "^1.1.3", | ||
"@remix-run/vercel": "^1.1.3", | ||
"react": "^17.0.2", | ||
"react-dom": "^17.0.2", | ||
"remix": "^1.1.3" | ||
}, | ||
"devDependencies": { | ||
"@geist-ui/prettier-config": "^1.0.1", | ||
"@remix-run/dev": "^1.1.3", | ||
"@types/react": "^17.0.24", | ||
"@types/react-dom": "^17.0.9", | ||
"prettier": "^2.5.1", | ||
"typescript": "^4.1.2" | ||
}, | ||
"engines": { | ||
"node": ">=14" | ||
}, | ||
"sideEffects": false | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/** | ||
* @type {import('@remix-run/dev/config').AppConfig} | ||
*/ | ||
module.exports = { | ||
appDirectory: 'app', | ||
assetsBuildDirectory: 'public/build', | ||
publicPath: '/build/', | ||
serverBuildDirectory: 'api/_build', | ||
ignoredRouteFiles: ['.*'], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/// <reference types="@remix-run/dev" /> | ||
/// <reference types="@remix-run/node/globals" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"include": ["remix.env.d.ts", "**/*.ts", "**/*.tsx"], | ||
"compilerOptions": { | ||
"lib": ["DOM", "DOM.Iterable", "ES2019"], | ||
"isolatedModules": true, | ||
"esModuleInterop": true, | ||
"jsx": "react-jsx", | ||
"moduleResolution": "node", | ||
"resolveJsonModule": true, | ||
"target": "ES2019", | ||
"strict": true, | ||
"baseUrl": ".", | ||
"paths": { | ||
"~/*": ["./app/*"] | ||
}, | ||
|
||
// Remix takes care of building everything in `remix build`. | ||
"noEmit": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"build": { | ||
"env": { | ||
"ENABLE_FILE_SYSTEM_API": "1" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
import { server } from './styled-jsx.es' | ||
const { flushToHTML } = server | ||
|
||
export { server } | ||
export { server, flushToHTML } | ||
export default server |