Skip to content

Commit 17bc103

Browse files
committed
chore: add nextjs
1 parent 613574d commit 17bc103

29 files changed

+18336
-0
lines changed

dendron-next-server.code-workspace

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{
2+
"folders": [
3+
{
4+
"path": "packages/dendron-next-server"
5+
},
6+
],
7+
"settings": {
8+
"files.exclude": {
9+
"*.d.ts": true,
10+
"packages": true
11+
},
12+
"editor.formatOnSave": false,
13+
"workbench.editor.showTabs": true,
14+
"workbench.colorTheme": "Solarized Dark",
15+
"workbench.colorCustomizations": {
16+
"activityBar.activeBackground": "#3399ff",
17+
"activityBar.activeBorder": "#bf0060",
18+
"activityBar.background": "#3399ff",
19+
"activityBar.foreground": "#15202b",
20+
"activityBar.inactiveForeground": "#15202b99",
21+
"activityBarBadge.background": "#bf0060",
22+
"activityBarBadge.foreground": "#e7e7e7",
23+
"statusBar.background": "#007fff",
24+
"statusBar.foreground": "#e7e7e7",
25+
"statusBarItem.hoverBackground": "#3399ff",
26+
"titleBar.activeBackground": "#007fff",
27+
"titleBar.activeForeground": "#e7e7e7",
28+
"titleBar.inactiveBackground": "#007fff99",
29+
"titleBar.inactiveForeground": "#e7e7e799"
30+
},
31+
"peacock.color": "#007fff",
32+
"vim.statusBarColorControl": false,
33+
"debug.node.autoAttach": "on"
34+
}
35+
}
36+

packages/dendron-next-server/.env.development

Whitespace-only changes.
+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
# dependencies
4+
/node_modules
5+
/.pnp
6+
.pnp.js
7+
8+
# testing
9+
/coverage
10+
11+
# next.js
12+
/.next/
13+
/out/
14+
15+
# production
16+
/build
17+
18+
# misc
19+
.DS_Store
20+
*.pem
21+
22+
# debug
23+
npm-debug.log*
24+
yarn-debug.log*
25+
yarn-error.log*
26+
27+
# local env files
28+
.env.local
29+
.env.development.local
30+
.env.test.local
31+
.env.production.local
32+
33+
# vercel
34+
.vercel
35+
36+
#amplify
37+
amplify/\#current-cloud-backend
38+
amplify/.config/local-*
39+
amplify/mock-data
40+
amplify/backend/amplify-meta.json
41+
amplify/backend/awscloudformation
42+
build/
43+
dist/
44+
node_modules/
45+
aws-exports.js
46+
awsconfiguration.json
47+
amplifyconfiguration.json
48+
amplify-build-config.json
49+
amplify-gradle-config.json
50+
amplifytools.xcconfig
+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
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).
2+
3+
## Getting Started
4+
5+
First, run the development server:
6+
7+
```bash
8+
npm run dev
9+
# or
10+
yarn dev
11+
```
12+
13+
Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
14+
15+
You can start editing the page by modifying `pages/index.js`. The page auto-updates as you edit the file.
16+
17+
## Learn More
18+
19+
To learn more about Next.js, take a look at the following resources:
20+
21+
- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
22+
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.
23+
24+
You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js/) - your feedback and contributions are welcome!
25+
26+
## Deploy on Vercel
27+
28+
The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/import?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.
29+
30+
Check out our [Next.js deployment documentation](https://nextjs.org/docs/deployment) for more details.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
import { MinusOutlined } from "@ant-design/icons";
2+
import { SchemaPropsV2 } from "@dendronhq/common-all";
3+
import { Button, Card, Typography } from "antd";
4+
import _ from "lodash";
5+
import dynamic from "next/dynamic";
6+
import React, { useState } from "react";
7+
import { ReactD3TreeItem } from "react-d3-tree";
8+
import { useWindowSize } from "./hooks";
9+
const { Title, Text, Paragraph } = Typography;
10+
const { Meta } = Card;
11+
12+
const Tree = dynamic(
13+
() => {
14+
return import("react-d3-tree");
15+
},
16+
{ ssr: false }
17+
);
18+
19+
type SchemaTreeItem = ReactD3TreeItem &
20+
Omit<Partial<SchemaPropsV2>, "children">;
21+
22+
const myTreeData = [
23+
{
24+
name: "Top Level",
25+
attributes: {
26+
keyA: "val A",
27+
keyB: "val B",
28+
keyC: "val C",
29+
},
30+
children: [
31+
{
32+
name: "Level 2: A",
33+
attributes: {
34+
keyA: "val A",
35+
keyB: "val B",
36+
keyC: "val C",
37+
},
38+
},
39+
{
40+
name: "Level 2: B",
41+
},
42+
],
43+
},
44+
];
45+
type TreeViewState = {
46+
translate: {
47+
x: number;
48+
y: number;
49+
};
50+
};
51+
52+
export default function DendronTree() {
53+
const size = useWindowSize();
54+
const [treeData, setTreeData] = useState<SchemaTreeItem[]>(myTreeData);
55+
const [window, setWindow] = useState(undefined);
56+
const [treeViewState, setTreeViewState] = useState<TreeViewState>({
57+
translate: { x: 0, y: 0 },
58+
});
59+
if (_.isUndefined(size.height)) {
60+
return null;
61+
}
62+
if (!_.isEqual(window, size)) {
63+
setWindow(size);
64+
setTreeViewState({
65+
translate: {
66+
x: size.width / 2,
67+
y: size.height / 5,
68+
},
69+
});
70+
}
71+
72+
const generateNodeProps = () => {
73+
return {
74+
buttons: [
75+
<Button
76+
type="dashed"
77+
shape="circle"
78+
icon={<MinusOutlined />}
79+
size="small"
80+
/>,
81+
],
82+
};
83+
};
84+
85+
return (
86+
<div style={{ height: "100vh" }}>
87+
<Tree
88+
orientation={"vertical"}
89+
data={myTreeData}
90+
translate={treeViewState.translate}
91+
/>
92+
</div>
93+
);
94+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import { useState, useEffect } from 'react';
2+
3+
export function useWindowSize() {
4+
// Initialize state with undefined width/height so server and client renders match
5+
6+
// Learn more here: https://joshwcomeau.com/react/the-perils-of-rehydration/
7+
8+
const [windowSize, setWindowSize] = useState({
9+
width: undefined,
10+
11+
height: undefined,
12+
});
13+
14+
useEffect(() => {
15+
// Handler to call on window resize
16+
17+
function handleResize() {
18+
// Set window width/height to state
19+
20+
setWindowSize({
21+
width: window.innerWidth,
22+
23+
height: window.innerHeight,
24+
});
25+
}
26+
27+
// Add event listener
28+
29+
window.addEventListener("resize", handleResize);
30+
31+
// Call handler right away so state gets updated with initial window size
32+
33+
handleResize();
34+
35+
// Remove event listener on cleanup
36+
37+
return () => window.removeEventListener("resize", handleResize);
38+
}, []); // Empty array ensures that effect is only run on mount
39+
40+
return windowSize;
41+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
import { Layout as ALayout, Menu } from "antd";
2+
import Head from "next/head";
3+
import styles from "../styles/layout.module.css";
4+
import utilStyles from "../styles/utils.module.css";
5+
const { Header, Content, Footer, Sider } = ALayout;
6+
7+
const name = "Dendron";
8+
export const siteTitle = "Dendron";
9+
10+
export default function Layout({
11+
children,
12+
Signout,
13+
}: {
14+
children: any;
15+
Signout: any;
16+
}) {
17+
return (
18+
<ALayout style={{height:"100vh"}}>
19+
<Head>
20+
<link rel="icon" href="/favicon.ico" />
21+
<meta name="description" content="Dendron" />
22+
<meta
23+
property="og:image"
24+
content={
25+
"https://foundation-prod-assetspublic53c57cce-8cpvgjldwysl.s3-us-west-2.amazonaws.com/assets/logo-256.png"
26+
}
27+
/>
28+
<meta name="og:title" content={siteTitle} />
29+
<meta name="twitter:card" content="summary_large_image" />
30+
</Head>
31+
<Header>
32+
<div className={styles.logo}>
33+
<img
34+
src="https://foundation-prod-assetspublic53c57cce-8cpvgjldwysl.s3-us-west-2.amazonaws.com/assets/logo-256.png"
35+
className={`${utilStyles.borderCircle}`}
36+
id="logo"
37+
style={{ height: "55px" }}
38+
alt={name}
39+
/>
40+
</div>
41+
<Menu theme="dark" mode="horizontal" style={{ float: "right" }}>
42+
<Menu.Item key="3">
43+
{" "}
44+
<a target="_blank" href="https://dendron.memberful.com/account/subscriptions">Update Subscription</a>
45+
</Menu.Item>
46+
</Menu>
47+
</Header>
48+
49+
<ALayout>
50+
<Content
51+
className={styles.siteLayoutBackground}
52+
style={{
53+
padding: 24,
54+
margin: 0,
55+
minHeight: 800,
56+
background: "white"
57+
}}
58+
>
59+
{children}
60+
</Content>
61+
</ALayout>
62+
</ALayout>
63+
);
64+
}
+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { StageEnv } from "./types";
2+
3+
export const ENV: {[key: string]: StageEnv} = {
4+
dev: {
5+
},
6+
prod: {
7+
}
8+
}
9+
10+
export const CONFIG = {
11+
};
+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import _ from "lodash"
2+
import { ENV } from "./config"
3+
import { StageEnv } from "./types";
4+
5+
export function getStage() {
6+
return process.env.STAGE
7+
}
8+
9+
export function env(key: keyof StageEnv): any {
10+
const stage = getStage();
11+
return ENV[stage][key]
12+
}
13+
14+
export function dump(): StageEnv {
15+
return ENV[getStage()];
16+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
export function info(msg: any) {
2+
console.log(JSON.stringify(msg));
3+
}
4+
export function error(msg: any) {
5+
console.log(JSON.stringify(msg));
6+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export type StageEnv = {
2+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/// <reference types="next" />
2+
/// <reference types="next/types/global" />

0 commit comments

Comments
 (0)