Skip to content

Commit 58b942b

Browse files
committed
docs: add example projects
1 parent 0304099 commit 58b942b

41 files changed

Lines changed: 5792 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
# dependencies
4+
/node_modules
5+
/.pnp
6+
.pnp.*
7+
.yarn/*
8+
!.yarn/patches
9+
!.yarn/plugins
10+
!.yarn/releases
11+
!.yarn/versions
12+
13+
# testing
14+
/coverage
15+
16+
# next.js
17+
/.next/
18+
/out/
19+
20+
# production
21+
/build
22+
23+
# misc
24+
.DS_Store
25+
*.pem
26+
27+
# debug
28+
npm-debug.log*
29+
yarn-debug.log*
30+
yarn-error.log*
31+
.pnpm-debug.log*
32+
33+
# env files (can opt-in for committing if needed)
34+
.env*
35+
36+
# vercel
37+
.vercel
38+
39+
# typescript
40+
*.tsbuildinfo
41+
next-env.d.ts

examples/nextjs16-react19/.npmrc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# 告诉 pnpm 这是一个独立的仓库根目录,不要去连上层的 pnpm-workspace.yaml
2+
# 禁用递归安装
3+
recursive = false
4+
# 强制不使用隔离之外的链接
5+
link-workspace-packages = false
6+
# 建议加上这个,确保依赖安装在当前目录的 node_modules
7+
node-linker = isolated
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
This is a [Next.js](https://nextjs.org) project bootstrapped with [`create-next-app`](https://nextjs.org/docs/app/api-reference/cli/create-next-app).
2+
3+
## Getting Started
4+
5+
First, run the development server:
6+
7+
```bash
8+
npm run dev
9+
# or
10+
yarn dev
11+
# or
12+
pnpm dev
13+
# or
14+
bun dev
15+
```
16+
17+
Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
18+
19+
You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file.
20+
21+
This project uses [`next/font`](https://nextjs.org/docs/app/building-your-application/optimizing/fonts) to automatically optimize and load [Geist](https://vercel.com/font), a new font family for Vercel.
22+
23+
## Learn More
24+
25+
To learn more about Next.js, take a look at the following resources:
26+
27+
- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
28+
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.
29+
30+
You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js) - your feedback and contributions are welcome!
31+
32+
## Deploy on Vercel
33+
34+
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.
35+
36+
Check out our [Next.js deployment documentation](https://nextjs.org/docs/app/building-your-application/deploying) for more details.

examples/nextjs16-react19/app/globals.css

Whitespace-only changes.
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import type { Metadata } from "next";
2+
// import { Geist, Geist_Mono } from "next/font/google";
3+
import "./globals.css";
4+
5+
// const geistSans = Geist({
6+
// variable: "--font-geist-sans",
7+
// subsets: ["latin"],
8+
// });
9+
10+
// const geistMono = Geist_Mono({
11+
// variable: "--font-geist-mono",
12+
// subsets: ["latin"],
13+
// });
14+
15+
export const metadata: Metadata = {
16+
title: "Create Next App",
17+
description: "Generated by create next app",
18+
};
19+
20+
export default function RootLayout({
21+
children,
22+
}: Readonly<{
23+
children: React.ReactNode;
24+
}>) {
25+
return (
26+
<html lang="en">
27+
{/* <body className={`${geistSans.variable} ${geistMono.variable}`}> */}
28+
<body>
29+
{children}
30+
</body>
31+
</html>
32+
);
33+
}

examples/nextjs16-react19/app/page.module.css

Whitespace-only changes.
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
"use client";
2+
// import Image from "next/image";
3+
// import styles from "./page.module.css";
4+
import { useHeTree, sortFlatData } from "he-tree-react";
5+
import { useState } from 'react';
6+
7+
export default function Home() {
8+
const keys = { idKey: 'id', parentIdKey: 'parent_id' };
9+
const [data, setdata] = useState(() => sortFlatData([
10+
{
11+
id: 1,
12+
parent_id: null,
13+
name: "Root Category",
14+
},
15+
{
16+
id: 2,
17+
parent_id: 1,
18+
name: "Technology",
19+
},
20+
{
21+
id: 5,
22+
parent_id: 2,
23+
name: "Hardware",
24+
},
25+
{
26+
id: 10,
27+
parent_id: 5,
28+
name: "Computer Components",
29+
},
30+
{
31+
id: 4,
32+
parent_id: 2,
33+
name: "Programming",
34+
},
35+
{
36+
id: 8,
37+
parent_id: 4,
38+
name: "Python",
39+
},
40+
{
41+
id: 3,
42+
parent_id: 1,
43+
name: "Science",
44+
},
45+
{
46+
id: 7,
47+
parent_id: 3,
48+
name: "Biology",
49+
},
50+
{
51+
id: 6,
52+
parent_id: 3,
53+
name: "Physics",
54+
},
55+
], keys));
56+
const { renderTree } = useHeTree({
57+
...keys,
58+
data,
59+
dataType: 'flat',
60+
onChange: setdata,
61+
renderNode: ({ id, node, open, checked }) => <div>
62+
{node.name}
63+
</div>,
64+
})
65+
return <div>
66+
{renderTree({ style: { width: '300px', border: '1px solid #555', padding: '20px' } })}
67+
</div>
68+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import type { NextConfig } from "next";
2+
3+
const nextConfig: NextConfig = {
4+
/* config options here */
5+
};
6+
7+
export default nextConfig;
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"name": "nextjs16-react19",
3+
"version": "0.1.0",
4+
"private": true,
5+
"scripts": {
6+
"install-dep": "pnpm --ignore-workspace install",
7+
"dev": "next dev",
8+
"build": "next build",
9+
"start": "next start"
10+
},
11+
"dependencies": {
12+
"next": "16.1.6",
13+
"react": "19.2.3",
14+
"react-dom": "19.2.3",
15+
"he-tree-react": "^1.2.1-beta.0"
16+
},
17+
"devDependencies": {
18+
"@types/node": "^20",
19+
"@types/react": "^19",
20+
"@types/react-dom": "^19",
21+
"typescript": "^5"
22+
},
23+
"pnpm": {
24+
"onlyBuiltDependencies": [
25+
"sharp"
26+
]
27+
}
28+
}

0 commit comments

Comments
 (0)