Skip to content

Commit d3168f1

Browse files
committed
feat: Rework repo structure
1 parent 687a989 commit d3168f1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+1037
-263
lines changed

.editorconfig

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
root = true
2+
3+
[*]
4+
indent_style = space
5+
indent_size = 2
6+
charset = utf-8
7+
trim_trailing_whitespace = true
8+
insert_final_newline = true
9+
end_of_line = lf
10+
max_line_length = null

.eslintrc.js

-10
This file was deleted.

.gitattributes

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
* text eol=lf
2+
3+
# images
4+
*.gif binary
5+
*.jpg binary
6+
*.png binary
7+
*.svg binary
8+
*.ico binary
9+
10+
# fonts
11+
*.eot binary
12+
*.ttf binary
13+
*.woff binary

.gitignore

+17-17
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,20 @@
11
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
22

3+
# build
4+
.turbo
5+
.next
6+
build_production
7+
build_local
8+
39
# dependencies
410
node_modules
5-
.pnp
6-
.pnp.js
7-
8-
# testing
9-
coverage
10-
11-
# next.js
12-
.next/
13-
out/
14-
build
11+
.pnp.*
12+
.yarn/*
13+
!.yarn/patches
14+
!.yarn/plugins
15+
!.yarn/releases
16+
!.yarn/sdks
17+
!.yarn/versions
1518

1619
# misc
1720
.DS_Store
@@ -21,13 +24,10 @@ build
2124
npm-debug.log*
2225
yarn-debug.log*
2326
yarn-error.log*
24-
.pnpm-debug.log*
2527

2628
# local env files
27-
.env.local
28-
.env.development.local
29-
.env.test.local
30-
.env.production.local
29+
.env*.local
30+
.env.development*.local
31+
.env.test*.local
32+
.env.production*.local
3133

32-
# turbo
33-
.turbo

apps/docs/next.config.js

-5
This file was deleted.

apps/docs/package.json

-27
This file was deleted.

apps/docs/pages/index.tsx

-10
This file was deleted.

apps/docs/tsconfig.json

-5
This file was deleted.

apps/web/.eslintrc.js

-4
This file was deleted.

apps/web/README.md

-30
This file was deleted.

apps/web/next-env.d.ts

-5
This file was deleted.

apps/web/next.config.js

-5
This file was deleted.

apps/web/package.json

-27
This file was deleted.

apps/web/pages/index.tsx

-10
This file was deleted.

apps/web/tsconfig.json

-5
This file was deleted.
File renamed without changes.
File renamed without changes.
+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import Link from "next/link";
2+
import { memo, useRef } from "react";
3+
4+
function Breadcrumbs({
5+
pathParts,
6+
}: {
7+
pathParts: { title: string; path: string }[];
8+
}) {
9+
const date = useRef(new Date(Date.now()).toLocaleString());
10+
11+
return (
12+
<div className="border-b border-gray-300 pt-2 pb-4 px-8 group">
13+
<div className="text-gray-600 text-xs text-start opacity-0 -mt-1 -mb-1 transition-opacity group-hover:opacity-100">
14+
This is breadcrumbs. Note that it is not a "god" component. Data loading
15+
is decoupled by the use of hooks inside the page layout.{" "}
16+
<span className="text-gray-400">
17+
(Breadcrumbs rendered at: {date.current})
18+
</span>
19+
</div>
20+
<nav className="flex justify-start">
21+
{!pathParts.length && (
22+
<span className="text-gray-600 text-base animate-pulse">
23+
Loading...
24+
</span>
25+
)}
26+
{pathParts.map(({ title, path }) => (
27+
<>
28+
<Link key={path} href={path}>
29+
<a className="text-gray-600 text-base underline">{title}</a>
30+
</Link>
31+
&nbsp;/&nbsp;
32+
</>
33+
))}
34+
</nav>
35+
</div>
36+
);
37+
}
38+
39+
export default memo(Breadcrumbs);
+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { memo } from "react";
2+
3+
import hljs from "highlight.js/lib/core";
4+
import typescript from "highlight.js/lib/languages/javascript";
5+
hljs.registerLanguage("typescript", typescript);
6+
import "highlight.js/styles/tokyo-night-dark.css";
7+
8+
function Highlight({ children }: { children: string }) {
9+
return <pre dangerouslySetInnerHTML={{ __html: hljs.highlight(children, { language: "typescript" }).value }} />;
10+
}
11+
12+
export default memo(Highlight);
+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { memo, useCallback, useState } from "react";
2+
3+
function Incrementer() {
4+
const [count, setCount] = useState(0);
5+
const increment = useCallback(() => setCount((c) => c + 1), []);
6+
7+
return (
8+
<div className="flex items-center justify-center p-4 border-2 border-dashed border-gray-600 space-x-4">
9+
<span className="text-gray-800 text-base">Current: {count}</span>
10+
<button
11+
className="p-2 text-gray-800 border border-gray-600 hover:border-gray-500 active:border-gray-800"
12+
onClick={increment}
13+
>
14+
Increment
15+
</button>
16+
</div>
17+
);
18+
}
19+
20+
export default memo(Incrementer);

examples/demo/components/Layout.tsx

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { memo, ReactElement, ReactNode, useRef } from "react";
2+
3+
function Layout({ children }: { children: ReactNode }): ReactElement {
4+
const date = useRef(new Date(Date.now()).toLocaleString());
5+
6+
return (
7+
<div>
8+
{children}
9+
<div className="border-t border-gray-300 py-4 px-8 text-gray-600 text-sm text-center">
10+
This is a demo of the "
11+
<span className="font-bold text-blue-600">@kvet/next-layout</span>"
12+
package. Note that the layout component maintains its state on the route
13+
change event.{" "}
14+
<span className="text-gray-400">
15+
(The layout rendered at: {date.current})
16+
</span>
17+
</div>
18+
</div>
19+
);
20+
}
21+
22+
export default memo(Layout);

examples/demo/components/Navbar.tsx

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import Link from "next/link";
2+
import { memo, useRef } from "react";
3+
4+
function Navbar() {
5+
const date = useRef(new Date(Date.now()).toLocaleString());
6+
7+
return (
8+
<div className="border-b border-gray-300 pt-2 pb-4 px-8 group">
9+
<div className="text-gray-600 text-xs text-start opacity-0 -mt-1 -mb-1 transition-opacity group-hover:opacity-100">
10+
This is a navbar. Note that a focused element maintains its state on the
11+
route change event.
12+
<span className="text-gray-400">(Layout rendered at: {date.current})</span>
13+
</div>
14+
<nav className="flex justify-center space-x-4">
15+
<Link href="/">
16+
<a className="text-gray-800 text-base underline">Main page</a>
17+
</Link>
18+
<Link href="/sidebar">
19+
<a className="text-gray-800 text-base underline">Page with a sidebar</a>
20+
</Link>
21+
{/* <Link href="/sidebar/fullscreen">
22+
<a className="text-gray-800 text-base underline">Nested page with a fullscreen layout</a>
23+
</Link> */}
24+
</nav>
25+
</div>
26+
);
27+
}
28+
29+
export default memo(Navbar);

examples/demo/components/Sidebar.tsx

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import Link from "next/link";
2+
import { memo, ReactElement, ReactNode, useRef } from "react";
3+
4+
function Sidebar({
5+
paths,
6+
children,
7+
}: {
8+
paths: { title: string; path: string }[];
9+
children: ReactNode;
10+
}): ReactElement {
11+
const date = useRef(new Date(Date.now()).toLocaleString());
12+
13+
return (
14+
<div className="flex flex-col-reverse md:flex-row">
15+
<div className="md:w-64 flex-shrink-0 border-r border-gray-300 py-4 group">
16+
<div className="text-center text-xs text-gray-600 opacity-0 transition-opacity group-hover:opacity-100">
17+
This is a sidebar.{" "}
18+
<span className="text-gray-400">(Rendered at: {date.current})</span>
19+
</div>
20+
<nav className="flex flex-col justify-start px-4 py-2 space-y-2">
21+
{!paths.length && (
22+
<span className="text-gray-600 text-base animate-pulse">
23+
Loading...
24+
</span>
25+
)}
26+
{paths.map(({ title, path }) => (
27+
<>
28+
<Link key={path} href={path}>
29+
<a className="text-gray-600 text-sm underline">{title}</a>
30+
</Link>
31+
</>
32+
))}
33+
</nav>
34+
</div>
35+
<div className="flex-grow flex-shrink">{children}</div>
36+
</div>
37+
);
38+
}
39+
40+
export default memo(Sidebar);
File renamed without changes.

0 commit comments

Comments
 (0)