simple tree prototype
This commit is contained in:
commit
ba94ab8984
|
|
@ -0,0 +1,24 @@
|
|||
# Logs
|
||||
logs
|
||||
*.log
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
pnpm-debug.log*
|
||||
lerna-debug.log*
|
||||
|
||||
node_modules
|
||||
dist
|
||||
dist-ssr
|
||||
*.local
|
||||
|
||||
# Editor directories and files
|
||||
.vscode/*
|
||||
!.vscode/extensions.json
|
||||
.idea
|
||||
.DS_Store
|
||||
*.suo
|
||||
*.ntvs*
|
||||
*.njsproj
|
||||
*.sln
|
||||
*.sw?
|
||||
|
|
@ -0,0 +1,73 @@
|
|||
# React + TypeScript + Vite
|
||||
|
||||
This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.
|
||||
|
||||
Currently, two official plugins are available:
|
||||
|
||||
- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react) uses [Oxc](https://oxc.rs)
|
||||
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react-swc) uses [SWC](https://swc.rs/)
|
||||
|
||||
## React Compiler
|
||||
|
||||
The React Compiler is not enabled on this template because of its impact on dev & build performances. To add it, see [this documentation](https://react.dev/learn/react-compiler/installation).
|
||||
|
||||
## Expanding the ESLint configuration
|
||||
|
||||
If you are developing a production application, we recommend updating the configuration to enable type-aware lint rules:
|
||||
|
||||
```js
|
||||
export default defineConfig([
|
||||
globalIgnores(['dist']),
|
||||
{
|
||||
files: ['**/*.{ts,tsx}'],
|
||||
extends: [
|
||||
// Other configs...
|
||||
|
||||
// Remove tseslint.configs.recommended and replace with this
|
||||
tseslint.configs.recommendedTypeChecked,
|
||||
// Alternatively, use this for stricter rules
|
||||
tseslint.configs.strictTypeChecked,
|
||||
// Optionally, add this for stylistic rules
|
||||
tseslint.configs.stylisticTypeChecked,
|
||||
|
||||
// Other configs...
|
||||
],
|
||||
languageOptions: {
|
||||
parserOptions: {
|
||||
project: ['./tsconfig.node.json', './tsconfig.app.json'],
|
||||
tsconfigRootDir: import.meta.dirname,
|
||||
},
|
||||
// other options...
|
||||
},
|
||||
},
|
||||
])
|
||||
```
|
||||
|
||||
You can also install [eslint-plugin-react-x](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-x) and [eslint-plugin-react-dom](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-dom) for React-specific lint rules:
|
||||
|
||||
```js
|
||||
// eslint.config.js
|
||||
import reactX from 'eslint-plugin-react-x'
|
||||
import reactDom from 'eslint-plugin-react-dom'
|
||||
|
||||
export default defineConfig([
|
||||
globalIgnores(['dist']),
|
||||
{
|
||||
files: ['**/*.{ts,tsx}'],
|
||||
extends: [
|
||||
// Other configs...
|
||||
// Enable lint rules for React
|
||||
reactX.configs['recommended-typescript'],
|
||||
// Enable lint rules for React DOM
|
||||
reactDom.configs.recommended,
|
||||
],
|
||||
languageOptions: {
|
||||
parserOptions: {
|
||||
project: ['./tsconfig.node.json', './tsconfig.app.json'],
|
||||
tsconfigRootDir: import.meta.dirname,
|
||||
},
|
||||
// other options...
|
||||
},
|
||||
},
|
||||
])
|
||||
```
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
import js from '@eslint/js'
|
||||
import globals from 'globals'
|
||||
import reactHooks from 'eslint-plugin-react-hooks'
|
||||
import reactRefresh from 'eslint-plugin-react-refresh'
|
||||
import tseslint from 'typescript-eslint'
|
||||
import { defineConfig, globalIgnores } from 'eslint/config'
|
||||
|
||||
export default defineConfig([
|
||||
globalIgnores(['dist']),
|
||||
{
|
||||
files: ['**/*.{ts,tsx}'],
|
||||
extends: [
|
||||
js.configs.recommended,
|
||||
tseslint.configs.recommended,
|
||||
reactHooks.configs.flat.recommended,
|
||||
reactRefresh.configs.vite,
|
||||
],
|
||||
languageOptions: {
|
||||
globals: globals.browser,
|
||||
},
|
||||
},
|
||||
])
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>client</title>
|
||||
</head>
|
||||
<body>
|
||||
<div id="root"></div>
|
||||
<script type="module" src="/src/main.tsx"></script>
|
||||
</body>
|
||||
</html>
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,34 @@
|
|||
{
|
||||
"name": "client",
|
||||
"private": true,
|
||||
"version": "0.0.0",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
"build": "tsc -b && vite build",
|
||||
"lint": "eslint .",
|
||||
"preview": "vite preview"
|
||||
},
|
||||
"dependencies": {
|
||||
"react": "^19.2.5",
|
||||
"react-dom": "^19.2.5",
|
||||
"slate": "^0.124.1",
|
||||
"slate-history": "^0.113.1",
|
||||
"slate-react": "^0.124.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@eslint/js": "^10.0.1",
|
||||
"@types/node": "^24.12.2",
|
||||
"@types/react": "^19.2.14",
|
||||
"@types/react-dom": "^19.2.3",
|
||||
"@vitejs/plugin-react": "^6.0.1",
|
||||
"eslint": "^10.2.1",
|
||||
"eslint-plugin-react-hooks": "^7.1.1",
|
||||
"eslint-plugin-react-refresh": "^0.5.2",
|
||||
"globals": "^17.5.0",
|
||||
"sass-embedded": "^1.99.0",
|
||||
"typescript": "~6.0.2",
|
||||
"typescript-eslint": "^8.58.2",
|
||||
"vite": "^8.0.10"
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 200'>
|
||||
<polyline points='30,70 90,130 160,30' fill='none' stroke='white' stroke-width='40' stroke-linecap='round' stroke-linejoin='round' />
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 207 B |
|
|
@ -0,0 +1,8 @@
|
|||
<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 200'>
|
||||
<mask id="check" mask-type="luminance">
|
||||
<rect x="0" y="0" width="200" height="200" fill="white" />
|
||||
<polyline points='30,70 90,130 160,30' fill='none' stroke='black' stroke-width='40' stroke-linecap='round' stroke-linejoin='round' />
|
||||
</mask>
|
||||
<circle cx='100' cy='100' r='60' fill='none' stroke='white' stroke-width='20' mask='url(#check)' />
|
||||
<polyline points='30,70 90,130 160,30' fill='none' stroke='white' stroke-width='20' stroke-linecap='round' stroke-linejoin='round' />
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 577 B |
|
|
@ -0,0 +1,184 @@
|
|||
/* .counter {
|
||||
font-size: 16px;
|
||||
padding: 5px 10px;
|
||||
border-radius: 5px;
|
||||
color: var(--accent);
|
||||
background: var(--accent-bg);
|
||||
border: 2px solid transparent;
|
||||
transition: border-color 0.3s;
|
||||
margin-bottom: 24px;
|
||||
|
||||
&:hover {
|
||||
border-color: var(--accent-border);
|
||||
}
|
||||
&:focus-visible {
|
||||
outline: 2px solid var(--accent);
|
||||
outline-offset: 2px;
|
||||
}
|
||||
}
|
||||
|
||||
.hero {
|
||||
position: relative;
|
||||
|
||||
.base,
|
||||
.framework,
|
||||
.vite {
|
||||
inset-inline: 0;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
.base {
|
||||
width: 170px;
|
||||
position: relative;
|
||||
z-index: 0;
|
||||
}
|
||||
|
||||
.framework,
|
||||
.vite {
|
||||
position: absolute;
|
||||
}
|
||||
|
||||
.framework {
|
||||
z-index: 1;
|
||||
top: 34px;
|
||||
height: 28px;
|
||||
transform: perspective(2000px) rotateZ(300deg) rotateX(44deg) rotateY(39deg)
|
||||
scale(1.4);
|
||||
}
|
||||
|
||||
.vite {
|
||||
z-index: 0;
|
||||
top: 107px;
|
||||
height: 26px;
|
||||
width: auto;
|
||||
transform: perspective(2000px) rotateZ(300deg) rotateX(40deg) rotateY(39deg)
|
||||
scale(0.8);
|
||||
}
|
||||
}
|
||||
|
||||
#center {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 25px;
|
||||
place-content: center;
|
||||
place-items: center;
|
||||
flex-grow: 1;
|
||||
|
||||
@media (max-width: 1024px) {
|
||||
padding: 32px 20px 24px;
|
||||
gap: 18px;
|
||||
}
|
||||
}
|
||||
|
||||
#next-steps {
|
||||
display: flex;
|
||||
border-top: 1px solid var(--border);
|
||||
text-align: left;
|
||||
|
||||
& > div {
|
||||
flex: 1 1 0;
|
||||
padding: 32px;
|
||||
@media (max-width: 1024px) {
|
||||
padding: 24px 20px;
|
||||
}
|
||||
}
|
||||
|
||||
.icon {
|
||||
margin-bottom: 16px;
|
||||
width: 22px;
|
||||
height: 22px;
|
||||
}
|
||||
|
||||
@media (max-width: 1024px) {
|
||||
flex-direction: column;
|
||||
text-align: center;
|
||||
}
|
||||
}
|
||||
|
||||
#docs {
|
||||
border-right: 1px solid var(--border);
|
||||
|
||||
@media (max-width: 1024px) {
|
||||
border-right: none;
|
||||
border-bottom: 1px solid var(--border);
|
||||
}
|
||||
}
|
||||
|
||||
#next-steps ul {
|
||||
list-style: none;
|
||||
padding: 0;
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
margin: 32px 0 0;
|
||||
|
||||
.logo {
|
||||
height: 18px;
|
||||
}
|
||||
|
||||
a {
|
||||
color: var(--text-h);
|
||||
font-size: 16px;
|
||||
border-radius: 6px;
|
||||
background: var(--social-bg);
|
||||
display: flex;
|
||||
padding: 6px 12px;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
text-decoration: none;
|
||||
transition: box-shadow 0.3s;
|
||||
|
||||
&:hover {
|
||||
box-shadow: var(--shadow);
|
||||
}
|
||||
.button-icon {
|
||||
height: 18px;
|
||||
width: 18px;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 1024px) {
|
||||
margin-top: 20px;
|
||||
flex-wrap: wrap;
|
||||
justify-content: center;
|
||||
|
||||
li {
|
||||
flex: 1 1 calc(50% - 8px);
|
||||
}
|
||||
|
||||
a {
|
||||
width: 100%;
|
||||
justify-content: center;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#spacer {
|
||||
height: 88px;
|
||||
border-top: 1px solid var(--border);
|
||||
@media (max-width: 1024px) {
|
||||
height: 48px;
|
||||
}
|
||||
}
|
||||
|
||||
.ticks {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
|
||||
&::before,
|
||||
&::after {
|
||||
content: '';
|
||||
position: absolute;
|
||||
top: -4.5px;
|
||||
border: 5px solid transparent;
|
||||
}
|
||||
|
||||
&::before {
|
||||
left: 0;
|
||||
border-left-color: var(--border);
|
||||
}
|
||||
&::after {
|
||||
right: 0;
|
||||
border-right-color: var(--border);
|
||||
}
|
||||
} */
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
import TreeView from './components/Slate/TreeView'
|
||||
|
||||
import './App.css'
|
||||
|
||||
export const App = function () {
|
||||
|
||||
return (
|
||||
<>
|
||||
<TreeView />
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
export default App
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
import type { RenderElementProps } from "slate-react";
|
||||
|
||||
export const DefaultElementView = function ({ attributes, children }: RenderElementProps) {
|
||||
return <p {...attributes}>{children}</p>
|
||||
}
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
import type { RenderLeafProps } from "slate-react";
|
||||
|
||||
export function renderLeaf({ attributes, children }: RenderLeafProps) {
|
||||
return <span {...attributes}>{children}</span>;
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
import type { RenderElementProps } from "slate-react";
|
||||
|
||||
export const TaskBodyElementView = function ({ attributes, children }: RenderElementProps) {
|
||||
return (
|
||||
<div {...attributes} className="body">
|
||||
{children}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
import React from "react";
|
||||
import type { RenderElementProps } from "slate-react";
|
||||
import type { TaskTreeElement } from "../../../types/slate";
|
||||
|
||||
export type TaskTreeElementViewProps = RenderElementProps & {
|
||||
element: TaskTreeElement,
|
||||
}
|
||||
|
||||
export const TaskTreeElementView = function ({ attributes, children, element }: TaskTreeElementViewProps) {
|
||||
const [body, ...childTasks] = React.Children.toArray(children);
|
||||
return (
|
||||
<div className={['task', ...(element.done ? ['done'] : [])].join(' ')} {...attributes}>
|
||||
<div className="bullet" contentEditable={false} />
|
||||
<div className="content">
|
||||
<div className="task-text">{body}</div>
|
||||
<div className="task-children">{childTasks}</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
import { DefaultElement, type RenderElementProps } from "slate-react";
|
||||
|
||||
import { TaskTreeElementView, type TaskTreeElementViewProps } from "./TaskTreeElementView";
|
||||
import { TaskBodyElementView } from "./TaskBodyElementView";
|
||||
|
||||
export * from './Leaf';
|
||||
|
||||
export function renderElement(props: RenderElementProps) {
|
||||
switch (props.element.type) {
|
||||
case "task-tree":
|
||||
return <TaskTreeElementView {...props as TaskTreeElementViewProps} />;
|
||||
case "task-body":
|
||||
return <TaskBodyElementView {...props} />;
|
||||
default:
|
||||
return <DefaultElement {...props} />
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
.task {
|
||||
display: flex;
|
||||
|
||||
&>.bullet {
|
||||
position: relative;
|
||||
width: 1em;
|
||||
height: 1em;
|
||||
margin: 4px;
|
||||
cursor: pointer;
|
||||
|
||||
&::after {
|
||||
position: absolute;
|
||||
top: 0px;
|
||||
left: 0px;
|
||||
width: 1em;
|
||||
height: 1em;
|
||||
display: inline-block;
|
||||
content: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 200'><circle cx='100' cy='100' r='60' fill='none' stroke='currentColor' stroke-width='20' /></svg>");
|
||||
}
|
||||
}
|
||||
|
||||
&.done>.bullet::after {
|
||||
content: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 200'><mask id='check' mask-type='luminance'><rect x='0' y='0' width='200' height='200' fill='white' /><polyline points='30,70 90,130 160,30' fill='none' stroke='black' stroke-width='40' stroke-linecap='round' stroke-linejoin='round' /></mask><circle cx='100' cy='100' r='60' fill='none' stroke='currentColor' stroke-width='20' mask='url(%23check)' /><polyline points='30,70 90,130 160,30' fill='none' stroke='currentColor' stroke-width='20' stroke-linecap='round' stroke-linejoin='round' /></svg>");
|
||||
}
|
||||
|
||||
&>.content {
|
||||
|
||||
&>.task-text {
|
||||
margin-left: 4px;
|
||||
padding: 4px 0px;
|
||||
|
||||
&>.body {
|
||||
// height: 1em;
|
||||
line-height: 1em;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.task-children [data-slate-zero-width] {
|
||||
display: none;
|
||||
}
|
||||
|
|
@ -0,0 +1,44 @@
|
|||
import { useState } from "react";
|
||||
import {
|
||||
createEditor,
|
||||
} from "slate";
|
||||
import {
|
||||
Slate,
|
||||
Editable,
|
||||
withReact,
|
||||
} from "slate-react";
|
||||
|
||||
import { renderElement, renderLeaf } from "./Elements";
|
||||
|
||||
import { initialValue } from "./initialValue";
|
||||
// import { tasksFromSlate } from "./transformers";
|
||||
// import type { TaskTreeElement } from "../../types/slate";
|
||||
|
||||
import "./TreeView.scss";
|
||||
|
||||
export default function TreeEditor() {
|
||||
const [editor] = useState(() => withReact(createEditor()));
|
||||
|
||||
return (
|
||||
|
||||
<Slate
|
||||
editor={editor}
|
||||
initialValue={initialValue}
|
||||
// onChange={value => {
|
||||
// const isAstChange = editor.operations.some((op) => 'set_selection' !== op.type);
|
||||
// if (isAstChange) {
|
||||
// // const content = JSON.stringify(value)
|
||||
// const data = JSON.stringify(tasksFromSlate(value as TaskTreeElement[]));
|
||||
// console.log(data);
|
||||
// localStorage.setItem('content', data);
|
||||
// }
|
||||
// }}
|
||||
>
|
||||
<Editable
|
||||
className="editable"
|
||||
renderElement={renderElement}
|
||||
renderLeaf={renderLeaf}
|
||||
/>
|
||||
</Slate >
|
||||
);
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
declare module "*.css";
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
import { tasksToSlate } from "./transformers";
|
||||
|
||||
export const initialValue = tasksToSlate([
|
||||
{
|
||||
id: '1',
|
||||
text: 'Task 1',
|
||||
children: [
|
||||
{
|
||||
id: '11',
|
||||
done: true,
|
||||
text: 'Alpha',
|
||||
},
|
||||
{
|
||||
id: '12',
|
||||
text: 'Beta',
|
||||
children: [
|
||||
{
|
||||
id: '121',
|
||||
text: 'Beta 1',
|
||||
},
|
||||
{
|
||||
id: '122',
|
||||
text: 'Beta 2',
|
||||
},
|
||||
{
|
||||
id: '123',
|
||||
text: 'Beta 3',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
id: '13',
|
||||
text: 'Gamma',
|
||||
},
|
||||
],
|
||||
}
|
||||
]);
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
import type { TaskElement, TaskTreeElement } from "../../types/slate";
|
||||
import type { Task } from "../../types/task";
|
||||
|
||||
export function tasksToSlate(tasks: Task[]): TaskTreeElement[] {
|
||||
return tasks.map((task) => ({
|
||||
type: 'task-tree',
|
||||
id: task.id,
|
||||
done: task.done ?? false,
|
||||
children: [
|
||||
{ type: 'task-body', children: [{ text: task.text }], }, // editable label lives in the leaf
|
||||
...(task.children ? tasksToSlate(task.children) : []),
|
||||
],
|
||||
}));
|
||||
}
|
||||
|
||||
export function taskFromSlate(element: TaskTreeElement): Task {
|
||||
const [label, ...nested] = element.children;
|
||||
return {
|
||||
id: element.id,
|
||||
done: element.done,
|
||||
text: (label as TaskElement).children[0].text,
|
||||
children: nested.length ? tasksFromSlate(nested) : undefined,
|
||||
};
|
||||
}
|
||||
|
||||
export function tasksFromSlate(elements: TaskTreeElement[]): Task[] {
|
||||
return elements.map(taskFromSlate);
|
||||
}
|
||||
|
|
@ -0,0 +1,111 @@
|
|||
/* :root {
|
||||
--text: #6b6375;
|
||||
--text-h: #08060d;
|
||||
--bg: #fff;
|
||||
--border: #e5e4e7;
|
||||
--code-bg: #f4f3ec;
|
||||
--accent: #aa3bff;
|
||||
--accent-bg: rgba(170, 59, 255, 0.1);
|
||||
--accent-border: rgba(170, 59, 255, 0.5);
|
||||
--social-bg: rgba(244, 243, 236, 0.5);
|
||||
--shadow:
|
||||
rgba(0, 0, 0, 0.1) 0 10px 15px -3px, rgba(0, 0, 0, 0.05) 0 4px 6px -2px;
|
||||
|
||||
--sans: system-ui, 'Segoe UI', Roboto, sans-serif;
|
||||
--heading: system-ui, 'Segoe UI', Roboto, sans-serif;
|
||||
--mono: ui-monospace, Consolas, monospace;
|
||||
|
||||
font: 18px/145% var(--sans);
|
||||
letter-spacing: 0.18px;
|
||||
color-scheme: light dark;
|
||||
color: var(--text);
|
||||
background: var(--bg);
|
||||
font-synthesis: none;
|
||||
text-rendering: optimizeLegibility;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
-moz-osx-font-smoothing: grayscale;
|
||||
|
||||
@media (max-width: 1024px) {
|
||||
font-size: 16px;
|
||||
}
|
||||
}
|
||||
|
||||
@media (prefers-color-scheme: dark) {
|
||||
:root {
|
||||
--text: #9ca3af;
|
||||
--text-h: #f3f4f6;
|
||||
--bg: #16171d;
|
||||
--border: #2e303a;
|
||||
--code-bg: #1f2028;
|
||||
--accent: #c084fc;
|
||||
--accent-bg: rgba(192, 132, 252, 0.15);
|
||||
--accent-border: rgba(192, 132, 252, 0.5);
|
||||
--social-bg: rgba(47, 48, 58, 0.5);
|
||||
--shadow:
|
||||
rgba(0, 0, 0, 0.4) 0 10px 15px -3px, rgba(0, 0, 0, 0.25) 0 4px 6px -2px;
|
||||
}
|
||||
|
||||
#social .button-icon {
|
||||
filter: invert(1) brightness(2);
|
||||
}
|
||||
}
|
||||
|
||||
#root {
|
||||
width: 1126px;
|
||||
max-width: 100%;
|
||||
margin: 0 auto;
|
||||
text-align: center;
|
||||
border-inline: 1px solid var(--border);
|
||||
min-height: 100svh;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
body {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
h1,
|
||||
h2 {
|
||||
font-family: var(--heading);
|
||||
font-weight: 500;
|
||||
color: var(--text-h);
|
||||
}
|
||||
|
||||
h1 {
|
||||
font-size: 56px;
|
||||
letter-spacing: -1.68px;
|
||||
margin: 32px 0;
|
||||
@media (max-width: 1024px) {
|
||||
font-size: 36px;
|
||||
margin: 20px 0;
|
||||
}
|
||||
}
|
||||
h2 {
|
||||
font-size: 24px;
|
||||
line-height: 118%;
|
||||
letter-spacing: -0.24px;
|
||||
margin: 0 0 8px;
|
||||
@media (max-width: 1024px) {
|
||||
font-size: 20px;
|
||||
}
|
||||
}
|
||||
p {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
code,
|
||||
.counter {
|
||||
font-family: var(--mono);
|
||||
display: inline-flex;
|
||||
border-radius: 4px;
|
||||
color: var(--text-h);
|
||||
}
|
||||
|
||||
code {
|
||||
font-size: 15px;
|
||||
line-height: 135%;
|
||||
padding: 4px 8px;
|
||||
background: var(--code-bg);
|
||||
} */
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
import { StrictMode } from 'react'
|
||||
import { createRoot } from 'react-dom/client'
|
||||
import App from './App.tsx'
|
||||
|
||||
import './index.css'
|
||||
|
||||
createRoot(document.getElementById('root')!).render(
|
||||
<StrictMode>
|
||||
<App />
|
||||
</StrictMode>,
|
||||
)
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
// TypeScript users only add this code
|
||||
import { BaseEditor, Descendant } from 'slate'
|
||||
import { ReactEditor } from 'slate-react'
|
||||
|
||||
type CustomElement = { type: 'paragraph'; children: CustomText[] }
|
||||
type CustomText = { text: string }
|
||||
|
||||
declare module 'slate' {
|
||||
interface CustomTypes {
|
||||
Editor: BaseEditor & ReactEditor
|
||||
Element: CustomElement
|
||||
Text: CustomText
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
import type { Task } from './task';
|
||||
|
||||
export type CustomText = { text: string };
|
||||
|
||||
export type TaskTreeElement = {
|
||||
type: 'task-tree',
|
||||
id: Task['id'],
|
||||
done: Task['done'],
|
||||
children: [TaskElement, ...TaskTreeElement[]],
|
||||
};
|
||||
|
||||
export type TaskElement = {
|
||||
type: 'task-body';
|
||||
children: [CustomText];
|
||||
};
|
||||
|
||||
declare module "slate" {
|
||||
interface CustomTypes {
|
||||
Editor: BaseEditor & ReactEditor;
|
||||
Element: TaskElement | TaskTreeElement;
|
||||
Text: CustomText;
|
||||
}
|
||||
}
|
||||
|
||||
type TreeEditor = BaseEditor & ReactEditor;
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
export type Task = {
|
||||
id: string;
|
||||
done?: boolean;
|
||||
text: string;
|
||||
children?: Task[];
|
||||
};
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
|
||||
"target": "es2023",
|
||||
"lib": ["ES2023", "DOM"],
|
||||
"module": "esnext",
|
||||
"types": ["vite/client"],
|
||||
"skipLibCheck": true,
|
||||
|
||||
/* Bundler mode */
|
||||
"moduleResolution": "bundler",
|
||||
"allowImportingTsExtensions": true,
|
||||
"verbatimModuleSyntax": true,
|
||||
"moduleDetection": "force",
|
||||
"noEmit": true,
|
||||
"jsx": "react-jsx",
|
||||
|
||||
/* Linting */
|
||||
"noUnusedLocals": true,
|
||||
"noUnusedParameters": true,
|
||||
"erasableSyntaxOnly": true,
|
||||
"noFallthroughCasesInSwitch": true
|
||||
},
|
||||
"include": ["src"]
|
||||
}
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"files": [],
|
||||
"references": [
|
||||
{ "path": "./tsconfig.app.json" },
|
||||
{ "path": "./tsconfig.node.json" }
|
||||
]
|
||||
}
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo",
|
||||
"target": "es2023",
|
||||
"lib": ["ES2023"],
|
||||
"module": "esnext",
|
||||
"types": ["node"],
|
||||
"skipLibCheck": true,
|
||||
|
||||
/* Bundler mode */
|
||||
"moduleResolution": "bundler",
|
||||
"allowImportingTsExtensions": true,
|
||||
"verbatimModuleSyntax": true,
|
||||
"moduleDetection": "force",
|
||||
"noEmit": true,
|
||||
|
||||
/* Linting */
|
||||
"noUnusedLocals": true,
|
||||
"noUnusedParameters": true,
|
||||
"erasableSyntaxOnly": true,
|
||||
"noFallthroughCasesInSwitch": true
|
||||
},
|
||||
"include": ["vite.config.ts"]
|
||||
}
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
import { defineConfig } from 'vite'
|
||||
import react from '@vitejs/plugin-react'
|
||||
|
||||
// https://vite.dev/config/
|
||||
export default defineConfig({
|
||||
plugins: [react()],
|
||||
})
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
{
|
||||
"name": "workflowy",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://git.aggtaa.com/anton/workflowy.git"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"type": "commonjs"
|
||||
}
|
||||
Loading…
Reference in New Issue