This commit is contained in:
Michael Zhang 2023-06-12 20:09:21 -05:00
parent 78e5d6df3d
commit 6405c06646
25 changed files with 184 additions and 1131 deletions

184
package-lock.json generated
View file

@ -1935,6 +1935,134 @@
"node": ">= 10" "node": ">= 10"
} }
}, },
"node_modules/@tauri-apps/cli-darwin-x64": {
"version": "1.3.1",
"resolved": "https://registry.npmjs.org/@tauri-apps/cli-darwin-x64/-/cli-darwin-x64-1.3.1.tgz",
"integrity": "sha512-fKcAUPVFO3jfDKXCSDGY0MhZFF/wDtx3rgFnogWYu4knk38o9RaqRkvMvqJhLYPuWaEM5h6/z1dRrr9KKCbrVg==",
"cpu": [
"x64"
],
"dev": true,
"optional": true,
"os": [
"darwin"
],
"engines": {
"node": ">= 10"
}
},
"node_modules/@tauri-apps/cli-linux-arm-gnueabihf": {
"version": "1.3.1",
"resolved": "https://registry.npmjs.org/@tauri-apps/cli-linux-arm-gnueabihf/-/cli-linux-arm-gnueabihf-1.3.1.tgz",
"integrity": "sha512-+4H0dv8ltJHYu/Ma1h9ixUPUWka9EjaYa8nJfiMsdCI4LJLNE6cPveE7RmhZ59v9GW1XB108/k083JUC/OtGvA==",
"cpu": [
"arm"
],
"dev": true,
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">= 10"
}
},
"node_modules/@tauri-apps/cli-linux-arm64-gnu": {
"version": "1.3.1",
"resolved": "https://registry.npmjs.org/@tauri-apps/cli-linux-arm64-gnu/-/cli-linux-arm64-gnu-1.3.1.tgz",
"integrity": "sha512-Pj3odVO1JAxLjYmoXKxcrpj/tPxcA8UP8N06finhNtBtBaxAjrjjxKjO4968KB0BUH7AASIss9EL4Tr0FGnDuw==",
"cpu": [
"arm64"
],
"dev": true,
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">= 10"
}
},
"node_modules/@tauri-apps/cli-linux-arm64-musl": {
"version": "1.3.1",
"resolved": "https://registry.npmjs.org/@tauri-apps/cli-linux-arm64-musl/-/cli-linux-arm64-musl-1.3.1.tgz",
"integrity": "sha512-tA0JdDLPFaj42UDIVcF2t8V0tSha40rppcmAR/MfQpTCxih6399iMjwihz9kZE1n4b5O4KTq9GliYo50a8zYlQ==",
"cpu": [
"arm64"
],
"dev": true,
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">= 10"
}
},
"node_modules/@tauri-apps/cli-linux-x64-gnu": {
"version": "1.3.1",
"resolved": "https://registry.npmjs.org/@tauri-apps/cli-linux-x64-gnu/-/cli-linux-x64-gnu-1.3.1.tgz",
"integrity": "sha512-FDU+Mnvk6NLkqQimcNojdKpMN4Y3W51+SQl+NqG9AFCWprCcSg62yRb84751ujZuf2MGT8HQOfmd0i77F4Q3tQ==",
"cpu": [
"x64"
],
"dev": true,
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">= 10"
}
},
"node_modules/@tauri-apps/cli-linux-x64-musl": {
"version": "1.3.1",
"resolved": "https://registry.npmjs.org/@tauri-apps/cli-linux-x64-musl/-/cli-linux-x64-musl-1.3.1.tgz",
"integrity": "sha512-MpO3akXFmK8lZYEbyQRDfhdxz1JkTBhonVuz5rRqxwA7gnGWHa1aF1+/2zsy7ahjB2tQ9x8DDFDMdVE20o9HrA==",
"cpu": [
"x64"
],
"dev": true,
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">= 10"
}
},
"node_modules/@tauri-apps/cli-win32-ia32-msvc": {
"version": "1.3.1",
"resolved": "https://registry.npmjs.org/@tauri-apps/cli-win32-ia32-msvc/-/cli-win32-ia32-msvc-1.3.1.tgz",
"integrity": "sha512-9Boeo3K5sOrSBAZBuYyGkpV2RfnGQz3ZhGJt4hE6P+HxRd62lS6+qDKAiw1GmkZ0l1drc2INWrNeT50gwOKwIQ==",
"cpu": [
"ia32"
],
"dev": true,
"optional": true,
"os": [
"win32"
],
"engines": {
"node": ">= 10"
}
},
"node_modules/@tauri-apps/cli-win32-x64-msvc": {
"version": "1.3.1",
"resolved": "https://registry.npmjs.org/@tauri-apps/cli-win32-x64-msvc/-/cli-win32-x64-msvc-1.3.1.tgz",
"integrity": "sha512-wMrTo91hUu5CdpbElrOmcZEoJR4aooTG+fbtcc87SMyPGQy1Ux62b+ZdwLvL1sVTxnIm//7v6QLRIWGiUjCPwA==",
"cpu": [
"x64"
],
"dev": true,
"optional": true,
"os": [
"win32"
],
"engines": {
"node": ">= 10"
}
},
"node_modules/@types/dom4": { "node_modules/@types/dom4": {
"version": "2.0.2", "version": "2.0.2",
"resolved": "https://registry.npmjs.org/@types/dom4/-/dom4-2.0.2.tgz", "resolved": "https://registry.npmjs.org/@types/dom4/-/dom4-2.0.2.tgz",
@ -5172,6 +5300,62 @@
"dev": true, "dev": true,
"optional": true "optional": true
}, },
"@tauri-apps/cli-darwin-x64": {
"version": "1.3.1",
"resolved": "https://registry.npmjs.org/@tauri-apps/cli-darwin-x64/-/cli-darwin-x64-1.3.1.tgz",
"integrity": "sha512-fKcAUPVFO3jfDKXCSDGY0MhZFF/wDtx3rgFnogWYu4knk38o9RaqRkvMvqJhLYPuWaEM5h6/z1dRrr9KKCbrVg==",
"dev": true,
"optional": true
},
"@tauri-apps/cli-linux-arm-gnueabihf": {
"version": "1.3.1",
"resolved": "https://registry.npmjs.org/@tauri-apps/cli-linux-arm-gnueabihf/-/cli-linux-arm-gnueabihf-1.3.1.tgz",
"integrity": "sha512-+4H0dv8ltJHYu/Ma1h9ixUPUWka9EjaYa8nJfiMsdCI4LJLNE6cPveE7RmhZ59v9GW1XB108/k083JUC/OtGvA==",
"dev": true,
"optional": true
},
"@tauri-apps/cli-linux-arm64-gnu": {
"version": "1.3.1",
"resolved": "https://registry.npmjs.org/@tauri-apps/cli-linux-arm64-gnu/-/cli-linux-arm64-gnu-1.3.1.tgz",
"integrity": "sha512-Pj3odVO1JAxLjYmoXKxcrpj/tPxcA8UP8N06finhNtBtBaxAjrjjxKjO4968KB0BUH7AASIss9EL4Tr0FGnDuw==",
"dev": true,
"optional": true
},
"@tauri-apps/cli-linux-arm64-musl": {
"version": "1.3.1",
"resolved": "https://registry.npmjs.org/@tauri-apps/cli-linux-arm64-musl/-/cli-linux-arm64-musl-1.3.1.tgz",
"integrity": "sha512-tA0JdDLPFaj42UDIVcF2t8V0tSha40rppcmAR/MfQpTCxih6399iMjwihz9kZE1n4b5O4KTq9GliYo50a8zYlQ==",
"dev": true,
"optional": true
},
"@tauri-apps/cli-linux-x64-gnu": {
"version": "1.3.1",
"resolved": "https://registry.npmjs.org/@tauri-apps/cli-linux-x64-gnu/-/cli-linux-x64-gnu-1.3.1.tgz",
"integrity": "sha512-FDU+Mnvk6NLkqQimcNojdKpMN4Y3W51+SQl+NqG9AFCWprCcSg62yRb84751ujZuf2MGT8HQOfmd0i77F4Q3tQ==",
"dev": true,
"optional": true
},
"@tauri-apps/cli-linux-x64-musl": {
"version": "1.3.1",
"resolved": "https://registry.npmjs.org/@tauri-apps/cli-linux-x64-musl/-/cli-linux-x64-musl-1.3.1.tgz",
"integrity": "sha512-MpO3akXFmK8lZYEbyQRDfhdxz1JkTBhonVuz5rRqxwA7gnGWHa1aF1+/2zsy7ahjB2tQ9x8DDFDMdVE20o9HrA==",
"dev": true,
"optional": true
},
"@tauri-apps/cli-win32-ia32-msvc": {
"version": "1.3.1",
"resolved": "https://registry.npmjs.org/@tauri-apps/cli-win32-ia32-msvc/-/cli-win32-ia32-msvc-1.3.1.tgz",
"integrity": "sha512-9Boeo3K5sOrSBAZBuYyGkpV2RfnGQz3ZhGJt4hE6P+HxRd62lS6+qDKAiw1GmkZ0l1drc2INWrNeT50gwOKwIQ==",
"dev": true,
"optional": true
},
"@tauri-apps/cli-win32-x64-msvc": {
"version": "1.3.1",
"resolved": "https://registry.npmjs.org/@tauri-apps/cli-win32-x64-msvc/-/cli-win32-x64-msvc-1.3.1.tgz",
"integrity": "sha512-wMrTo91hUu5CdpbElrOmcZEoJR4aooTG+fbtcc87SMyPGQy1Ux62b+ZdwLvL1sVTxnIm//7v6QLRIWGiUjCPwA==",
"dev": true,
"optional": true
},
"@types/dom4": { "@types/dom4": {
"version": "2.0.2", "version": "2.0.2",
"resolved": "https://registry.npmjs.org/@types/dom4/-/dom4-2.0.2.tgz", "resolved": "https://registry.npmjs.org/@types/dom4/-/dom4-2.0.2.tgz",

View file

@ -1,3 +0,0 @@
export default function Component() {
return <></>;
}

View file

@ -1 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="35.93" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 228"><path fill="#00D8FF" d="M210.483 73.824a171.49 171.49 0 0 0-8.24-2.597c.465-1.9.893-3.777 1.273-5.621c6.238-30.281 2.16-54.676-11.769-62.708c-13.355-7.7-35.196.329-57.254 19.526a171.23 171.23 0 0 0-6.375 5.848a155.866 155.866 0 0 0-4.241-3.917C100.759 3.829 77.587-4.822 63.673 3.233C50.33 10.957 46.379 33.89 51.995 62.588a170.974 170.974 0 0 0 1.892 8.48c-3.28.932-6.445 1.924-9.474 2.98C17.309 83.498 0 98.307 0 113.668c0 15.865 18.582 31.778 46.812 41.427a145.52 145.52 0 0 0 6.921 2.165a167.467 167.467 0 0 0-2.01 9.138c-5.354 28.2-1.173 50.591 12.134 58.266c13.744 7.926 36.812-.22 59.273-19.855a145.567 145.567 0 0 0 5.342-4.923a168.064 168.064 0 0 0 6.92 6.314c21.758 18.722 43.246 26.282 56.54 18.586c13.731-7.949 18.194-32.003 12.4-61.268a145.016 145.016 0 0 0-1.535-6.842c1.62-.48 3.21-.974 4.76-1.488c29.348-9.723 48.443-25.443 48.443-41.52c0-15.417-17.868-30.326-45.517-39.844Zm-6.365 70.984c-1.4.463-2.836.91-4.3 1.345c-3.24-10.257-7.612-21.163-12.963-32.432c5.106-11 9.31-21.767 12.459-31.957c2.619.758 5.16 1.557 7.61 2.4c23.69 8.156 38.14 20.213 38.14 29.504c0 9.896-15.606 22.743-40.946 31.14Zm-10.514 20.834c2.562 12.94 2.927 24.64 1.23 33.787c-1.524 8.219-4.59 13.698-8.382 15.893c-8.067 4.67-25.32-1.4-43.927-17.412a156.726 156.726 0 0 1-6.437-5.87c7.214-7.889 14.423-17.06 21.459-27.246c12.376-1.098 24.068-2.894 34.671-5.345a134.17 134.17 0 0 1 1.386 6.193ZM87.276 214.515c-7.882 2.783-14.16 2.863-17.955.675c-8.075-4.657-11.432-22.636-6.853-46.752a156.923 156.923 0 0 1 1.869-8.499c10.486 2.32 22.093 3.988 34.498 4.994c7.084 9.967 14.501 19.128 21.976 27.15a134.668 134.668 0 0 1-4.877 4.492c-9.933 8.682-19.886 14.842-28.658 17.94ZM50.35 144.747c-12.483-4.267-22.792-9.812-29.858-15.863c-6.35-5.437-9.555-10.836-9.555-15.216c0-9.322 13.897-21.212 37.076-29.293c2.813-.98 5.757-1.905 8.812-2.773c3.204 10.42 7.406 21.315 12.477 32.332c-5.137 11.18-9.399 22.249-12.634 32.792a134.718 134.718 0 0 1-6.318-1.979Zm12.378-84.26c-4.811-24.587-1.616-43.134 6.425-47.789c8.564-4.958 27.502 2.111 47.463 19.835a144.318 144.318 0 0 1 3.841 3.545c-7.438 7.987-14.787 17.08-21.808 26.988c-12.04 1.116-23.565 2.908-34.161 5.309a160.342 160.342 0 0 1-1.76-7.887Zm110.427 27.268a347.8 347.8 0 0 0-7.785-12.803c8.168 1.033 15.994 2.404 23.343 4.08c-2.206 7.072-4.956 14.465-8.193 22.045a381.151 381.151 0 0 0-7.365-13.322Zm-45.032-43.861c5.044 5.465 10.096 11.566 15.065 18.186a322.04 322.04 0 0 0-30.257-.006c4.974-6.559 10.069-12.652 15.192-18.18ZM82.802 87.83a323.167 323.167 0 0 0-7.227 13.238c-3.184-7.553-5.909-14.98-8.134-22.152c7.304-1.634 15.093-2.97 23.209-3.984a321.524 321.524 0 0 0-7.848 12.897Zm8.081 65.352c-8.385-.936-16.291-2.203-23.593-3.793c2.26-7.3 5.045-14.885 8.298-22.6a321.187 321.187 0 0 0 7.257 13.246c2.594 4.48 5.28 8.868 8.038 13.147Zm37.542 31.03c-5.184-5.592-10.354-11.779-15.403-18.433c4.902.192 9.899.29 14.978.29c5.218 0 10.376-.117 15.453-.343c-4.985 6.774-10.018 12.97-15.028 18.486Zm52.198-57.817c3.422 7.8 6.306 15.345 8.596 22.52c-7.422 1.694-15.436 3.058-23.88 4.071a382.417 382.417 0 0 0 7.859-13.026a347.403 347.403 0 0 0 7.425-13.565Zm-16.898 8.101a358.557 358.557 0 0 1-12.281 19.815a329.4 329.4 0 0 1-23.444.823c-7.967 0-15.716-.248-23.178-.732a310.202 310.202 0 0 1-12.513-19.846h.001a307.41 307.41 0 0 1-10.923-20.627a310.278 310.278 0 0 1 10.89-20.637l-.001.001a307.318 307.318 0 0 1 12.413-19.761c7.613-.576 15.42-.876 23.31-.876H128c7.926 0 15.743.303 23.354.883a329.357 329.357 0 0 1 12.335 19.695a358.489 358.489 0 0 1 11.036 20.54a329.472 329.472 0 0 1-11 20.722Zm22.56-122.124c8.572 4.944 11.906 24.881 6.52 51.026c-.344 1.668-.73 3.367-1.15 5.09c-10.622-2.452-22.155-4.275-34.23-5.408c-7.034-10.017-14.323-19.124-21.64-27.008a160.789 160.789 0 0 1 5.888-5.4c18.9-16.447 36.564-22.941 44.612-18.3ZM128 90.808c12.625 0 22.86 10.235 22.86 22.86s-10.235 22.86-22.86 22.86s-22.86-10.235-22.86-22.86s10.235-22.86 22.86-22.86Z"></path></svg>

Before

Width:  |  Height:  |  Size: 4 KiB

View file

@ -1,51 +0,0 @@
.footer {
color: #777;
padding: 10px 15px;
height: 20px;
text-align: center;
border-top: 1px solid #e6e6e6;
&:before {
content: "";
position: absolute;
right: 0;
bottom: 0;
left: 0;
height: 50px;
overflow: hidden;
box-shadow: 0 1px 1px rgba(0, 0, 0, 0.2), 0 8px 0 -3px #f6f6f6,
0 9px 1px -3px rgba(0, 0, 0, 0.2), 0 16px 0 -6px #f6f6f6,
0 17px 2px -6px rgba(0, 0, 0, 0.2);
}
}
.todoCount {
float: left;
text-align: left;
}
.filters {
margin: 0;
padding: 0;
list-style: none;
position: absolute;
right: 0;
left: 0;
}
.filterButton {
display: inline;
a {
color: inherit;
margin: 3px;
padding: 3px 7px;
text-decoration: none;
border: 1px solid transparent;
border-radius: 3px;
&.selected {
border-color: rgba(175, 47, 47, 0.2);
}
}
}

View file

@ -1,45 +0,0 @@
import classNames from "classnames";
import { Setter } from "solid-js";
import { NowShowing } from "~/lib/todos/common";
import styles from "./Footer.module.scss";
export interface IFooterProps {
count: number;
nowShowing: NowShowing;
setNowShowing: Setter<NowShowing>;
}
export default function Footer(props: IFooterProps) {
const activeTodoWord = props.count == 1 ? "item" : "items";
const clearButton = <></>;
const showButton = (text: string, value: NowShowing) => {
return (
<li class={styles.filterButton}>
<a
href="javascript:void(0);"
onClick={(_) => props.setNowShowing(value)}
class={classNames(props.nowShowing === value && styles.selected)}
>
{text}
</a>
</li>
);
};
return (
<footer class={styles.footer}>
<span class={styles.todoCount}>
<strong>{props.count}</strong> {activeTodoWord} left
</span>
<ul class={styles.filters}>
{showButton("All", NowShowing.ALL_TODOS)}{" "}
{showButton("Active", NowShowing.ACTIVE_TODOS)}{" "}
{showButton("Completed", NowShowing.COMPLETED_TODOS)}
</ul>
{clearButton}
</footer>
);
}

View file

@ -1,127 +0,0 @@
button {
margin: 0;
padding: 0;
border: 0;
background: none;
font-size: 100%;
vertical-align: baseline;
font-family: inherit;
font-weight: inherit;
color: inherit;
-webkit-appearance: none;
appearance: none;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
.todoItem {
position: relative;
font-size: 24px;
border-bottom: 1px solid #ededed;
&:last-child {
border-bottom: none;
}
label {
word-break: break-all;
padding: 15px 15px 15px 60px;
display: block;
line-height: 1.2;
transition: color 0.4s;
}
&:hover .destroy {
display: block;
}
}
.toggle {
text-align: center;
width: 40px;
/* auto, since non-WebKit browsers doesn't support input styling */
height: auto;
position: absolute;
top: 0;
bottom: 0;
margin: auto 0;
border: none; /* Mobile Safari */
-webkit-appearance: none;
appearance: none;
opacity: 0;
label {
word-break: break-all;
padding: 15px 15px 15px 60px;
display: block;
line-height: 1.2;
transition: color 0.4s;
}
& + label {
background-image: url("data:image/svg+xml;utf8,%3Csvg%20xmlns%3D%22http%3A//www.w3.org/2000/svg%22%20width%3D%2240%22%20height%3D%2240%22%20viewBox%3D%22-10%20-18%20100%20135%22%3E%3Ccircle%20cx%3D%2250%22%20cy%3D%2250%22%20r%3D%2250%22%20fill%3D%22none%22%20stroke%3D%22%23ededed%22%20stroke-width%3D%223%22/%3E%3C/svg%3E");
background-repeat: no-repeat;
background-position: center left;
}
&:checked + label {
background-image: url("data:image/svg+xml;utf8,%3Csvg%20xmlns%3D%22http%3A//www.w3.org/2000/svg%22%20width%3D%2240%22%20height%3D%2240%22%20viewBox%3D%22-10%20-18%20100%20135%22%3E%3Ccircle%20cx%3D%2250%22%20cy%3D%2250%22%20r%3D%2250%22%20fill%3D%22none%22%20stroke%3D%22%23bddad5%22%20stroke-width%3D%223%22/%3E%3Cpath%20fill%3D%22%235dc2af%22%20d%3D%22M72%2025L42%2071%2027%2056l-4%204%2020%2020%2034-52z%22/%3E%3C/svg%3E");
}
}
.completed label {
color: #d9d9d9;
text-decoration: line-through;
}
.editing .edit {
display: block;
width: 506px;
padding: 12px 16px;
margin: 0 0 0 43px;
}
.edit {
display: block;
width: calc(100% - 43px);
padding: 12px 16px;
margin: 0 0 0 43px;
position: relative;
// margin: 0;
// width: 100%;
font-size: 24px;
font-family: inherit;
font-weight: inherit;
line-height: 1.4em;
color: inherit;
// padding: 6px;
border: 1px solid #999;
box-shadow: inset 0 -1px 5px 0 rgba(0, 0, 0, 0.2);
box-sizing: border-box;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
.destroy {
display: none;
position: absolute;
top: 0;
right: 10px;
bottom: 0;
width: 40px;
height: 40px;
margin: auto 0;
font-size: 30px;
color: #cc9a9a;
margin-bottom: 11px;
transition: color 0.2s ease-out;
&:hover {
color: #af5b5e;
}
&:after {
content: "×";
}
}

View file

@ -1,86 +0,0 @@
import classNames from "classnames";
import { batch, createSignal, Show } from "solid-js";
import styles from "./TodoItem.module.scss";
const ENTER_KEY = 13;
const ESCAPE_KEY = 27;
export interface ITodoItemProps {
title: string;
completed: boolean;
updating: boolean;
onRemove: () => Promise<void>;
onCommit: (newTitle: string) => Promise<void>;
onComplete: (completed: boolean) => Promise<void>;
}
export default function TodoItem(props: ITodoItemProps) {
const [isEditing, setIsEditing] = createSignal(false);
const [editText, setEditText] = createSignal("");
let inputBox: HTMLInputElement | undefined;
const beginEdit = () => {
batch(() => {
setEditText(props.title);
setIsEditing(true);
});
inputBox?.focus();
};
const endEditAndCommit = async () => {
await props.onCommit(editText());
setIsEditing(false);
};
const endEditAndCancel = () => {
setIsEditing(false);
};
const handleKey = async (e) => {
setEditText(e.currentTarget.value);
if (e.keyCode === ESCAPE_KEY) {
endEditAndCancel();
} else if (e.keyCode === ENTER_KEY) {
await endEditAndCommit();
}
};
const liClasses = classNames(
styles.todoItem,
props.completed ? styles.completed : null,
isEditing() ? styles.editing : null,
);
return (
<li class={liClasses}>
<Show when={!isEditing()}>
<div class={styles.view}>
<input
class={styles.toggle}
type="checkbox"
checked={props.completed}
onChange={(e) => props.onComplete(e.currentTarget.checked)}
/>
<label onDblClick={(_) => beginEdit()}>{props.title}</label>
<button
class={styles.destroy}
onClick={async () => await props.onRemove()}
/>
</div>
</Show>
<Show when={isEditing()}>
<input
class={styles.edit}
ref={inputBox}
value={editText()}
onBlur={endEditAndCommit}
onSubmit={endEditAndCommit}
onKeyDown={handleKey}
onChange={(e) => setEditText(e.currentTarget.value)}
/>
</Show>
</li>
);
}

View file

@ -1,64 +0,0 @@
import { Node, NodeMeta } from "@prisma/client";
export interface FetchedNode extends Node {
metadata: NodeMeta[];
}
export interface IFindManyNodesRequest {
select_keys?: IMetaKey[];
take?: number;
}
export interface IRegisterAppRequest {
name: string;
}
export interface IMetaKey {
appId: string;
appKey: string;
}
export interface IGetNodeRequest {
node_id: string;
}
export interface ICreateNodeRequest {
/**
* A label for humans. This is not used by the database in any way, it's just
* something to print when debugging.
*/
label: string;
/**
* A mapping from labels to node creation requests.
*/
other_nodes?: Map<string, ICreateNodeRequest>;
/**
* A set of edges, using the IDs in auxiliary_nodes.
*/
edges?: Set<ICreateEdgeRequest>;
/**
* A set of metadata keys to values
*/
metadata_keys?: Map<IMetaKey, string>;
}
export interface IUpdateNodeRequest {
id: string;
/** A set of metadata keys to values */
metadata_keys?: Map<IMetaKey, string>;
}
export interface IRemoveNodeRequest {
id: string;
}
export interface ICreateEdgeRequest {
label: string;
from_node: string;
to_node: string;
metadata: unknown;
}

View file

@ -1,10 +0,0 @@
// import { PrismaClient } from "@prisma/client";
// export const db = new PrismaClient();
import { Database } from "~/core/db";
export const db = new Database();
export const todosApp = await db.registerApp({
name: "todos",
});

View file

@ -1,97 +0,0 @@
/*
import { PrismaClient } from "@prisma/client";
import { redirect } from "solid-start/server";
import { createCookieSessionStorage } from "solid-start/session";
import { db } from ".";
type LoginForm = {
username: string;
password: string;
};
export async function register({ username, password }: LoginForm) {
return db.user.create({
data: { username: username, password },
});
}
export async function login({ username, password }: LoginForm) {
const user = await db.user.findUnique({ where: { username } });
if (!user) return null;
const isCorrectPassword = password === user.password;
if (!isCorrectPassword) return null;
return user;
}
const sessionSecret = import.meta.env.SESSION_SECRET;
const storage = createCookieSessionStorage({
cookie: {
name: "RJ_session",
// secure doesn't work on localhost for Safari
// https://web.dev/when-to-use-local-https/
secure: true,
secrets: ["hello"],
sameSite: "lax",
path: "/",
maxAge: 60 * 60 * 24 * 30,
httpOnly: true,
},
});
export function getUserSession(request: Request) {
return storage.getSession(request.headers.get("Cookie"));
}
export async function getUserId(request: Request) {
const session = await getUserSession(request);
const userId = session.get("userId");
if (!userId || typeof userId !== "string") return null;
return userId;
}
export async function requireUserId(
request: Request,
redirectTo: string = new URL(request.url).pathname
) {
const session = await getUserSession(request);
const userId = session.get("userId");
if (!userId || typeof userId !== "string") {
const searchParams = new URLSearchParams([["redirectTo", redirectTo]]);
throw redirect(`/login?${searchParams}`);
}
return userId;
}
export async function getUser(db: PrismaClient, request: Request) {
const userId = await getUserId(request);
if (typeof userId !== "string") {
return null;
}
try {
const user = await db.user.findUnique({ where: { id: userId } });
return user;
} catch {
throw logout(request);
}
}
export async function logout(request: Request) {
const session = await storage.getSession(request.headers.get("Cookie"));
return redirect("/login", {
headers: {
"Set-Cookie": await storage.destroySession(session),
},
});
}
export async function createUserSession(userId: string, redirectTo: string) {
const session = await storage.getSession();
session.set("userId", userId);
return redirect(redirectTo, {
headers: {
"Set-Cookie": await storage.commitSession(session),
},
});
}
*/

View file

@ -1,17 +0,0 @@
/*
import { PrismaClient } from "@prisma/client";
import { createServerData$, redirect } from "solid-start/server";
import { getUser } from "./session";
export const useUser = () =>
createServerData$(async (_, { request }) => {
const db = new PrismaClient();
const user = await getUser(db, request);
if (!user) {
throw redirect("/login");
}
return user;
});
*/

View file

@ -1,3 +0,0 @@
import { mount, StartClient } from "solid-start/entry-client";
mount(() => <StartClient />, document);

View file

@ -1,9 +0,0 @@
import {
StartServer,
createHandler,
renderAsync,
} from "solid-start/entry-server";
export default createHandler(
renderAsync((event) => <StartServer event={event} />)
);

View file

@ -1,2 +0,0 @@
export * from "./core/db";
export * from "./core/types";

View file

@ -1,23 +0,0 @@
import { createEffect } from "solid-js";
import { createStore, SetStoreFunction, Store } from "solid-js/store";
export function createTodoStore<T extends object>(
init: T
): [Store<T>, SetStoreFunction<T>] {
// const localState = localStorage.getItem(name);
const [state, setState] = createStore<T>(
init || []
// localState ? JSON.parse(localState) : init
);
createEffect(() => {
// localStorage.setItem(name, JSON.stringify(state));
});
return [state, setState];
}
export function removeIndex<T>(array: readonly T[], index: number): T[] {
return [...array.slice(0, index), ...array.slice(index + 1)];
}

View file

@ -1,5 +0,0 @@
export enum NowShowing {
ALL_TODOS = "all_todos",
ACTIVE_TODOS = "active_todos",
COMPLETED_TODOS = "completed_todos",
}

View file

@ -1,68 +0,0 @@
import { FetchedNode } from "~/core/types";
import { db, todosApp } from "~/db";
export interface ITodoItem {
id: string;
title: string;
completed: boolean;
committed: boolean;
deleted: boolean;
}
export const retrieveMeta = (node: FetchedNode, key: string) => {
const meta = node.metadata.find(
(meta) => meta.appId == todosApp.id && meta.appKey == key
);
if (!meta) return null;
const metaValue = meta.value.toString();
return JSON.parse(metaValue);
};
export const nodeToTodoItem = (node: FetchedNode) => ({
id: node.id,
title: retrieveMeta(node, "title"),
completed: retrieveMeta(node, "completed"),
committed: true,
deleted: false,
});
export async function addTodoActionImpl({ title }: { title: string }) {
const metadata_keys = new Map();
const setMeta = (appKey: string, value: any) =>
metadata_keys.set({ appId: todosApp.id, appKey }, JSON.stringify(value));
setMeta("title", title);
setMeta("completed", false);
const node = await db.createNode({
label: `todo-${title}`,
metadata_keys,
});
return node;
}
export async function updateTodoActionImpl({
id,
title,
completed,
}: {
id: string;
title: string;
completed: boolean;
}) {
const metadata_keys = new Map();
const setMeta = (appKey: string, value: any) =>
metadata_keys.set({ appId: todosApp.id, appKey }, JSON.stringify(value));
setMeta("title", title);
setMeta("completed", completed);
console.log("Updating", metadata_keys);
const node = await db.updateNode({ id, metadata_keys });
if (!node) return;
return nodeToTodoItem(node);
}
export async function removeTodoActionImpl({ id }: { id: string }) {
await db.removeNode({ id });
}

View file

@ -1,4 +0,0 @@
body {
font-family: Gordita, Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans",
"Helvetica Neue", sans-serif;
}

View file

@ -1,36 +0,0 @@
// @refresh reload
import { Suspense } from "solid-js";
import {
Body,
ErrorBoundary,
FileRoutes,
Head,
Html,
Meta,
Routes,
Scripts,
Title,
} from "solid-start";
import "./root.css";
export default function Root() {
return (
<Html lang="en">
<Head>
<Title>SolidStart - With Auth</Title>
<Meta charset="utf-8" />
<Meta name="viewport" content="width=device-width, initial-scale=1" />
</Head>
<Body>
<ErrorBoundary>
<Suspense fallback={<div>Loading</div>}>
<Routes>
<FileRoutes />
</Routes>
</Suspense>
</ErrorBoundary>
<Scripts />
</Body>
</Html>
);
}

View file

@ -1,7 +0,0 @@
export default function NotFound() {
return (
<main class="full-width">
<h1>Page Not Found</h1>
</main>
);
}

View file

@ -1,3 +0,0 @@
export default function Calendar() {
return <>Calendar</>;
}

View file

@ -1,18 +0,0 @@
import { refetchRouteData, useRouteData } from "solid-start";
import { createServerAction$ } from "solid-start/server";
export default function Home() {
/*
const user = useRouteData<typeof routeData>();
const [, { Form }] = createServerAction$((f: FormData, { request }) =>
logout(request)
); */
return (
<main class="full-width">
<h1>Hello!</h1>
<h3>Message board</h3>
<button onClick={() => refetchRouteData()}>Refresh</button>
</main>
);
}

View file

@ -1,138 +0,0 @@
/*
import { Show } from "solid-js";
import { useParams, useRouteData } from "solid-start";
import { FormError } from "solid-start/data";
import {
createServerAction$,
createServerData$,
redirect,
} from "solid-start/server";
import { db } from "~/db";
import { createUserSession, getUser, login, register } from "~/db/session";
function validateUsername(username: unknown) {
if (typeof username !== "string" || username.length < 3) {
return `Usernames must be at least 3 characters long`;
}
}
function validatePassword(password: unknown) {
if (typeof password !== "string" || password.length < 6) {
return `Passwords must be at least 6 characters long`;
}
}
export function routeData() {
return createServerData$(async (_, { request }) => {
if (await getUser(db, request)) {
throw redirect("/");
}
return {};
});
}
export default function Login() {
const data = useRouteData<typeof routeData>();
const params = useParams();
const [loggingIn, { Form }] = createServerAction$(async (form: FormData) => {
const loginType = form.get("loginType");
const username = form.get("username");
const password = form.get("password");
const redirectTo = form.get("redirectTo") || "/";
if (
typeof loginType !== "string" ||
typeof username !== "string" ||
typeof password !== "string" ||
typeof redirectTo !== "string"
) {
throw new FormError(`Form not submitted correctly.`);
}
const fields = { loginType, username, password };
const fieldErrors = {
username: validateUsername(username),
password: validatePassword(password),
};
if (Object.values(fieldErrors).some(Boolean)) {
throw new FormError("Fields invalid", { fieldErrors, fields });
}
switch (loginType) {
case "login": {
const user = await login({ username, password });
if (!user) {
throw new FormError(`Username/Password combination is incorrect`, {
fields,
});
}
return createUserSession(`${user.id}`, redirectTo);
}
case "register": {
const userExists = await db.user.findUnique({ where: { username } });
if (userExists) {
throw new FormError(`User with username ${username} already exists`, {
fields,
});
}
const user = await register({ username, password });
if (!user) {
throw new FormError(
`Something went wrong trying to create a new user.`,
{
fields,
}
);
}
return createUserSession(`${user.id}`, redirectTo);
}
default: {
throw new FormError(`Login type invalid`, { fields });
}
}
});
return (
<main>
<h1>Login</h1>
<Form>
<input
type="hidden"
name="redirectTo"
value={params.redirectTo ?? "/"}
/>
<fieldset>
<legend>Login or Register?</legend>
<label>
<input type="radio" name="loginType" value="login" checked={true} />{" "}
Login
</label>
<label>
<input type="radio" name="loginType" value="register" /> Register
</label>
</fieldset>
<div>
<label for="username-input">Username</label>
<input name="username" placeholder="kody" />
</div>
<Show when={loggingIn.error?.fieldErrors?.username}>
<p role="alert">{loggingIn.error.fieldErrors.username}</p>
</Show>
<div>
<label for="password-input">Password</label>
<input name="password" type="password" placeholder="twixrox" />
</div>
<Show when={loggingIn.error?.fieldErrors?.password}>
<p role="alert">{loggingIn.error.fieldErrors.password}</p>
</Show>
<Show when={loggingIn.error}>
<p role="alert" id="error-message">
{loggingIn.error.message}
</p>
</Show>
<button type="submit">{data() ? "Login" : ""}</button>
</Form>
</main>
);
}
*/

View file

@ -1,105 +0,0 @@
.container {
min-width: 230px;
max-width: 550px;
margin: 0 auto;
}
:focus {
outline: none;
}
.main {
position: relative;
z-index: 2;
border-top: 1px solid #e6e6e6;
line-height: 1.4em;
}
.todoApp {
background: #fff;
margin: 130px 0 40px 0;
position: relative;
box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.2), 0 25px 50px 0 rgba(0, 0, 0, 0.1);
input::-webkit-input-placeholder,
input::-moz-placeholder,
input::input-placeholder {
font-style: italic;
font-weight: 300;
color: #e6e6e6;
}
h1 {
position: absolute;
top: -155px;
width: 100%;
font-size: 100px;
font-weight: 100;
text-align: center;
color: rgba(175, 47, 47, 0.15);
-webkit-text-rendering: optimizeLegibility;
-moz-text-rendering: optimizeLegibility;
text-rendering: optimizeLegibility;
}
}
.newTodo {
position: relative;
margin: 0;
width: 100%;
font-size: 24px;
font-family: inherit;
font-weight: inherit;
line-height: 1.4em;
border: 0;
color: inherit;
padding: 6px;
border: 1px solid #999;
box-shadow: inset 0 -1px 5px 0 rgba(0, 0, 0, 0.2);
box-sizing: border-box;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
padding: 16px 16px 16px 60px;
border: none;
background: rgba(0, 0, 0, 0.003);
box-shadow: inset 0 -2px 1px rgba(0, 0, 0, 0.03);
}
.toggleAll {
width: 1px;
height: 1px;
border: none; /* Mobile Safari */
opacity: 0;
position: absolute;
right: 100%;
bottom: 100%;
& + label {
width: 60px;
height: 34px;
font-size: 0;
position: absolute;
top: -52px;
left: -13px;
-webkit-transform: rotate(90deg);
transform: rotate(90deg);
&:before {
content: "";
font-size: 22px;
color: #e6e6e6;
padding: 10px 27px 10px 27px;
}
}
&:checked + label:before {
color: #737373;
}
}
.todoList {
margin: 0;
padding: 0;
list-style: none;
}

View file

@ -1,209 +0,0 @@
import { For, batch, createSignal, JSX } from "solid-js";
import { useRouteData } from "solid-start";
import { createServerAction$, createServerData$ } from "solid-start/server";
import Footer from "~/components/todos/Footer";
import styles from "./index.module.scss";
import TodoItem from "~/components/todos/TodoItem";
import { db, todosApp } from "~/db";
import { createTodoStore, removeIndex } from "~/lib/todos/client";
import {
addTodoActionImpl,
nodeToTodoItem,
removeTodoActionImpl,
ITodoItem,
updateTodoActionImpl,
} from "~/lib/todos/server";
import { NowShowing } from "~/lib/todos/common";
export function routeData() {
return createServerData$(async () => {
const nodes = await db.findManyNodes({
select_keys: [
{ appId: todosApp.id, appKey: "title" },
{ appId: todosApp.id, appKey: "completed" },
],
});
if (!nodes) return null;
const initTodos = nodes.map(nodeToTodoItem);
return { initTodos };
});
}
export default function Todos() {
const getRouteData = useRouteData<typeof routeData>();
const data = getRouteData();
if (!data) return <>Loading...</>;
const { initTodos } = data;
const [newTitle, setTitle] = createSignal("");
const [todos, setTodos] = createTodoStore<ITodoItem[]>(initTodos);
const [nowShowing, setNowShowing] = createSignal(NowShowing.ALL_TODOS);
const [adding, addTodoAction] = createServerAction$(addTodoActionImpl, {
invalidate: ["todos"],
});
const addTodo = async (e: SubmitEvent) => {
e.preventDefault();
e.stopPropagation();
const idx = todos.length;
const title = newTitle();
batch(() => {
setTodos(idx, {
title,
completed: false,
committed: false,
deleted: false,
});
setTitle("");
});
const node = await addTodoAction({ title });
batch(() => {
setTodos(idx, "id", node.id);
setTodos(idx, "committed", true);
});
};
const [updating, updateTodoAction] = createServerAction$(
updateTodoActionImpl,
{ invalidate: ["todos"] }
);
const updateNode = async (
idx: number,
prop: "title" | "completed",
newValue: any
) => {
batch(() => {
setTodos(idx, "committed", false);
setTodos(idx, prop, newValue);
});
const todoItem = todos[idx];
const updateProps = {
id: todoItem.id,
title: todoItem.title,
completed: todoItem.completed,
};
updateProps[prop] = newValue;
const node = await updateTodoAction(updateProps);
if (node) {
batch(() => {
setTodos(idx, "title", node.title);
setTodos(idx, "completed", node.completed);
setTodos(idx, "committed", true);
});
}
};
const [removing, removeTodoAction] = createServerAction$(
removeTodoActionImpl,
{ invalidate: ["todos"] }
);
const removeTodo = async (idx: number) => {
const todo = todos[idx];
batch(() => {
setTodos(idx, "deleted", true);
setTodos(idx, "committed", false);
});
await removeTodoAction({ id: todo.id });
// TODO: Is there a race condition here with the index?
setTodos((t) => removeIndex(t, idx));
};
const activeTodoCount = () =>
todos.reduce((accum, todo) => (todo.completed ? accum : accum + 1), 0);
const shownTodos = () =>
todos.filter((todo) => {
switch (nowShowing()) {
case NowShowing.ALL_TODOS:
return true;
case NowShowing.ACTIVE_TODOS:
return !todo.completed;
case NowShowing.COMPLETED_TODOS:
return todo.completed;
}
});
const todoItems = (
<For each={shownTodos()}>
{(todo, i) => {
const style: JSX.CSSProperties = {};
if (todo.deleted) style["text-decoration"] = "line-through";
return (
<TodoItem
title={todo.title}
completed={todo.completed}
updating={updating?.input?.id == todo.id && updating.pending}
onRemove={() => removeTodo(i())}
onCommit={(string) => updateNode(i(), "title", string)}
onComplete={(done) => updateNode(i(), "completed", done)}
/>
);
}}
</For>
);
let main;
if (shownTodos().length) {
main = (
<section class={styles.main}>
<input
id="toggle-all"
class={styles.toggleAll}
type="checkbox"
// onChange={(e) => this.toggleAll(e)}
checked={activeTodoCount() === 0}
/>
<label for="toggle-all">Mark all as complete</label>
<ul class={styles.todoList}>{todoItems}</ul>
</section>
);
}
let footer;
footer = (
<Footer
count={activeTodoCount()}
nowShowing={nowShowing()}
setNowShowing={setNowShowing}
/>
);
return (
<div class={styles.container}>
<div class={styles.todoApp}>
<header class={styles.header}>
<h1>todos</h1>
<form onSubmit={addTodo}>
<input
class={styles.newTodo}
required
value={newTitle()}
placeholder="What needs to be done?"
onInput={(e) => setTitle(e.currentTarget.value)}
disabled={adding.pending}
autofocus={true}
/>
</form>
</header>
{main}
{footer}
</div>
</div>
);
}