Skip to content

Commit

Permalink
chore: Next.js + CLI example
Browse files Browse the repository at this point in the history
  • Loading branch information
nmn committed Jun 25, 2024
1 parent 3c17e77 commit 16679e1
Show file tree
Hide file tree
Showing 24 changed files with 2,947 additions and 1,951 deletions.
3 changes: 3 additions & 0 deletions apps/cli-example/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"ignorePatterns": ["src"]
}
3 changes: 2 additions & 1 deletion apps/cli-example/source/components/Card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ type Props = Readonly<{
title: string;
body: string;
href: string;
other?: string;
}>;

export default function Card({ title, body, href }: Props) {
export default function Card({ title, body, href, other: _foo }: Props) {
return (
<a
{...stylex.props(styles.link)}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

module.exports = {
presets: ['@babel/preset-flow'],
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
"name": "@stylexjs/open-props",
"version": "0.6.1",
"description": "A library common values as variables to be used with Stylex.",
"type": "module",
"exports": {
"./lib/animationNames.stylex": "./lib/animationNames.stylex.js",
"./lib/animations.stylex": "./lib/animations.stylex.js",
"./lib/aspects.stylex": "./lib/aspects.stylex.js",
"./lib/borders.stylex": "./lib/borders.stylex.js",
"./lib/colors.stylex": "./lib/colors.stylex.js",
"./lib/colorsHSL.stylex": "./lib/colorsHSL.stylex.js",
"./lib/colorsOKLCH.stylex": "./lib/colorsOKLCH.stylex.js",
"./lib/colorsOKLCHHues.stylex": "./lib/colorsOKLCHHues.stylex.js",
"./lib/easings.stylex": "./lib/easings.stylex.js",
"./lib/fonts.stylex": "./lib/fonts.stylex.js",
"./lib/gradients.stylex": "./lib/gradients.stylex.js",
"./lib/grayOKLCH.stylex": "./lib/grayOKLCH.stylex.js",
"./lib/highlights.stylex": "./lib/highlights.stylex.js",
"./lib/layouts.stylex": "./lib/layouts.stylex.js",
"./lib/masksCornerCuts.stylex": "./lib/masksCornerCuts.stylex.js",
"./lib/masksEdges.stylex": "./lib/masksEdges.stylex.js",
"./lib/shadows.stylex": "./lib/shadows.stylex.js",
"./lib/sizes.stylex": "./lib/sizes.stylex.js",
"./lib/svg.stylex": "./lib/svg.stylex.js",
"./lib/zIndex.stylex": "./lib/zIndex.stylex.js"
},
"repository": "https://www.github.com/facebook/stylex",
"license": "MIT",
"scripts": {
"test": "jest",
"prebuild": "gen-types -i src/ -o lib/",
"build": "babel src/ --out-dir lib/ --copy-files"
},
"dependencies": {
"@stylexjs/stylex": "0.6.1"
},
"devDependencies": {
"@stylexjs/scripts": "0.6.1"
},
"jest": {},
"files": [
"lib/*"
]
}
12 changes: 12 additions & 0 deletions apps/next-with-cli/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"ignorePatterns": ["node_modules/", ".next/", "src"],
"plugins": ["@stylexjs"],
"rules": {
// The Eslint rule still needs work, but you can
// enable it to test things out.
"@stylexjs/valid-styles": "error",
"ft-flow/space-after-type-colon": 0,
"ft-flow/no-types-missing-file-annotation": 0,
"ft-flow/generic-spacing": 0
}
}
38 changes: 38 additions & 0 deletions apps/next-with-cli/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

src

# 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
14 changes: 14 additions & 0 deletions apps/next-with-cli/.stylex.json5
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
input: ['./source'],
output: ['./src'],
cssBundleName: 'stylex_bundle.css',
useCSSLayers: true,
babelPresets: [
['@babel/preset-typescript', { allExtensions: true, isTSX: true }],
// '@babel/preset-react',
],
// modules_EXPERIMENTAL: [
// ['@stylexjs/open-props', { ignore: ['src', '__tests__'] }],
// ],
// watch: true,
}
36 changes: 36 additions & 0 deletions apps/next-with-cli/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
This is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app).

## Getting Started

First, run the development server:

```bash
npm run dev
# or
yarn dev
# or
pnpm dev
# or
bun dev
```

Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.

You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file.

This project uses [`next/font`](https://nextjs.org/docs/basic-features/font-optimization) to automatically optimize and load Inter, a custom Google Font.

## Learn More

To learn more about Next.js, take a look at the following resources:

- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.

You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js/) - your feedback and contributions are welcome!

## Deploy on Vercel

The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.

Check out our [Next.js deployment documentation](https://nextjs.org/docs/deployment) for more details.
4 changes: 4 additions & 0 deletions apps/next-with-cli/next.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/** @type {import('next').NextConfig} */
const nextConfig = {};

export default nextConfig;
29 changes: 29 additions & 0 deletions apps/next-with-cli/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"name": "next-with-cli",
"version": "0.1.0",
"private": true,
"scripts": {
"predev": "stylex --config ./.stylex.json5",
"dev": "stylex --config ./.stylex.json5 -w & next dev",
"prestart": "stylex --config ./.stylex.json5 && next build",
"start": "next start",
"lint": "next lint"
},
"dependencies": {
"react": "18.3.1",
"react-dom": "18.3.1",
"next": "14.2.4",
"@stylexjs/stylex": "^0.6.1"
},
"devDependencies": {
"@stylexjs/babel-plugin": "^0.6.1",
"@stylexjs/eslint-plugin": "^0.6.1",
"@stylexjs/cli": "^0.6.1",
"typescript": "^5",
"@types/node": "^20",
"@types/react": "^18",
"@types/react-dom": "^18",
"eslint": "^8",
"eslint-config-next": "14.2.4"
}
}
1 change: 1 addition & 0 deletions apps/next-with-cli/public/next.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions apps/next-with-cli/public/vercel.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 19 additions & 0 deletions apps/next-with-cli/source/app/404.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
*/

import type { Metadata } from 'next';

export const metadata: Metadata = {
title: 'Not Found',
description: '404 - Not Found',
};

export default function RootLayout() {
return <h1>404 - Page Not Found</h1>;
}
19 changes: 19 additions & 0 deletions apps/next-with-cli/source/app/500.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
*/

import type { Metadata } from 'next';

export const metadata: Metadata = {
title: 'Not Found',
description: '500 - Internal Server Error',
};

export default function RootLayout() {
return <h1>500 - Internal Server Error</h1>;
}
21 changes: 21 additions & 0 deletions apps/next-with-cli/source/app/error.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
*/

'use client';

import type { Metadata } from 'next';

export const metadata: Metadata = {
title: 'Some Error',
description: 'Some Error',
};

export default function RootLayout() {
return <h1>500 - Some Error</h1>;
}
Binary file added apps/next-with-cli/source/app/favicon.ico
Binary file not shown.
85 changes: 85 additions & 0 deletions apps/next-with-cli/source/app/globals.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
:root {
--max-width: 1100px;
--border-radius: 12px;
--font-mono: ui-monospace, Menlo, Monaco, 'Cascadia Mono', 'Segoe UI Mono',
'Roboto Mono', 'Oxygen Mono', 'Ubuntu Monospace', 'Source Code Pro',
'Fira Mono', 'Droid Sans Mono', 'Courier New', monospace;

--foreground-rgb: 0, 0, 0;
--background-start-rgb: 214, 219, 220;
--background-end-rgb: 255, 255, 255;

--primary-glow: conic-gradient(
from 180deg at 50% 50%,
#16abff33 0deg,
#0885ff33 55deg,
#54d6ff33 120deg,
#0071ff33 160deg,
transparent 360deg
);
--secondary-glow: radial-gradient(
rgba(255, 255, 255, 1),
rgba(255, 255, 255, 0)
);

--tile-start-rgb: 239, 245, 249;
--tile-end-rgb: 228, 232, 233;
--tile-border: conic-gradient(
#00000080,
#00000040,
#00000030,
#00000020,
#00000010,
#00000010,
#00000080
);

--callout-rgb: 238, 240, 241;
--callout-border-rgb: 172, 175, 176;
--card-rgb: 180, 185, 188;
--card-border-rgb: 131, 134, 135;
}

@media (prefers-color-scheme: dark) {
:root {
--foreground-rgb: 255, 255, 255;
--background-start-rgb: 0, 0, 0;
--background-end-rgb: 0, 0, 0;

--primary-glow: radial-gradient(rgba(1, 65, 255, 0.4), rgba(1, 65, 255, 0));
--secondary-glow: linear-gradient(
to bottom right,
rgba(1, 65, 255, 0),
rgba(1, 65, 255, 0),
rgba(1, 65, 255, 0.3)
);

--tile-start-rgb: 2, 13, 46;
--tile-end-rgb: 2, 5, 19;
--tile-border: conic-gradient(
#ffffff80,
#ffffff40,
#ffffff30,
#ffffff20,
#ffffff10,
#ffffff10,
#ffffff80
);

--callout-rgb: 20, 20, 20;
--callout-border-rgb: 108, 108, 108;
--card-rgb: 100, 100, 100;
--card-border-rgb: 200, 200, 200;
}
}

* {
box-sizing: border-box;
padding: 0;
margin: 0;
}

a {
color: inherit;
text-decoration: none;
}
Loading

0 comments on commit 16679e1

Please sign in to comment.