Unverified Commit dbb63850 authored by arshad's avatar arshad Committed by GitHub

feat: add with-reflexjs example (#24068)

This PR adds an example for using Next.js with [Reflexjs](https://reflexjs.org).

Thank You

## Documentation / Examples

- [x] Make sure the linting passes
parent efb2b8b0
{
"presets": [
[
"next/babel",
{
"preset-react": {
"runtime": "automatic",
"importSource": "reflexjs"
}
}
]
]
}
# 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
# Next.js + Reflexjs Example
Reflexjs is a library for rapid UI development with style props, color modes, themes and variants.
This example shows how to use [Reflexjs](https://github.com/reflexjs/reflexjs) with Next.js.
## 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-reflexjs&project-name=with-reflexjs&repository-name=with-reflexjs)
## 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-reflexjs with-reflexjs-app
# or
yarn create next-app --example with-reflexjs with-reflexjs-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)).
{
"name": "with-reflexjs",
"version": "1.0.0",
"license": "MIT",
"scripts": {
"dev": "next",
"build": "next build",
"start": "next start"
},
"dependencies": {
"next": "latest",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"reflexjs": "^2.0.0"
},
"devDependencies": {
"@babel/core": "^7.12.9",
"@types/node": "^14.14.12",
"@types/react": "^17.0.0",
"typescript": "^4.1.2"
}
}
import { AppProps } from 'next/app'
import { ThemeProvider } from 'reflexjs'
import theme from '../src/theme'
export default function App({ Component, pageProps }: AppProps) {
return (
<ThemeProvider theme={theme}>
<Component {...pageProps} />
</ThemeProvider>
)
}
import NextDocument, { Html, Main, NextScript, Head } from 'next/document'
import { InitializeColorMode } from 'reflexjs'
export default class Document extends NextDocument {
render() {
return (
<Html lang="en">
<Head />
<body>
<InitializeColorMode />
<Main />
<NextScript />
</body>
</Html>
)
}
}
export default function IndexPage() {
return (
<div variant="container" textAlign="center" py="20">
<h1 variant="heading.h1">
Welcome to <span color="primary">Reflexjs</span>
</h1>
<p fontSize="xl" my="4">
Get started by editing pages/index.tsx
</p>
<a href="https://reflexjs.org/docs" variant="button.primary">
Read the docs
</a>
</div>
)
}
import { Theme } from 'reflexjs'
const theme: Theme = {
useRootStyles: true,
initialColorModeName: 'light',
colors: {
text: '#191924',
background: '#fff',
primary: '#06f',
border: '#ebece9',
modes: {
dark: {
text: '#ededee',
background: '#1a202c',
primary: '#06f',
border: '#2a2a3c',
},
},
},
breakpoints: ['640px', '768px', '1024px', '1280px'],
fonts: {
body:
'-apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji',
heading: 'inherit',
monospace:
'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, Liberation Mono, Courier New, monospace',
},
fontSizes: {
sm: '0.875rem',
md: '1rem',
lg: '3rem',
},
fontWeights: {
normal: 400,
medium: 500,
bold: 700,
},
space: {
0: '0',
1: '0.25rem',
2: '0.5rem',
3: '0.75rem',
4: '1rem',
5: '1.25rem',
6: '1.5rem',
7: '1.75rem',
8: '2rem',
9: '2.25rem',
10: '2.5rem',
},
sizes: {
0: '0',
1: '0.25rem',
2: '0.5rem',
3: '0.75rem',
4: '1rem',
5: '1.25rem',
6: '1.5rem',
7: '1.75rem',
8: '2rem',
9: '2.25rem',
10: '2.5rem',
auto: 'auto',
half: '50%',
full: '100%',
screen: '100vw',
},
borders: [0, '1px solid'],
radii: {
none: '0',
sm: '0.125rem',
md: '0.25rem',
lg: '0.375rem',
xl: '0.5rem',
},
shadows: {
none: 'none',
sm: '0 1px 2px 0 rgba(0, 0, 0, 0.05)',
md: '0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06)',
lg: '0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06)',
},
gridTemplateColumns: {
none: 'none',
1: 'repeat(1, minmax(0, 1fr))',
2: 'repeat(2, minmax(0, 1fr))',
3: 'repeat(3, minmax(0, 1fr))',
},
gridTemplateRows: {
none: 'none',
1: 'repeat(1, minmax(0, 1fr))',
2: 'repeat(2, minmax(0, 1fr))',
3: 'repeat(3, minmax(0, 1fr))',
},
styles: {
root: {
fontFamily: 'body',
fontSize: 16,
lineHeight: 'normal',
fontFeatureSettings: "'kern'",
textRendering: 'optimizeLegibility',
WebkitFontSmoothing: 'antialiased',
'*': {
listStyle: 'none',
border: '0 solid',
borderColor: 'border',
m: 0,
p: 0,
'::selection': {
bg: 'selection',
},
},
body: {
color: 'text',
fontFamily: 'body',
fontWeight: 'normal',
fontSize: 'md',
lineHeight: 'relaxed',
letterSpacing: 'normal',
},
},
},
// Variants.
text: {
paragraph: {
fontSize: 'lg',
my: 8,
lineHeight: 8,
},
},
heading: {
color: 'heading',
fontFamily: 'heading',
fontWeight: 'semibold',
lineHeight: 'tight',
letterSpacing: 'tight',
h1: {
fontWeight: 'bold',
lineHeight: '1.1',
fontSize: 'lg',
},
},
container: {
px: '6|6|6|4',
mx: 'auto',
maxWidth: 1280,
},
button: {
display: 'inline-flex',
alignItems: 'center',
justifyContent: 'center',
color: 'text',
bg: 'muted',
fontFamily: 'body',
fontSize: 'md',
fontWeight: 'medium',
lineHeight: 'none',
textDecoration: 'none',
border: '1px solid',
borderColor: 'border',
borderRadius: 'md',
px: 4,
py: 3,
cursor: 'pointer',
transition: 'all .15s ease-in',
':hover, :focus': {
transform: 'translateY(-2px)',
boxShadow: 'lg',
},
primary: {
bg: 'primary',
color: 'white',
borderColor: 'primary',
'&:hover, &:focus': {
bg: 'primaryHover',
color: 'white',
borderColor: 'primaryHover',
transform: 'translateY(-2px)',
boxShadow: 'lg',
},
},
},
}
export default theme
{
"compilerOptions": {
"target": "es5",
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
"strict": false,
"forceConsistentCasingInFileNames": true,
"noEmit": true,
"esModuleInterop": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve"
},
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"],
"exclude": ["node_modules"]
}
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