mirror of
https://github.com/vinliao/nashboard-old.git
synced 2025-12-17 04:35:15 +01:00
migrate from sveltekit to vanilla svelte
This commit is contained in:
@@ -1,15 +0,0 @@
|
|||||||
module.exports = {
|
|
||||||
root: true,
|
|
||||||
extends: ['eslint:recommended', 'prettier'],
|
|
||||||
plugins: ['svelte3'],
|
|
||||||
overrides: [{ files: ['*.svelte'], processor: 'svelte3/svelte3' }],
|
|
||||||
parserOptions: {
|
|
||||||
sourceType: 'module',
|
|
||||||
ecmaVersion: 2020
|
|
||||||
},
|
|
||||||
env: {
|
|
||||||
browser: true,
|
|
||||||
es2017: true,
|
|
||||||
node: true
|
|
||||||
}
|
|
||||||
};
|
|
||||||
12
.gitignore
vendored
12
.gitignore
vendored
@@ -1,10 +1,4 @@
|
|||||||
|
/node_modules/
|
||||||
|
/public/build/
|
||||||
|
|
||||||
.DS_Store
|
.DS_Store
|
||||||
node_modules
|
|
||||||
/build
|
|
||||||
/.svelte-kit
|
|
||||||
/package
|
|
||||||
.env
|
|
||||||
.env.*
|
|
||||||
!.env.example
|
|
||||||
.vercel
|
|
||||||
.output
|
|
||||||
|
|||||||
@@ -1,6 +0,0 @@
|
|||||||
{
|
|
||||||
"useTabs": true,
|
|
||||||
"singleQuote": true,
|
|
||||||
"trailingComma": "none",
|
|
||||||
"printWidth": 100
|
|
||||||
}
|
|
||||||
22
LICENSE
22
LICENSE
@@ -1,22 +0,0 @@
|
|||||||
MIT License
|
|
||||||
|
|
||||||
Copyright (c) 2022 Vincent Liao
|
|
||||||
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
|
||||||
in the Software without restriction, including without limitation the rights
|
|
||||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
copies of the Software, and to permit persons to whom the Software is
|
|
||||||
furnished to do so, subject to the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in all
|
|
||||||
copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
SOFTWARE.
|
|
||||||
3
README copy.md
Normal file
3
README copy.md
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
A basic Svelte and Tailwind setup.
|
||||||
|
|
||||||
|
Run `npx degit vinliao/svelte-tailwind your-app-name` to pull repo. Run `cd your-app-name`. Run `yarn` to install (or, use the `npm` equivalent). Run `yarn dev` to serve file; run `yarn run watch` to make Tailwind's CSS available to use. Both have to run when developing.
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
{
|
|
||||||
"compilerOptions": {
|
|
||||||
"baseUrl": ".",
|
|
||||||
"paths": {
|
|
||||||
"$lib": ["src/lib"],
|
|
||||||
"$lib/*": ["src/lib/*"]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"include": ["src/**/*.d.ts", "src/**/*.js", "src/**/*.svelte"]
|
|
||||||
}
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
exports.handler = async function () {
|
|
||||||
return {
|
|
||||||
statusCode: 200,
|
|
||||||
body: JSON.stringify({ message: 'Success!' }),
|
|
||||||
};
|
|
||||||
};
|
|
||||||
58
package.json
58
package.json
@@ -1,35 +1,29 @@
|
|||||||
{
|
{
|
||||||
"name": "relayed",
|
"name": "relayed",
|
||||||
"version": "0.0.1",
|
"version": "0.0.1",
|
||||||
"scripts": {
|
"private": true,
|
||||||
"dev": "svelte-kit dev",
|
"scripts": {
|
||||||
"build": "svelte-kit build",
|
"watch": "postcss public/tailwind.css -o public/app.css -w",
|
||||||
"package": "svelte-kit package",
|
"build": "rollup -c",
|
||||||
"preview": "svelte-kit preview",
|
"dev": "rollup -c -w",
|
||||||
"lint": "prettier --ignore-path .gitignore --check --plugin-search-dir=. . && eslint --ignore-path .gitignore .",
|
"start": "sirv public --no-clear"
|
||||||
"format": "prettier --ignore-path .gitignore --write --plugin-search-dir=. ."
|
},
|
||||||
},
|
"devDependencies": {
|
||||||
"devDependencies": {
|
"@rollup/plugin-commonjs": "^17.0.0",
|
||||||
"@sveltejs/adapter-auto": "next",
|
"@rollup/plugin-node-resolve": "^11.0.0",
|
||||||
"@sveltejs/kit": "next",
|
"autoprefixer": "^10.4.2",
|
||||||
"autoprefixer": "^10.4.2",
|
"postcss-cli": "^9.1.0",
|
||||||
"eslint": "^7.32.0",
|
"rollup": "^2.3.4",
|
||||||
"eslint-config-prettier": "^8.3.0",
|
"rollup-plugin-css-only": "^3.1.0",
|
||||||
"eslint-plugin-svelte3": "^3.2.1",
|
"rollup-plugin-livereload": "^2.0.0",
|
||||||
"postcss": "^8.4.5",
|
"rollup-plugin-svelte": "^7.0.0",
|
||||||
"postcss-load-config": "^3.1.1",
|
"rollup-plugin-terser": "^7.0.0",
|
||||||
"prettier": "^2.5.1",
|
"svelte": "^3.0.0",
|
||||||
"prettier-plugin-svelte": "^2.5.0",
|
"tailwindcss": "^3.0.23"
|
||||||
"svelte": "^3.46.0",
|
},
|
||||||
"svelte-preprocess": "^4.10.1",
|
"dependencies": {
|
||||||
"tailwindcss": "^3.0.12"
|
"sirv-cli": "^2.0.0",
|
||||||
},
|
"timeago.js": "^4.0.2",
|
||||||
"type": "module",
|
|
||||||
"dependencies": {
|
|
||||||
"@fontsource/fira-mono": "^4.5.0",
|
|
||||||
"@lukeed/uuid": "^2.0.0",
|
|
||||||
"cookie": "^0.4.1",
|
|
||||||
"timeago.js": "^4.0.2",
|
|
||||||
"underscore": "^1.13.2"
|
"underscore": "^1.13.2"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +0,0 @@
|
|||||||
const tailwindcss = require('tailwindcss');
|
|
||||||
const autoprefixer = require('autoprefixer');
|
|
||||||
|
|
||||||
const config = {
|
|
||||||
plugins: [
|
|
||||||
//Some plugins, like tailwindcss/nesting, need to run before Tailwind,
|
|
||||||
tailwindcss(),
|
|
||||||
//But others, like autoprefixer, need to run after,
|
|
||||||
autoprefixer
|
|
||||||
]
|
|
||||||
};
|
|
||||||
|
|
||||||
module.exports = config;
|
|
||||||
6
postcss.config.js
Normal file
6
postcss.config.js
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
module.exports = {
|
||||||
|
plugins: {
|
||||||
|
tailwindcss: {},
|
||||||
|
autoprefixer: {},
|
||||||
|
}
|
||||||
|
}
|
||||||
586
public/app.css
Normal file
586
public/app.css
Normal file
@@ -0,0 +1,586 @@
|
|||||||
|
/*
|
||||||
|
! tailwindcss v3.0.23 | MIT License | https://tailwindcss.com
|
||||||
|
*//*
|
||||||
|
1. Prevent padding and border from affecting element width. (https://github.com/mozdevs/cssremedy/issues/4)
|
||||||
|
2. Allow adding a border to an element by just adding a border-width. (https://github.com/tailwindcss/tailwindcss/pull/116)
|
||||||
|
*/
|
||||||
|
|
||||||
|
*,
|
||||||
|
::before,
|
||||||
|
::after {
|
||||||
|
box-sizing: border-box; /* 1 */
|
||||||
|
border-width: 0; /* 2 */
|
||||||
|
border-style: solid; /* 2 */
|
||||||
|
border-color: #e5e7eb; /* 2 */
|
||||||
|
}
|
||||||
|
|
||||||
|
::before,
|
||||||
|
::after {
|
||||||
|
--tw-content: '';
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
1. Use a consistent sensible line-height in all browsers.
|
||||||
|
2. Prevent adjustments of font size after orientation changes in iOS.
|
||||||
|
3. Use a more readable tab size.
|
||||||
|
4. Use the user's configured `sans` font-family by default.
|
||||||
|
*/
|
||||||
|
|
||||||
|
html {
|
||||||
|
line-height: 1.5; /* 1 */
|
||||||
|
-webkit-text-size-adjust: 100%; /* 2 */
|
||||||
|
-moz-tab-size: 4; /* 3 */
|
||||||
|
-o-tab-size: 4;
|
||||||
|
tab-size: 4; /* 3 */
|
||||||
|
font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"; /* 4 */
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
1. Remove the margin in all browsers.
|
||||||
|
2. Inherit line-height from `html` so users can set them as a class directly on the `html` element.
|
||||||
|
*/
|
||||||
|
|
||||||
|
body {
|
||||||
|
margin: 0; /* 1 */
|
||||||
|
line-height: inherit; /* 2 */
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
1. Add the correct height in Firefox.
|
||||||
|
2. Correct the inheritance of border color in Firefox. (https://bugzilla.mozilla.org/show_bug.cgi?id=190655)
|
||||||
|
3. Ensure horizontal rules are visible by default.
|
||||||
|
*/
|
||||||
|
|
||||||
|
hr {
|
||||||
|
height: 0; /* 1 */
|
||||||
|
color: inherit; /* 2 */
|
||||||
|
border-top-width: 1px; /* 3 */
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Add the correct text decoration in Chrome, Edge, and Safari.
|
||||||
|
*/
|
||||||
|
|
||||||
|
abbr:where([title]) {
|
||||||
|
-webkit-text-decoration: underline dotted;
|
||||||
|
text-decoration: underline dotted;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Remove the default font size and weight for headings.
|
||||||
|
*/
|
||||||
|
|
||||||
|
h1,
|
||||||
|
h2,
|
||||||
|
h3,
|
||||||
|
h4,
|
||||||
|
h5,
|
||||||
|
h6 {
|
||||||
|
font-size: inherit;
|
||||||
|
font-weight: inherit;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Reset links to optimize for opt-in styling instead of opt-out.
|
||||||
|
*/
|
||||||
|
|
||||||
|
a {
|
||||||
|
color: inherit;
|
||||||
|
text-decoration: inherit;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Add the correct font weight in Edge and Safari.
|
||||||
|
*/
|
||||||
|
|
||||||
|
b,
|
||||||
|
strong {
|
||||||
|
font-weight: bolder;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
1. Use the user's configured `mono` font family by default.
|
||||||
|
2. Correct the odd `em` font sizing in all browsers.
|
||||||
|
*/
|
||||||
|
|
||||||
|
code,
|
||||||
|
kbd,
|
||||||
|
samp,
|
||||||
|
pre {
|
||||||
|
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace; /* 1 */
|
||||||
|
font-size: 1em; /* 2 */
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Add the correct font size in all browsers.
|
||||||
|
*/
|
||||||
|
|
||||||
|
small {
|
||||||
|
font-size: 80%;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Prevent `sub` and `sup` elements from affecting the line height in all browsers.
|
||||||
|
*/
|
||||||
|
|
||||||
|
sub,
|
||||||
|
sup {
|
||||||
|
font-size: 75%;
|
||||||
|
line-height: 0;
|
||||||
|
position: relative;
|
||||||
|
vertical-align: baseline;
|
||||||
|
}
|
||||||
|
|
||||||
|
sub {
|
||||||
|
bottom: -0.25em;
|
||||||
|
}
|
||||||
|
|
||||||
|
sup {
|
||||||
|
top: -0.5em;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
1. Remove text indentation from table contents in Chrome and Safari. (https://bugs.chromium.org/p/chromium/issues/detail?id=999088, https://bugs.webkit.org/show_bug.cgi?id=201297)
|
||||||
|
2. Correct table border color inheritance in all Chrome and Safari. (https://bugs.chromium.org/p/chromium/issues/detail?id=935729, https://bugs.webkit.org/show_bug.cgi?id=195016)
|
||||||
|
3. Remove gaps between table borders by default.
|
||||||
|
*/
|
||||||
|
|
||||||
|
table {
|
||||||
|
text-indent: 0; /* 1 */
|
||||||
|
border-color: inherit; /* 2 */
|
||||||
|
border-collapse: collapse; /* 3 */
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
1. Change the font styles in all browsers.
|
||||||
|
2. Remove the margin in Firefox and Safari.
|
||||||
|
3. Remove default padding in all browsers.
|
||||||
|
*/
|
||||||
|
|
||||||
|
button,
|
||||||
|
input,
|
||||||
|
optgroup,
|
||||||
|
select,
|
||||||
|
textarea {
|
||||||
|
font-family: inherit; /* 1 */
|
||||||
|
font-size: 100%; /* 1 */
|
||||||
|
line-height: inherit; /* 1 */
|
||||||
|
color: inherit; /* 1 */
|
||||||
|
margin: 0; /* 2 */
|
||||||
|
padding: 0; /* 3 */
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Remove the inheritance of text transform in Edge and Firefox.
|
||||||
|
*/
|
||||||
|
|
||||||
|
button,
|
||||||
|
select {
|
||||||
|
text-transform: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
1. Correct the inability to style clickable types in iOS and Safari.
|
||||||
|
2. Remove default button styles.
|
||||||
|
*/
|
||||||
|
|
||||||
|
button,
|
||||||
|
[type='button'],
|
||||||
|
[type='reset'],
|
||||||
|
[type='submit'] {
|
||||||
|
-webkit-appearance: button; /* 1 */
|
||||||
|
background-color: transparent; /* 2 */
|
||||||
|
background-image: none; /* 2 */
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Use the modern Firefox focus style for all focusable elements.
|
||||||
|
*/
|
||||||
|
|
||||||
|
:-moz-focusring {
|
||||||
|
outline: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Remove the additional `:invalid` styles in Firefox. (https://github.com/mozilla/gecko-dev/blob/2f9eacd9d3d995c937b4251a5557d95d494c9be1/layout/style/res/forms.css#L728-L737)
|
||||||
|
*/
|
||||||
|
|
||||||
|
:-moz-ui-invalid {
|
||||||
|
box-shadow: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Add the correct vertical alignment in Chrome and Firefox.
|
||||||
|
*/
|
||||||
|
|
||||||
|
progress {
|
||||||
|
vertical-align: baseline;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Correct the cursor style of increment and decrement buttons in Safari.
|
||||||
|
*/
|
||||||
|
|
||||||
|
::-webkit-inner-spin-button,
|
||||||
|
::-webkit-outer-spin-button {
|
||||||
|
height: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
1. Correct the odd appearance in Chrome and Safari.
|
||||||
|
2. Correct the outline style in Safari.
|
||||||
|
*/
|
||||||
|
|
||||||
|
[type='search'] {
|
||||||
|
-webkit-appearance: textfield; /* 1 */
|
||||||
|
outline-offset: -2px; /* 2 */
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Remove the inner padding in Chrome and Safari on macOS.
|
||||||
|
*/
|
||||||
|
|
||||||
|
::-webkit-search-decoration {
|
||||||
|
-webkit-appearance: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
1. Correct the inability to style clickable types in iOS and Safari.
|
||||||
|
2. Change font properties to `inherit` in Safari.
|
||||||
|
*/
|
||||||
|
|
||||||
|
::-webkit-file-upload-button {
|
||||||
|
-webkit-appearance: button; /* 1 */
|
||||||
|
font: inherit; /* 2 */
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Add the correct display in Chrome and Safari.
|
||||||
|
*/
|
||||||
|
|
||||||
|
summary {
|
||||||
|
display: list-item;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Removes the default spacing and border for appropriate elements.
|
||||||
|
*/
|
||||||
|
|
||||||
|
blockquote,
|
||||||
|
dl,
|
||||||
|
dd,
|
||||||
|
h1,
|
||||||
|
h2,
|
||||||
|
h3,
|
||||||
|
h4,
|
||||||
|
h5,
|
||||||
|
h6,
|
||||||
|
hr,
|
||||||
|
figure,
|
||||||
|
p,
|
||||||
|
pre {
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
fieldset {
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
legend {
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
ol,
|
||||||
|
ul,
|
||||||
|
menu {
|
||||||
|
list-style: none;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Prevent resizing textareas horizontally by default.
|
||||||
|
*/
|
||||||
|
|
||||||
|
textarea {
|
||||||
|
resize: vertical;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
1. Reset the default placeholder opacity in Firefox. (https://github.com/tailwindlabs/tailwindcss/issues/3300)
|
||||||
|
2. Set the default placeholder color to the user's configured gray 400 color.
|
||||||
|
*/
|
||||||
|
|
||||||
|
input::-moz-placeholder, textarea::-moz-placeholder {
|
||||||
|
opacity: 1; /* 1 */
|
||||||
|
color: #9ca3af; /* 2 */
|
||||||
|
}
|
||||||
|
|
||||||
|
input:-ms-input-placeholder, textarea:-ms-input-placeholder {
|
||||||
|
opacity: 1; /* 1 */
|
||||||
|
color: #9ca3af; /* 2 */
|
||||||
|
}
|
||||||
|
|
||||||
|
input::placeholder,
|
||||||
|
textarea::placeholder {
|
||||||
|
opacity: 1; /* 1 */
|
||||||
|
color: #9ca3af; /* 2 */
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Set the default cursor for buttons.
|
||||||
|
*/
|
||||||
|
|
||||||
|
button,
|
||||||
|
[role="button"] {
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Make sure disabled buttons don't get the pointer cursor.
|
||||||
|
*/
|
||||||
|
:disabled {
|
||||||
|
cursor: default;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
1. Make replaced elements `display: block` by default. (https://github.com/mozdevs/cssremedy/issues/14)
|
||||||
|
2. Add `vertical-align: middle` to align replaced elements more sensibly by default. (https://github.com/jensimmons/cssremedy/issues/14#issuecomment-634934210)
|
||||||
|
This can trigger a poorly considered lint error in some tools but is included by design.
|
||||||
|
*/
|
||||||
|
|
||||||
|
img,
|
||||||
|
svg,
|
||||||
|
video,
|
||||||
|
canvas,
|
||||||
|
audio,
|
||||||
|
iframe,
|
||||||
|
embed,
|
||||||
|
object {
|
||||||
|
display: block; /* 1 */
|
||||||
|
vertical-align: middle; /* 2 */
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Constrain images and videos to the parent width and preserve their intrinsic aspect ratio. (https://github.com/mozdevs/cssremedy/issues/14)
|
||||||
|
*/
|
||||||
|
|
||||||
|
img,
|
||||||
|
video {
|
||||||
|
max-width: 100%;
|
||||||
|
height: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Ensure the default browser behavior of the `hidden` attribute.
|
||||||
|
*/
|
||||||
|
|
||||||
|
[hidden] {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
*, ::before, ::after {
|
||||||
|
--tw-translate-x: 0;
|
||||||
|
--tw-translate-y: 0;
|
||||||
|
--tw-rotate: 0;
|
||||||
|
--tw-skew-x: 0;
|
||||||
|
--tw-skew-y: 0;
|
||||||
|
--tw-scale-x: 1;
|
||||||
|
--tw-scale-y: 1;
|
||||||
|
--tw-pan-x: ;
|
||||||
|
--tw-pan-y: ;
|
||||||
|
--tw-pinch-zoom: ;
|
||||||
|
--tw-scroll-snap-strictness: proximity;
|
||||||
|
--tw-ordinal: ;
|
||||||
|
--tw-slashed-zero: ;
|
||||||
|
--tw-numeric-figure: ;
|
||||||
|
--tw-numeric-spacing: ;
|
||||||
|
--tw-numeric-fraction: ;
|
||||||
|
--tw-ring-inset: ;
|
||||||
|
--tw-ring-offset-width: 0px;
|
||||||
|
--tw-ring-offset-color: #fff;
|
||||||
|
--tw-ring-color: rgb(59 130 246 / 0.5);
|
||||||
|
--tw-ring-offset-shadow: 0 0 #0000;
|
||||||
|
--tw-ring-shadow: 0 0 #0000;
|
||||||
|
--tw-shadow: 0 0 #0000;
|
||||||
|
--tw-shadow-colored: 0 0 #0000;
|
||||||
|
--tw-blur: ;
|
||||||
|
--tw-brightness: ;
|
||||||
|
--tw-contrast: ;
|
||||||
|
--tw-grayscale: ;
|
||||||
|
--tw-hue-rotate: ;
|
||||||
|
--tw-invert: ;
|
||||||
|
--tw-saturate: ;
|
||||||
|
--tw-sepia: ;
|
||||||
|
--tw-drop-shadow: ;
|
||||||
|
--tw-backdrop-blur: ;
|
||||||
|
--tw-backdrop-brightness: ;
|
||||||
|
--tw-backdrop-contrast: ;
|
||||||
|
--tw-backdrop-grayscale: ;
|
||||||
|
--tw-backdrop-hue-rotate: ;
|
||||||
|
--tw-backdrop-invert: ;
|
||||||
|
--tw-backdrop-opacity: ;
|
||||||
|
--tw-backdrop-saturate: ;
|
||||||
|
--tw-backdrop-sepia: ;
|
||||||
|
}
|
||||||
|
.mx-auto {
|
||||||
|
margin-left: auto;
|
||||||
|
margin-right: auto;
|
||||||
|
}
|
||||||
|
.my-5 {
|
||||||
|
margin-top: 1.25rem;
|
||||||
|
margin-bottom: 1.25rem;
|
||||||
|
}
|
||||||
|
.my-1 {
|
||||||
|
margin-top: 0.25rem;
|
||||||
|
margin-bottom: 0.25rem;
|
||||||
|
}
|
||||||
|
.mr-3 {
|
||||||
|
margin-right: 0.75rem;
|
||||||
|
}
|
||||||
|
.mb-2 {
|
||||||
|
margin-bottom: 0.5rem;
|
||||||
|
}
|
||||||
|
.block {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
.flex {
|
||||||
|
display: flex;
|
||||||
|
}
|
||||||
|
.max-w-3xl {
|
||||||
|
max-width: 48rem;
|
||||||
|
}
|
||||||
|
.flex-1 {
|
||||||
|
flex: 1 1 0%;
|
||||||
|
}
|
||||||
|
.shrink {
|
||||||
|
flex-shrink: 1;
|
||||||
|
}
|
||||||
|
.flex-col {
|
||||||
|
flex-direction: column;
|
||||||
|
}
|
||||||
|
.items-baseline {
|
||||||
|
align-items: baseline;
|
||||||
|
}
|
||||||
|
.justify-between {
|
||||||
|
justify-content: space-between;
|
||||||
|
}
|
||||||
|
.space-y-2 > :not([hidden]) ~ :not([hidden]) {
|
||||||
|
--tw-space-y-reverse: 0;
|
||||||
|
margin-top: calc(0.5rem * calc(1 - var(--tw-space-y-reverse)));
|
||||||
|
margin-bottom: calc(0.5rem * var(--tw-space-y-reverse));
|
||||||
|
}
|
||||||
|
.space-x-2 > :not([hidden]) ~ :not([hidden]) {
|
||||||
|
--tw-space-x-reverse: 0;
|
||||||
|
margin-right: calc(0.5rem * var(--tw-space-x-reverse));
|
||||||
|
margin-left: calc(0.5rem * calc(1 - var(--tw-space-x-reverse)));
|
||||||
|
}
|
||||||
|
.self-start {
|
||||||
|
align-self: flex-start;
|
||||||
|
}
|
||||||
|
.break-words {
|
||||||
|
overflow-wrap: break-word;
|
||||||
|
}
|
||||||
|
.rounded-md {
|
||||||
|
border-radius: 0.375rem;
|
||||||
|
}
|
||||||
|
.border-l-4 {
|
||||||
|
border-left-width: 4px;
|
||||||
|
}
|
||||||
|
.border-slate-800 {
|
||||||
|
--tw-border-opacity: 1;
|
||||||
|
border-color: rgb(30 41 59 / var(--tw-border-opacity));
|
||||||
|
}
|
||||||
|
.bg-white {
|
||||||
|
--tw-bg-opacity: 1;
|
||||||
|
background-color: rgb(255 255 255 / var(--tw-bg-opacity));
|
||||||
|
}
|
||||||
|
.bg-gradient-to-r {
|
||||||
|
background-image: linear-gradient(to right, var(--tw-gradient-stops));
|
||||||
|
}
|
||||||
|
.from-pink-100 {
|
||||||
|
--tw-gradient-from: #fce7f3;
|
||||||
|
--tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to, rgb(252 231 243 / 0));
|
||||||
|
}
|
||||||
|
.to-orange-200 {
|
||||||
|
--tw-gradient-to: #fed7aa;
|
||||||
|
}
|
||||||
|
.p-3 {
|
||||||
|
padding: 0.75rem;
|
||||||
|
}
|
||||||
|
.p-2 {
|
||||||
|
padding: 0.5rem;
|
||||||
|
}
|
||||||
|
.px-4 {
|
||||||
|
padding-left: 1rem;
|
||||||
|
padding-right: 1rem;
|
||||||
|
}
|
||||||
|
.pb-3 {
|
||||||
|
padding-bottom: 0.75rem;
|
||||||
|
}
|
||||||
|
.pl-3 {
|
||||||
|
padding-left: 0.75rem;
|
||||||
|
}
|
||||||
|
.text-center {
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
.text-right {
|
||||||
|
text-align: right;
|
||||||
|
}
|
||||||
|
.font-mono {
|
||||||
|
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
|
||||||
|
}
|
||||||
|
.text-sm {
|
||||||
|
font-size: 0.875rem;
|
||||||
|
line-height: 1.25rem;
|
||||||
|
}
|
||||||
|
.text-2xl {
|
||||||
|
font-size: 1.5rem;
|
||||||
|
line-height: 2rem;
|
||||||
|
}
|
||||||
|
.text-neutral-400 {
|
||||||
|
--tw-text-opacity: 1;
|
||||||
|
color: rgb(163 163 163 / var(--tw-text-opacity));
|
||||||
|
}
|
||||||
|
.text-neutral-500 {
|
||||||
|
--tw-text-opacity: 1;
|
||||||
|
color: rgb(115 115 115 / var(--tw-text-opacity));
|
||||||
|
}
|
||||||
|
.text-orange-700 {
|
||||||
|
--tw-text-opacity: 1;
|
||||||
|
color: rgb(194 65 12 / var(--tw-text-opacity));
|
||||||
|
}
|
||||||
|
.text-neutral-600 {
|
||||||
|
--tw-text-opacity: 1;
|
||||||
|
color: rgb(82 82 82 / var(--tw-text-opacity));
|
||||||
|
}
|
||||||
|
.underline {
|
||||||
|
-webkit-text-decoration-line: underline;
|
||||||
|
text-decoration-line: underline;
|
||||||
|
}
|
||||||
|
.shadow {
|
||||||
|
--tw-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
|
||||||
|
--tw-shadow-colored: 0 1px 3px 0 var(--tw-shadow-color), 0 1px 2px -1px var(--tw-shadow-color);
|
||||||
|
box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);
|
||||||
|
}
|
||||||
|
@media (min-width: 640px) {
|
||||||
|
|
||||||
|
.sm\:invisible {
|
||||||
|
visibility: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sm\:flex {
|
||||||
|
display: flex;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sm\:w-1\/2 {
|
||||||
|
width: 50%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sm\:space-y-4 > :not([hidden]) ~ :not([hidden]) {
|
||||||
|
--tw-space-y-reverse: 0;
|
||||||
|
margin-top: calc(1rem * calc(1 - var(--tw-space-y-reverse)));
|
||||||
|
margin-bottom: calc(1rem * var(--tw-space-y-reverse));
|
||||||
|
}
|
||||||
|
}
|
||||||
BIN
public/favicon.png
Normal file
BIN
public/favicon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.1 KiB |
0
public/global.css
Normal file
0
public/global.css
Normal file
19
public/index.html
Normal file
19
public/index.html
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset='utf-8'>
|
||||||
|
<meta name='viewport' content='width=device-width,initial-scale=1'>
|
||||||
|
|
||||||
|
<title>Svelte app</title>
|
||||||
|
|
||||||
|
<link rel='icon' type='image/png' href='/favicon.png'>
|
||||||
|
<link rel='stylesheet' href='/global.css'>
|
||||||
|
<link rel='stylesheet' href='/app.css'>
|
||||||
|
<link rel='stylesheet' href='/build/bundle.css'>
|
||||||
|
|
||||||
|
<script defer src='/build/bundle.js'></script>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
3
public/tailwind.css
Normal file
3
public/tailwind.css
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
@tailwind base;
|
||||||
|
@tailwind components;
|
||||||
|
@tailwind utilities;
|
||||||
76
rollup.config.js
Normal file
76
rollup.config.js
Normal file
@@ -0,0 +1,76 @@
|
|||||||
|
import svelte from 'rollup-plugin-svelte';
|
||||||
|
import commonjs from '@rollup/plugin-commonjs';
|
||||||
|
import resolve from '@rollup/plugin-node-resolve';
|
||||||
|
import livereload from 'rollup-plugin-livereload';
|
||||||
|
import { terser } from 'rollup-plugin-terser';
|
||||||
|
import css from 'rollup-plugin-css-only';
|
||||||
|
|
||||||
|
const production = !process.env.ROLLUP_WATCH;
|
||||||
|
|
||||||
|
function serve() {
|
||||||
|
let server;
|
||||||
|
|
||||||
|
function toExit() {
|
||||||
|
if (server) server.kill(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
writeBundle() {
|
||||||
|
if (server) return;
|
||||||
|
server = require('child_process').spawn('npm', ['run', 'start', '--', '--dev'], {
|
||||||
|
stdio: ['ignore', 'inherit', 'inherit'],
|
||||||
|
shell: true
|
||||||
|
});
|
||||||
|
|
||||||
|
process.on('SIGTERM', toExit);
|
||||||
|
process.on('exit', toExit);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export default {
|
||||||
|
input: 'src/main.js',
|
||||||
|
output: {
|
||||||
|
sourcemap: true,
|
||||||
|
format: 'iife',
|
||||||
|
name: 'app',
|
||||||
|
file: 'public/build/bundle.js'
|
||||||
|
},
|
||||||
|
plugins: [
|
||||||
|
svelte({
|
||||||
|
compilerOptions: {
|
||||||
|
// enable run-time checks when not in production
|
||||||
|
dev: !production
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
// we'll extract any component CSS out into
|
||||||
|
// a separate file - better for performance
|
||||||
|
css({ output: 'bundle.css' }),
|
||||||
|
|
||||||
|
// If you have external dependencies installed from
|
||||||
|
// npm, you'll most likely need these plugins. In
|
||||||
|
// some cases you'll need additional configuration -
|
||||||
|
// consult the documentation for details:
|
||||||
|
// https://github.com/rollup/plugins/tree/master/packages/commonjs
|
||||||
|
resolve({
|
||||||
|
browser: true,
|
||||||
|
dedupe: ['svelte']
|
||||||
|
}),
|
||||||
|
commonjs(),
|
||||||
|
|
||||||
|
// In dev mode, call `npm run start` once
|
||||||
|
// the bundle has been generated
|
||||||
|
!production && serve(),
|
||||||
|
|
||||||
|
// Watch the `public` directory and refresh the
|
||||||
|
// browser on changes when not in production
|
||||||
|
!production && livereload('public'),
|
||||||
|
|
||||||
|
// If we're building for production (npm run build
|
||||||
|
// instead of npm run dev), minify
|
||||||
|
production && terser()
|
||||||
|
],
|
||||||
|
watch: {
|
||||||
|
clearScreen: false
|
||||||
|
}
|
||||||
|
};
|
||||||
121
scripts/setupTypeScript.js
Normal file
121
scripts/setupTypeScript.js
Normal file
@@ -0,0 +1,121 @@
|
|||||||
|
// @ts-check
|
||||||
|
|
||||||
|
/** This script modifies the project to support TS code in .svelte files like:
|
||||||
|
|
||||||
|
<script lang="ts">
|
||||||
|
export let name: string;
|
||||||
|
</script>
|
||||||
|
|
||||||
|
As well as validating the code for CI.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** To work on this script:
|
||||||
|
rm -rf test-template template && git clone sveltejs/template test-template && node scripts/setupTypeScript.js test-template
|
||||||
|
*/
|
||||||
|
|
||||||
|
const fs = require("fs")
|
||||||
|
const path = require("path")
|
||||||
|
const { argv } = require("process")
|
||||||
|
|
||||||
|
const projectRoot = argv[2] || path.join(__dirname, "..")
|
||||||
|
|
||||||
|
// Add deps to pkg.json
|
||||||
|
const packageJSON = JSON.parse(fs.readFileSync(path.join(projectRoot, "package.json"), "utf8"))
|
||||||
|
packageJSON.devDependencies = Object.assign(packageJSON.devDependencies, {
|
||||||
|
"svelte-check": "^2.0.0",
|
||||||
|
"svelte-preprocess": "^4.0.0",
|
||||||
|
"@rollup/plugin-typescript": "^8.0.0",
|
||||||
|
"typescript": "^4.0.0",
|
||||||
|
"tslib": "^2.0.0",
|
||||||
|
"@tsconfig/svelte": "^2.0.0"
|
||||||
|
})
|
||||||
|
|
||||||
|
// Add script for checking
|
||||||
|
packageJSON.scripts = Object.assign(packageJSON.scripts, {
|
||||||
|
"check": "svelte-check --tsconfig ./tsconfig.json"
|
||||||
|
})
|
||||||
|
|
||||||
|
// Write the package JSON
|
||||||
|
fs.writeFileSync(path.join(projectRoot, "package.json"), JSON.stringify(packageJSON, null, " "))
|
||||||
|
|
||||||
|
// mv src/main.js to main.ts - note, we need to edit rollup.config.js for this too
|
||||||
|
const beforeMainJSPath = path.join(projectRoot, "src", "main.js")
|
||||||
|
const afterMainTSPath = path.join(projectRoot, "src", "main.ts")
|
||||||
|
fs.renameSync(beforeMainJSPath, afterMainTSPath)
|
||||||
|
|
||||||
|
// Switch the app.svelte file to use TS
|
||||||
|
const appSveltePath = path.join(projectRoot, "src", "App.svelte")
|
||||||
|
let appFile = fs.readFileSync(appSveltePath, "utf8")
|
||||||
|
appFile = appFile.replace("<script>", '<script lang="ts">')
|
||||||
|
appFile = appFile.replace("export let name;", 'export let name: string;')
|
||||||
|
fs.writeFileSync(appSveltePath, appFile)
|
||||||
|
|
||||||
|
// Edit rollup config
|
||||||
|
const rollupConfigPath = path.join(projectRoot, "rollup.config.js")
|
||||||
|
let rollupConfig = fs.readFileSync(rollupConfigPath, "utf8")
|
||||||
|
|
||||||
|
// Edit imports
|
||||||
|
rollupConfig = rollupConfig.replace(`'rollup-plugin-terser';`, `'rollup-plugin-terser';
|
||||||
|
import sveltePreprocess from 'svelte-preprocess';
|
||||||
|
import typescript from '@rollup/plugin-typescript';`)
|
||||||
|
|
||||||
|
// Replace name of entry point
|
||||||
|
rollupConfig = rollupConfig.replace(`'src/main.js'`, `'src/main.ts'`)
|
||||||
|
|
||||||
|
// Add preprocessor
|
||||||
|
rollupConfig = rollupConfig.replace(
|
||||||
|
'compilerOptions:',
|
||||||
|
'preprocess: sveltePreprocess({ sourceMap: !production }),\n\t\t\tcompilerOptions:'
|
||||||
|
);
|
||||||
|
|
||||||
|
// Add TypeScript
|
||||||
|
rollupConfig = rollupConfig.replace(
|
||||||
|
'commonjs(),',
|
||||||
|
'commonjs(),\n\t\ttypescript({\n\t\t\tsourceMap: !production,\n\t\t\tinlineSources: !production\n\t\t}),'
|
||||||
|
);
|
||||||
|
fs.writeFileSync(rollupConfigPath, rollupConfig)
|
||||||
|
|
||||||
|
// Add TSConfig
|
||||||
|
const tsconfig = `{
|
||||||
|
"extends": "@tsconfig/svelte/tsconfig.json",
|
||||||
|
|
||||||
|
"include": ["src/**/*"],
|
||||||
|
"exclude": ["node_modules/*", "__sapper__/*", "public/*"]
|
||||||
|
}`
|
||||||
|
const tsconfigPath = path.join(projectRoot, "tsconfig.json")
|
||||||
|
fs.writeFileSync(tsconfigPath, tsconfig)
|
||||||
|
|
||||||
|
// Add global.d.ts
|
||||||
|
const dtsPath = path.join(projectRoot, "src", "global.d.ts")
|
||||||
|
fs.writeFileSync(dtsPath, `/// <reference types="svelte" />`)
|
||||||
|
|
||||||
|
// Delete this script, but not during testing
|
||||||
|
if (!argv[2]) {
|
||||||
|
// Remove the script
|
||||||
|
fs.unlinkSync(path.join(__filename))
|
||||||
|
|
||||||
|
// Check for Mac's DS_store file, and if it's the only one left remove it
|
||||||
|
const remainingFiles = fs.readdirSync(path.join(__dirname))
|
||||||
|
if (remainingFiles.length === 1 && remainingFiles[0] === '.DS_store') {
|
||||||
|
fs.unlinkSync(path.join(__dirname, '.DS_store'))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if the scripts folder is empty
|
||||||
|
if (fs.readdirSync(path.join(__dirname)).length === 0) {
|
||||||
|
// Remove the scripts folder
|
||||||
|
fs.rmdirSync(path.join(__dirname))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Adds the extension recommendation
|
||||||
|
fs.mkdirSync(path.join(projectRoot, ".vscode"), { recursive: true })
|
||||||
|
fs.writeFileSync(path.join(projectRoot, ".vscode", "extensions.json"), `{
|
||||||
|
"recommendations": ["svelte.svelte-vscode"]
|
||||||
|
}
|
||||||
|
`)
|
||||||
|
|
||||||
|
console.log("Converted to TypeScript.")
|
||||||
|
|
||||||
|
if (fs.existsSync(path.join(projectRoot, "node_modules"))) {
|
||||||
|
console.log("\nYou will need to re-run your dependency manager to get started.")
|
||||||
|
}
|
||||||
141
src/App.svelte
Normal file
141
src/App.svelte
Normal file
@@ -0,0 +1,141 @@
|
|||||||
|
<script>
|
||||||
|
import Count from "./Count.svelte";
|
||||||
|
import Activity from "./Activity.svelte";
|
||||||
|
import Relay from "./Relay.svelte";
|
||||||
|
import Dots from "./Dots.svelte";
|
||||||
|
import Tweet from "./Tweet.svelte";
|
||||||
|
import Kind from "./Kind.svelte";
|
||||||
|
|
||||||
|
import _ from "underscore";
|
||||||
|
|
||||||
|
// initial dummy event object
|
||||||
|
let events = [
|
||||||
|
{
|
||||||
|
message:
|
||||||
|
"Lorem ipsum dolor sit amet consectetur adipisicing elit. Ipsum suscipit dolores eos sequi. Repudiandae doloremque qui quo deserunt quidem, eum incidunt consequuntur numquam nostrum! Lorem ipsum dolor sit amet consectetur adipisicing elit. Ipsum suscipit dolores eos sequi. Repudiandae doloremque qui quo deserunt quidem, eum incidunt consequuntur numquam nostrum!",
|
||||||
|
time: 1,
|
||||||
|
pubkey: "0000000000",
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
let eventCount24h = 0;
|
||||||
|
let eventCount1h = 0;
|
||||||
|
let networkActivity = Array(24).fill(0); // array index is hour
|
||||||
|
|
||||||
|
let kind0 = 0;
|
||||||
|
let kind1 = 0;
|
||||||
|
let kind2 = 0;
|
||||||
|
let kind3 = 0;
|
||||||
|
let kind4 = 0;
|
||||||
|
let kindOther = 0;
|
||||||
|
|
||||||
|
const unixTime = Math.floor(Date.now() / 1000);
|
||||||
|
const unixTimeMinus24h = unixTime - 60 * 60 * 24;
|
||||||
|
const unixTimeMinus1h = unixTime - 60 * 60;
|
||||||
|
|
||||||
|
// taken from github.com/fiatjaf/nostr-relay-registry
|
||||||
|
const relays = [
|
||||||
|
"wss://nostr-pub.wellorder.net",
|
||||||
|
"wss://relayer.fiatjaf.com",
|
||||||
|
"wss://nostr.rocks",
|
||||||
|
"wss://rsslay.fiatjaf.com",
|
||||||
|
"wss://freedom-relay.herokuapp.com/ws",
|
||||||
|
"wss://nostr-relay.freeberty.net",
|
||||||
|
"wss://nostr.bitcoiner.social",
|
||||||
|
"wss://nostr-relay.wlvs.space",
|
||||||
|
"wss://nostr.onsats.org",
|
||||||
|
"wss://nostr-relay.untethr.me",
|
||||||
|
"wss://nostr-verified.wellorder.net",
|
||||||
|
"wss://nostr.drss.io",
|
||||||
|
"wss://nostr.unknown.place",
|
||||||
|
];
|
||||||
|
let relayActivity = Array(relays.length).fill(0);
|
||||||
|
|
||||||
|
relays.forEach((url, relayIndex) => {
|
||||||
|
let socket = new WebSocket(url);
|
||||||
|
|
||||||
|
socket.onopen = function (event) {
|
||||||
|
console.log(`Connected to ${url}`);
|
||||||
|
|
||||||
|
// pull all event 24h
|
||||||
|
socket.send(
|
||||||
|
JSON.stringify(["REQ", "foobar", { since: unixTimeMinus24h }])
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
// // take data and parse here
|
||||||
|
socket.onmessage = function (incomingPayload) {
|
||||||
|
// spits out lots of error when parsing
|
||||||
|
// Uncaught SyntaxError: Unexpected token P in JSON at position 0
|
||||||
|
const payload = JSON.parse(incomingPayload.data);
|
||||||
|
const event = payload[2];
|
||||||
|
const eventDate = new Date(event.created_at * 1000);
|
||||||
|
|
||||||
|
// count total event
|
||||||
|
eventCount24h++;
|
||||||
|
if (event.created_at > unixTimeMinus1h) eventCount1h++;
|
||||||
|
|
||||||
|
// count kinds
|
||||||
|
if (event.kind == "0") kind0++;
|
||||||
|
// metadata
|
||||||
|
else if (event.kind == "1") kind1++;
|
||||||
|
// tweet
|
||||||
|
else if (event.kind == "2") kind2++;
|
||||||
|
// relay share
|
||||||
|
else if (event.kind == "3") kind3++;
|
||||||
|
// contact list
|
||||||
|
else if (event.kind == "4") kind4++;
|
||||||
|
// private messages
|
||||||
|
else kindOther++;
|
||||||
|
|
||||||
|
// count peak event
|
||||||
|
const eventHour = eventDate.getUTCHours();
|
||||||
|
networkActivity[eventHour]++;
|
||||||
|
|
||||||
|
// count relay activity
|
||||||
|
relayActivity[relayIndex]++;
|
||||||
|
|
||||||
|
// show tweets
|
||||||
|
let tweet = {
|
||||||
|
message: event.content,
|
||||||
|
time: parseInt(event.created_at),
|
||||||
|
id: event.id,
|
||||||
|
pubkey: event.pubkey,
|
||||||
|
};
|
||||||
|
events.push(tweet);
|
||||||
|
const uniqueEvents = _.uniq(events);
|
||||||
|
const sortedEvents = _.sortBy(uniqueEvents, "time");
|
||||||
|
events = sortedEvents.reverse().slice(0, 20);
|
||||||
|
};
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<section class="bg-gradient-to-r from-pink-100 to-orange-200">
|
||||||
|
<div class="p-2 max-w-3xl mx-auto sm:flex">
|
||||||
|
<div class="sm:w-1/2 space-y-2 sm:space-y-4">
|
||||||
|
<Count {eventCount1h} {eventCount24h} />
|
||||||
|
<Kind {kind0} {kind1} {kind2} {kind3} {kind4} {kindOther} />
|
||||||
|
<Activity {networkActivity} />
|
||||||
|
<Relay {relays} {relayActivity} />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="sm:invisible">
|
||||||
|
<Dots />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="rounded-md shadow p-3 bg-white sm:w-1/2">
|
||||||
|
<span class="block text-center pb-3 text-sm text-neutral-400 font-mono"
|
||||||
|
>NOSTR NETWORK'S LATEST EVENTS</span
|
||||||
|
>
|
||||||
|
<div class="flex flex-col">
|
||||||
|
{#each events as tweet}
|
||||||
|
<Tweet
|
||||||
|
time={tweet.time}
|
||||||
|
pubkey={tweet.pubkey}
|
||||||
|
message={tweet.message}
|
||||||
|
/>
|
||||||
|
{/each}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
/* Write your global styles here, in PostCSS syntax */
|
|
||||||
|
|
||||||
@import '@fontsource/fira-mono';
|
|
||||||
|
|
||||||
@tailwind base;
|
|
||||||
|
|
||||||
@tailwind components;
|
|
||||||
|
|
||||||
@tailwind utilities;
|
|
||||||
13
src/app.html
13
src/app.html
@@ -1,13 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html lang="en">
|
|
||||||
<head>
|
|
||||||
<meta charset="utf-8" />
|
|
||||||
<meta name="description" content="Svelte demo app" />
|
|
||||||
<link rel="icon" href="%svelte.assets%/favicon.png" />
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
||||||
%svelte.head%
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<div>%svelte.body%</div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
23
src/hooks.js
23
src/hooks.js
@@ -1,23 +0,0 @@
|
|||||||
import cookie from 'cookie';
|
|
||||||
import { v4 as uuid } from '@lukeed/uuid';
|
|
||||||
|
|
||||||
export const handle = async ({ event, resolve }) => {
|
|
||||||
const cookies = cookie.parse(event.request.headers.get('cookie') || '');
|
|
||||||
event.locals.userid = cookies.userid || uuid();
|
|
||||||
|
|
||||||
const response = await resolve(event);
|
|
||||||
|
|
||||||
if (!cookies.userid) {
|
|
||||||
// if this is the first time the user has visited this app,
|
|
||||||
// set a cookie so that we recognise them when they return
|
|
||||||
response.headers.set(
|
|
||||||
'set-cookie',
|
|
||||||
cookie.serialize('userid', event.locals.userid, {
|
|
||||||
path: '/',
|
|
||||||
httpOnly: true
|
|
||||||
})
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return response;
|
|
||||||
};
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
<div class="rounded-md shadow border p-3">
|
|
||||||
<div class="flex">
|
|
||||||
<div class="flex-1 text-center">
|
|
||||||
<span class="block text-center mb-1 text-xs text-neutral-400">RELAY STORES</span>
|
|
||||||
<span class="text-2xl">~75</span>
|
|
||||||
<span class="text-neutral-400">evt/24h</span>
|
|
||||||
</div>
|
|
||||||
<div class="flex-1 text-center">
|
|
||||||
<span class="block text-center mb-1 text-xs text-neutral-400">NETWORK STORES</span>
|
|
||||||
<span class="text-2xl">~32</span>
|
|
||||||
<span class="text-neutral-400">mb/24h</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
<div class="rounded-md shadow border p-3">
|
|
||||||
<span class="block text-center pb-3 text-xs text-neutral-400">DATA STORED BY NETWORK</span>
|
|
||||||
<div class="flex">
|
|
||||||
<div class="flex-1 text-center">
|
|
||||||
<span class="text-2xl">3</span>
|
|
||||||
<span class="text-neutral-400">mb/hr</span>
|
|
||||||
</div>
|
|
||||||
<div class="flex-1 text-center">
|
|
||||||
<span class="text-2xl">32</span>
|
|
||||||
<span class="text-neutral-400">mb/24hr</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
<script>
|
|
||||||
import Tweet from "./Tweet.svelte";
|
|
||||||
export let events; // events are still actually very messy
|
|
||||||
const uniqueEvents = [...new Set(events)];
|
|
||||||
const sortedEvents = uniqueEvents.sort((a, b) => {
|
|
||||||
return b.created_at - a.created_at
|
|
||||||
}).slice(0, 20);
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<div class="rounded-md shadow border p-3">
|
|
||||||
<span class="block text-center pb-3 text-xs text-neutral-400">NOSTR NETWORK'S LATEST EVENTS</span>
|
|
||||||
<div class="flex flex-col">
|
|
||||||
<!-- <p>{events.length}</p> -->
|
|
||||||
{#each sortedEvents as event}
|
|
||||||
<Tweet
|
|
||||||
message={event.content}
|
|
||||||
time={event.created_at}
|
|
||||||
pubkey={event.pubkey}
|
|
||||||
/>
|
|
||||||
{/each}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
<script>
|
|
||||||
export let time;
|
|
||||||
export let message;
|
|
||||||
export let pubkey;
|
|
||||||
export let depth = 0;
|
|
||||||
// TODO: set border color depending on depth
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<div style:padding-left={depth * 0.75 + "rem"}>
|
|
||||||
<div class="border-l-4 border-slate-800 pl-2 pr-3 py-1 my-1 ml-3 rounded-md">
|
|
||||||
<div class="flex justify-between">
|
|
||||||
<span class="font-bold">{pubkey}</span>
|
|
||||||
<span class="text-neutral-400">{time}</span>
|
|
||||||
</div>
|
|
||||||
<div class="mb-2 break-words">{message}</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
<script>
|
|
||||||
export let eventCount1h;
|
|
||||||
export let eventCount24h;
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<div class="rounded-md shadow p-3 bg-white">
|
|
||||||
<span class="block text-center pb-3 text-xs text-neutral-400">NOSTR NETWORK'S EVENT COUNT</span>
|
|
||||||
<div class="flex">
|
|
||||||
<div class="flex-1 text-center">
|
|
||||||
<span class="text-2xl">{eventCount1h}</span>
|
|
||||||
<span class="text-neutral-400">last 1h</span>
|
|
||||||
</div>
|
|
||||||
<div class="flex-1 text-center">
|
|
||||||
<span class="text-2xl">{eventCount24h}</span>
|
|
||||||
<span class="text-neutral-400">last 24h</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
@@ -1,55 +0,0 @@
|
|||||||
import { invalidate } from '$app/navigation';
|
|
||||||
|
|
||||||
// this action (https://svelte.dev/tutorial/actions) allows us to
|
|
||||||
// progressively enhance a <form> that already works without JS
|
|
||||||
export function enhance(form, { pending, error, result } = {}) {
|
|
||||||
let current_token;
|
|
||||||
|
|
||||||
async function handle_submit(e) {
|
|
||||||
const token = (current_token = {});
|
|
||||||
|
|
||||||
e.preventDefault();
|
|
||||||
|
|
||||||
const data = new FormData(form);
|
|
||||||
|
|
||||||
if (pending) pending({ data, form });
|
|
||||||
|
|
||||||
try {
|
|
||||||
const response = await fetch(form.action, {
|
|
||||||
method: form.method,
|
|
||||||
headers: {
|
|
||||||
accept: 'application/json'
|
|
||||||
},
|
|
||||||
body: data
|
|
||||||
});
|
|
||||||
|
|
||||||
if (token !== current_token) return;
|
|
||||||
|
|
||||||
if (response.ok) {
|
|
||||||
if (result) result({ data, form, response });
|
|
||||||
|
|
||||||
const url = new URL(form.action);
|
|
||||||
url.search = url.hash = '';
|
|
||||||
invalidate(url.href);
|
|
||||||
} else if (error) {
|
|
||||||
error({ data, form, error: null, response });
|
|
||||||
} else {
|
|
||||||
console.error(await response.text());
|
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
if (error) {
|
|
||||||
error({ data, form, error: e, response: null });
|
|
||||||
} else {
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
form.addEventListener('submit', handle_submit);
|
|
||||||
|
|
||||||
return {
|
|
||||||
destroy() {
|
|
||||||
form.removeEventListener('submit', handle_submit);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
@@ -1,124 +0,0 @@
|
|||||||
<script>
|
|
||||||
import { page } from '$app/stores';
|
|
||||||
import logo from './svelte-logo.svg';
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<header>
|
|
||||||
<div class="corner">
|
|
||||||
<a href="https://kit.svelte.dev">
|
|
||||||
<img src={logo} alt="SvelteKit" />
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<nav>
|
|
||||||
<svg viewBox="0 0 2 3" aria-hidden="true">
|
|
||||||
<path d="M0,0 L1,2 C1.5,3 1.5,3 2,3 L2,0 Z" />
|
|
||||||
</svg>
|
|
||||||
<ul>
|
|
||||||
<li class:active={$page.url.pathname === '/'}><a sveltekit:prefetch href="/">Home</a></li>
|
|
||||||
<li class:active={$page.url.pathname === '/about'}>
|
|
||||||
<a sveltekit:prefetch href="/about">About</a>
|
|
||||||
</li>
|
|
||||||
<li class:active={$page.url.pathname === '/todos'}>
|
|
||||||
<a sveltekit:prefetch href="/todos">Todos</a>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
<svg viewBox="0 0 2 3" aria-hidden="true">
|
|
||||||
<path d="M0,0 L0,3 C0.5,3 0.5,3 1,2 L2,0 Z" />
|
|
||||||
</svg>
|
|
||||||
</nav>
|
|
||||||
|
|
||||||
<div class="corner">
|
|
||||||
<!-- TODO put something else here? github link? -->
|
|
||||||
</div>
|
|
||||||
</header>
|
|
||||||
|
|
||||||
<style>
|
|
||||||
header {
|
|
||||||
display: flex;
|
|
||||||
justify-content: space-between;
|
|
||||||
}
|
|
||||||
|
|
||||||
.corner {
|
|
||||||
width: 3em;
|
|
||||||
height: 3em;
|
|
||||||
}
|
|
||||||
|
|
||||||
.corner a {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
width: 100%;
|
|
||||||
height: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.corner img {
|
|
||||||
width: 2em;
|
|
||||||
height: 2em;
|
|
||||||
object-fit: contain;
|
|
||||||
}
|
|
||||||
|
|
||||||
nav {
|
|
||||||
display: flex;
|
|
||||||
justify-content: center;
|
|
||||||
--background: rgba(255, 255, 255, 0.7);
|
|
||||||
}
|
|
||||||
|
|
||||||
svg {
|
|
||||||
width: 2em;
|
|
||||||
height: 3em;
|
|
||||||
display: block;
|
|
||||||
}
|
|
||||||
|
|
||||||
path {
|
|
||||||
fill: var(--background);
|
|
||||||
}
|
|
||||||
|
|
||||||
ul {
|
|
||||||
position: relative;
|
|
||||||
padding: 0;
|
|
||||||
margin: 0;
|
|
||||||
height: 3em;
|
|
||||||
display: flex;
|
|
||||||
justify-content: center;
|
|
||||||
align-items: center;
|
|
||||||
list-style: none;
|
|
||||||
background: var(--background);
|
|
||||||
background-size: contain;
|
|
||||||
}
|
|
||||||
|
|
||||||
li {
|
|
||||||
position: relative;
|
|
||||||
height: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
li.active::before {
|
|
||||||
--size: 6px;
|
|
||||||
content: '';
|
|
||||||
width: 0;
|
|
||||||
height: 0;
|
|
||||||
position: absolute;
|
|
||||||
top: 0;
|
|
||||||
left: calc(50% - var(--size));
|
|
||||||
border: var(--size) solid transparent;
|
|
||||||
border-top: var(--size) solid var(--accent-color);
|
|
||||||
}
|
|
||||||
|
|
||||||
nav a {
|
|
||||||
display: flex;
|
|
||||||
height: 100%;
|
|
||||||
align-items: center;
|
|
||||||
padding: 0 1em;
|
|
||||||
color: var(--heading-color);
|
|
||||||
font-weight: 700;
|
|
||||||
font-size: 0.8rem;
|
|
||||||
text-transform: uppercase;
|
|
||||||
letter-spacing: 0.1em;
|
|
||||||
text-decoration: none;
|
|
||||||
transition: color 0.2s linear;
|
|
||||||
}
|
|
||||||
|
|
||||||
a:hover {
|
|
||||||
color: var(--accent-color);
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
<svg xmlns="http://www.w3.org/2000/svg" width="107" height="128" viewBox="0 0 107 128"><title>svelte-logo</title><path d="M94.1566,22.8189c-10.4-14.8851-30.94-19.2971-45.7914-9.8348L22.2825,29.6078A29.9234,29.9234,0,0,0,8.7639,49.6506a31.5136,31.5136,0,0,0,3.1076,20.2318A30.0061,30.0061,0,0,0,7.3953,81.0653a31.8886,31.8886,0,0,0,5.4473,24.1157c10.4022,14.8865,30.9423,19.2966,45.7914,9.8348L84.7167,98.3921A29.9177,29.9177,0,0,0,98.2353,78.3493,31.5263,31.5263,0,0,0,95.13,58.117a30,30,0,0,0,4.4743-11.1824,31.88,31.88,0,0,0-5.4473-24.1157" style="fill:#ff3e00"/><path d="M45.8171,106.5815A20.7182,20.7182,0,0,1,23.58,98.3389a19.1739,19.1739,0,0,1-3.2766-14.5025,18.1886,18.1886,0,0,1,.6233-2.4357l.4912-1.4978,1.3363.9815a33.6443,33.6443,0,0,0,10.203,5.0978l.9694.2941-.0893.9675a5.8474,5.8474,0,0,0,1.052,3.8781,6.2389,6.2389,0,0,0,6.6952,2.485,5.7449,5.7449,0,0,0,1.6021-.7041L69.27,76.281a5.4306,5.4306,0,0,0,2.4506-3.631,5.7948,5.7948,0,0,0-.9875-4.3712,6.2436,6.2436,0,0,0-6.6978-2.4864,5.7427,5.7427,0,0,0-1.6.7036l-9.9532,6.3449a19.0329,19.0329,0,0,1-5.2965,2.3259,20.7181,20.7181,0,0,1-22.2368-8.2427,19.1725,19.1725,0,0,1-3.2766-14.5024,17.9885,17.9885,0,0,1,8.13-12.0513L55.8833,23.7472a19.0038,19.0038,0,0,1,5.3-2.3287A20.7182,20.7182,0,0,1,83.42,29.6611a19.1739,19.1739,0,0,1,3.2766,14.5025,18.4,18.4,0,0,1-.6233,2.4357l-.4912,1.4978-1.3356-.98a33.6175,33.6175,0,0,0-10.2037-5.1l-.9694-.2942.0893-.9675a5.8588,5.8588,0,0,0-1.052-3.878,6.2389,6.2389,0,0,0-6.6952-2.485,5.7449,5.7449,0,0,0-1.6021.7041L37.73,51.719a5.4218,5.4218,0,0,0-2.4487,3.63,5.7862,5.7862,0,0,0,.9856,4.3717,6.2437,6.2437,0,0,0,6.6978,2.4864,5.7652,5.7652,0,0,0,1.602-.7041l9.9519-6.3425a18.978,18.978,0,0,1,5.2959-2.3278,20.7181,20.7181,0,0,1,22.2368,8.2427,19.1725,19.1725,0,0,1,3.2766,14.5024,17.9977,17.9977,0,0,1-8.13,12.0532L51.1167,104.2528a19.0038,19.0038,0,0,1-5.3,2.3287" style="fill:#fff"/></svg>
|
|
||||||
|
Before Width: | Height: | Size: 1.8 KiB |
10
src/main.js
Normal file
10
src/main.js
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
import App from './App.svelte';
|
||||||
|
|
||||||
|
const app = new App({
|
||||||
|
target: document.body,
|
||||||
|
props: {
|
||||||
|
name: 'world'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
export default app;
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
<script>
|
|
||||||
import Header from '$lib/header/Header.svelte';
|
|
||||||
import '../app.css';
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<header />
|
|
||||||
|
|
||||||
<main>
|
|
||||||
<div>
|
|
||||||
<slot />
|
|
||||||
</div>
|
|
||||||
</main>
|
|
||||||
|
|
||||||
<footer>
|
|
||||||
</footer>
|
|
||||||
|
|
||||||
<style>
|
|
||||||
</style>
|
|
||||||
@@ -1,50 +0,0 @@
|
|||||||
<script context="module">
|
|
||||||
import { browser, dev } from '$app/env';
|
|
||||||
|
|
||||||
// we don't need any JS on this page, though we'll load
|
|
||||||
// it in dev so that we get hot module replacement...
|
|
||||||
export const hydrate = dev;
|
|
||||||
|
|
||||||
// ...but if the client-side router is already loaded
|
|
||||||
// (i.e. we came here from elsewhere in the app), use it
|
|
||||||
export const router = browser;
|
|
||||||
|
|
||||||
// since there's no dynamic data here, we can prerender
|
|
||||||
// it so that it gets served as a static asset in prod
|
|
||||||
export const prerender = true;
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<svelte:head>
|
|
||||||
<title>About</title>
|
|
||||||
</svelte:head>
|
|
||||||
|
|
||||||
<div class="content">
|
|
||||||
<h1>About this app</h1>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
This is a <a href="https://kit.svelte.dev">SvelteKit</a> app. You can make your own by typing the
|
|
||||||
following into your command line and following the prompts:
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<!-- TODO lose the @next! -->
|
|
||||||
<pre>npm init svelte@next</pre>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
The page you're looking at is purely static HTML, with no client-side interactivity needed.
|
|
||||||
Because of that, we don't need to load any JavaScript. Try viewing the page's source, or opening
|
|
||||||
the devtools network panel and reloading.
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
The <a href="/todos">TODOs</a> page illustrates SvelteKit's data loading and form handling. Try using
|
|
||||||
it with JavaScript disabled!
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<style>
|
|
||||||
.content {
|
|
||||||
width: 100%;
|
|
||||||
max-width: var(--column-width);
|
|
||||||
margin: var(--column-margin-top) auto 0 auto;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
@@ -1,38 +0,0 @@
|
|||||||
<script>
|
|
||||||
import Tweet from '$lib/Tweet.svelte';
|
|
||||||
import Reply from '$lib/Reply.svelte';
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<div class="mb-5"></div>
|
|
||||||
<Tweet
|
|
||||||
message="Lorem ipsum dolor sit amet consectetur adipisicing elit. Pariatur harum suscipit perferendis inventore dolorum numquam voluptatem aperiam reiciendis nostrum vitae!"
|
|
||||||
time="3m"
|
|
||||||
pubkey="c3765...cd0076"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<!-- separator of sections -->
|
|
||||||
<div class="flex my-5">
|
|
||||||
<div class="flex-1"></div>
|
|
||||||
<div>· · ·</div>
|
|
||||||
<div class="flex-1"></div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<Reply
|
|
||||||
message="first to reply"
|
|
||||||
time="1m"
|
|
||||||
pubkey="c3765...cd0076"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<Reply
|
|
||||||
message="first to reply"
|
|
||||||
time="1m"
|
|
||||||
pubkey="c3765...cd0076"
|
|
||||||
depth=1
|
|
||||||
/>
|
|
||||||
|
|
||||||
<Reply
|
|
||||||
message="first to reply"
|
|
||||||
time="1m"
|
|
||||||
pubkey="c3765...cd0076"
|
|
||||||
depth=2
|
|
||||||
/>
|
|
||||||
@@ -1,179 +0,0 @@
|
|||||||
<script>
|
|
||||||
import Tweet from "$lib/Tweet.svelte";
|
|
||||||
import Reply from "$lib/Reply.svelte";
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<section class="p-3">
|
|
||||||
<p>this page is for prototyping ui</p>
|
|
||||||
<div class="mb-5" />
|
|
||||||
|
|
||||||
<!-- start here -->
|
|
||||||
<div class="border w-1/3 p-5 mb-1 rounded-md">
|
|
||||||
<div class="flex justify-between">
|
|
||||||
<span class="font-bold">007b1...3dd56 (clickable)</span>
|
|
||||||
<span class="text-neutral-400">2 minutes ago</span>
|
|
||||||
</div>
|
|
||||||
<!-- <div class="my-1 pl-3 border-l-4 border-red-800">
|
|
||||||
<div class="flex justify-between">
|
|
||||||
<span>anon said:</span>
|
|
||||||
<div></div>
|
|
||||||
</div>
|
|
||||||
<div class="font-light text-neutral-600 break-words">{replied.message}</div>
|
|
||||||
</div> -->
|
|
||||||
<div class="mb-2 break-words">
|
|
||||||
Lorem ipsum dolor sit, amet consectetur adipisicing elit. Delectus laboriosam nulla laborum
|
|
||||||
numquam nobis reprehenderit debitis necessitatibus nihil facere! Beatae, rem nobis, sed
|
|
||||||
nostrum impedit illum illo recusandae facere quia modi cumque. Libero id odit reprehenderit
|
|
||||||
laborum vel saepe. Quo voluptatibus, dolorem repellat ut harum iure quisquam vitae corrupti
|
|
||||||
ullam repellendus, eaque laborum eos, modi laudantium quod in sit quia! (both card and profile
|
|
||||||
are clickable)
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="border w-1/3 p-5 rounded-md">
|
|
||||||
<div class="flex justify-between">
|
|
||||||
<span class="font-bold">007b1...3dd56</span>
|
|
||||||
<span class="text-neutral-400">2 minutes ago</span>
|
|
||||||
</div>
|
|
||||||
<div class="my-1 pl-3 border-l-4 border-slate-800">
|
|
||||||
<div class="flex justify-between">
|
|
||||||
<span>3ca29...4faa3</span>
|
|
||||||
<div />
|
|
||||||
</div>
|
|
||||||
<div class="text-neutral-500 break-words">short replied message (entire reply clickable)</div>
|
|
||||||
</div>
|
|
||||||
<div class="mb-2 break-words">
|
|
||||||
Lorem ipsum dolor sit, amet consectetur adipisicing elit. Delectus laboriosam nulla laborum
|
|
||||||
numquam nobis reprehenderit debitis necessitatibus nihil facere! Beatae, rem nobis, sed
|
|
||||||
nostrum impedit illum illo recusandae facere quia modi cumque. Libero id odit reprehenderit
|
|
||||||
laborum vel saepe. Quo voluptatibus, dolorem repellat ut harum iure quisquam vitae corrupti
|
|
||||||
ullam repellendus, eaque laborum eos, modi laudantium quod in sit quia!
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<p class="py-5">now another expeirment</p>
|
|
||||||
<div class="w-1/5 rounded-md p-3 mb-5 shadow-lg border">
|
|
||||||
<span class="text-center block mb-5">Total events</span>
|
|
||||||
<div class="flex mb-5">
|
|
||||||
<div class="flex-1 px-5">
|
|
||||||
<span class="block text-right text-neutral-500">1h</span>
|
|
||||||
<span class="block text-right text-5xl font-bold">30</span>
|
|
||||||
</div>
|
|
||||||
<div class="flex-1 px-5">
|
|
||||||
<span class="block text-neutral-500">24h</span>
|
|
||||||
<span class="block text-5xl font-bold">999</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="flex">
|
|
||||||
<div class="flex-1 px-5">
|
|
||||||
<span class="block text-right text-neutral-500">3d</span>
|
|
||||||
<span class="block text-right text-5xl font-bold">3038</span>
|
|
||||||
</div>
|
|
||||||
<div class="flex-1 px-5">
|
|
||||||
<span class="block text-neutral-500">1w</span>
|
|
||||||
<span class="block text-5xl font-bold">12009</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="border w-1/5 rounded-md p-5 mb-5">
|
|
||||||
<span class="text-center block mb-5">Network activity (24h)</span>
|
|
||||||
<div class="flex flex-col">
|
|
||||||
<div class="flex p-2">
|
|
||||||
<span class="flex-1 text-neutral-400">Time (UTC)</span>
|
|
||||||
<span class="flex-1 text-neutral-400">Number of events</span>
|
|
||||||
</div>
|
|
||||||
{#each Array(5) as _}
|
|
||||||
<div class="flex p-2 border-b">
|
|
||||||
<span class="flex-1">16</span>
|
|
||||||
<span class="flex-1">24</span>
|
|
||||||
</div>
|
|
||||||
{/each}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="border w-1/5 rounded-md bg-slate-50 shadow-lg">
|
|
||||||
<span class="text-center block py-3 text-neutral-600">Network activity (24h)</span>
|
|
||||||
<div class="flex flex-col p-5 bg-white">
|
|
||||||
<div class="flex p-2">
|
|
||||||
<span class="flex-1 text-neutral-400">Time (UTC)</span>
|
|
||||||
<span class="flex-1 text-neutral-400">Number of events</span>
|
|
||||||
</div>
|
|
||||||
{#each Array(5) as _}
|
|
||||||
<div class="flex p-2">
|
|
||||||
<span class="flex-1">16</span>
|
|
||||||
<span class="flex-1">24</span>
|
|
||||||
</div>
|
|
||||||
{/each}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<p class="p-5">another experiment</p>
|
|
||||||
<div class="border w-1/3 p-5 mb-3 rounded-md">
|
|
||||||
<div class="flex justify-between">
|
|
||||||
<span class="font-bold">007b1...3dd56 (clickable)</span>
|
|
||||||
<span class="text-neutral-400">2 minutes ago</span>
|
|
||||||
</div>
|
|
||||||
<div class="mb-2 break-words">
|
|
||||||
Lorem ipsum dolor sit, amet consectetur adipisicing elit. Delectus laboriosam nulla laborum
|
|
||||||
numquam nobis reprehenderit debitis necessitatibus nihil facere! Beatae, rem nobis, sed
|
|
||||||
nostrum impedit illum illo recusandae facere quia modi cumque. Libero id odit reprehenderit
|
|
||||||
laborum vel saepe. Quo voluptatibus, dolorem repellat ut harum iure quisquam vitae corrupti
|
|
||||||
ullam repellendus, eaque laborum eos, modi laudantium quod in sit quia! (both card and profile
|
|
||||||
are clickable)
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="border-l-4 border-slate-800 w-1/3 p-5 my-1 rounded-md">
|
|
||||||
<div class="flex justify-between">
|
|
||||||
<span class="font-bold">007b1...3dd56 (clickable)</span>
|
|
||||||
<span class="text-neutral-400">2 minutes ago</span>
|
|
||||||
</div>
|
|
||||||
<div class="mb-2 break-words">reply one this is the reply component, set padding left programmatically and add the color</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="border-l-4 border-slate-800 ml-3 w-1/3 p-5 my-1 rounded-md">
|
|
||||||
<div class="flex justify-between">
|
|
||||||
<span class="font-bold">007b1...3dd56 (clickable)</span>
|
|
||||||
<span class="text-neutral-400">2 minutes ago</span>
|
|
||||||
</div>
|
|
||||||
<div class="mb-2 break-words">
|
|
||||||
reply two Lorem ipsum, dolor sit amet consectetur adipisicing elit. Incidunt qui quas possimus
|
|
||||||
consequuntur voluptas repellendus hic ipsum molestias veritatis voluptatem.
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="border-l-4 border-slate-800 w-1/3 p-5 rounded-md">
|
|
||||||
<div class="flex justify-between">
|
|
||||||
<span class="font-bold">007b1...3dd56 (clickable)</span>
|
|
||||||
<span class="text-neutral-400">2 minutes ago</span>
|
|
||||||
</div>
|
|
||||||
<div class="mb-2 break-words">another parent reply</div>
|
|
||||||
</div>
|
|
||||||
<div class="border-l-4 border-slate-800 ml-3 w-1/3 p-5 rounded-md">
|
|
||||||
<div class="flex justify-between">
|
|
||||||
<span class="font-bold">007b1...3dd56 (clickable)</span>
|
|
||||||
<span class="text-neutral-400">2 minutes ago</span>
|
|
||||||
</div>
|
|
||||||
<div class="mb-2 break-words">
|
|
||||||
reply two Lorem ipsum, dolor sit amet consectetur adipisicing elit. Incidunt qui quas possimus
|
|
||||||
consequuntur voluptas repellendus hic ipsum molestias veritatis voluptatem.
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="border-l-4 border-slate-800 ml-3 w-1/3 p-5 rounded-md">
|
|
||||||
<div class="flex justify-between">
|
|
||||||
<span class="font-bold">007b1...3dd56 (clickable)</span>
|
|
||||||
<span class="text-neutral-400">2 minutes ago</span>
|
|
||||||
</div>
|
|
||||||
<div class="mb-2 break-words">
|
|
||||||
child reply child reply
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<p>from lib</p>
|
|
||||||
<Tweet/>
|
|
||||||
<Tweet/>
|
|
||||||
<Tweet/>
|
|
||||||
<Reply/>
|
|
||||||
<Reply/>
|
|
||||||
<Reply/>
|
|
||||||
</section>
|
|
||||||
@@ -1,139 +0,0 @@
|
|||||||
<script>
|
|
||||||
import Count from '$lib/Count.svelte';
|
|
||||||
import Activity from '$lib/Activity.svelte';
|
|
||||||
import Relay from '$lib/Relay.svelte';
|
|
||||||
import Dots from '$lib/Dots.svelte';
|
|
||||||
import Tweet from '$lib/Tweet.svelte';
|
|
||||||
import Kind from '$lib/Kind.svelte';
|
|
||||||
|
|
||||||
import { onMount } from 'svelte';
|
|
||||||
import _ from 'underscore';
|
|
||||||
|
|
||||||
// initial dummy event object
|
|
||||||
let events = [
|
|
||||||
{
|
|
||||||
message:
|
|
||||||
'Lorem ipsum dolor sit amet consectetur adipisicing elit. Ipsum suscipit dolores eos sequi. Repudiandae doloremque qui quo deserunt quidem, eum incidunt consequuntur numquam nostrum! Lorem ipsum dolor sit amet consectetur adipisicing elit. Ipsum suscipit dolores eos sequi. Repudiandae doloremque qui quo deserunt quidem, eum incidunt consequuntur numquam nostrum!',
|
|
||||||
time: 1,
|
|
||||||
pubkey: '0000000000'
|
|
||||||
}
|
|
||||||
];
|
|
||||||
|
|
||||||
let eventCount24h = 0;
|
|
||||||
let eventCount1h = 0;
|
|
||||||
let networkActivity = Array(24).fill(0); // array index is hour
|
|
||||||
|
|
||||||
let kind0 = 0;
|
|
||||||
let kind1 = 0;
|
|
||||||
let kind2 = 0;
|
|
||||||
let kind3 = 0;
|
|
||||||
let kind4 = 0;
|
|
||||||
let kindOther = 0;
|
|
||||||
|
|
||||||
const unixTime = Math.floor(Date.now() / 1000);
|
|
||||||
const unixTimeMinus24h = unixTime - 60 * 60 * 24;
|
|
||||||
const unixTimeMinus1h = unixTime - 60 * 60;
|
|
||||||
|
|
||||||
// taken from github.com/fiatjaf/nostr-relay-registry
|
|
||||||
const relays = [
|
|
||||||
'wss://nostr-pub.wellorder.net',
|
|
||||||
'wss://relayer.fiatjaf.com',
|
|
||||||
'wss://nostr.rocks',
|
|
||||||
'wss://rsslay.fiatjaf.com',
|
|
||||||
'wss://freedom-relay.herokuapp.com/ws',
|
|
||||||
'wss://nostr-relay.freeberty.net',
|
|
||||||
'wss://nostr.bitcoiner.social',
|
|
||||||
'wss://nostr-relay.wlvs.space',
|
|
||||||
'wss://nostr.onsats.org',
|
|
||||||
'wss://nostr-relay.untethr.me',
|
|
||||||
'wss://nostr-verified.wellorder.net',
|
|
||||||
'wss://nostr.drss.io',
|
|
||||||
'wss://nostr.unknown.place'
|
|
||||||
];
|
|
||||||
let relayActivity = Array(relays.length).fill(0);
|
|
||||||
|
|
||||||
// only do it on front end
|
|
||||||
onMount(() => {
|
|
||||||
relays.forEach((url, relayIndex) => {
|
|
||||||
let socket = new WebSocket(url);
|
|
||||||
|
|
||||||
socket.onopen = function (event) {
|
|
||||||
console.log(`Connected to ${url}`);
|
|
||||||
|
|
||||||
// pull all event 24h
|
|
||||||
socket.send(JSON.stringify(['REQ', 'foobar', { since: unixTimeMinus24h }]));
|
|
||||||
};
|
|
||||||
|
|
||||||
// // take data and parse here
|
|
||||||
socket.onmessage = function (incomingPayload) {
|
|
||||||
// spits out lots of error when parsing
|
|
||||||
// Uncaught SyntaxError: Unexpected token P in JSON at position 0
|
|
||||||
const payload = JSON.parse(incomingPayload.data);
|
|
||||||
const event = payload[2];
|
|
||||||
const eventDate = new Date(event.created_at * 1000);
|
|
||||||
|
|
||||||
// count total event
|
|
||||||
eventCount24h++;
|
|
||||||
if (event.created_at > unixTimeMinus1h) eventCount1h++;
|
|
||||||
|
|
||||||
// count kinds
|
|
||||||
if (event.kind == '0') kind0++;
|
|
||||||
// metadata
|
|
||||||
else if (event.kind == '1') kind1++;
|
|
||||||
// tweet
|
|
||||||
else if (event.kind == '2') kind2++;
|
|
||||||
// relay share
|
|
||||||
else if (event.kind == '3') kind3++;
|
|
||||||
// contact list
|
|
||||||
else if (event.kind == '4') kind4++;
|
|
||||||
// private messages
|
|
||||||
else kindOther++;
|
|
||||||
|
|
||||||
// count peak event
|
|
||||||
const eventHour = eventDate.getUTCHours();
|
|
||||||
networkActivity[eventHour]++;
|
|
||||||
|
|
||||||
// count relay activity
|
|
||||||
relayActivity[relayIndex]++;
|
|
||||||
|
|
||||||
// show tweets
|
|
||||||
let tweet = {
|
|
||||||
message: event.content,
|
|
||||||
time: parseInt(event.created_at),
|
|
||||||
id: event.id,
|
|
||||||
pubkey: event.pubkey
|
|
||||||
};
|
|
||||||
events.push(tweet);
|
|
||||||
const uniqueEvents = _.uniq(events);
|
|
||||||
const sortedEvents = _.sortBy(uniqueEvents, 'time');
|
|
||||||
events = sortedEvents.reverse().slice(0, 20);
|
|
||||||
};
|
|
||||||
});
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<section class="bg-gradient-to-r from-pink-100 to-orange-200">
|
|
||||||
<div class="p-2 max-w-3xl mx-auto sm:flex">
|
|
||||||
<div class="sm:w-1/2 space-y-2 sm:space-y-4">
|
|
||||||
<Count {eventCount1h} {eventCount24h} />
|
|
||||||
<Kind {kind0} {kind1} {kind2} {kind3} {kind4} {kindOther} />
|
|
||||||
<Activity {networkActivity} />
|
|
||||||
<Relay {relays} {relayActivity} />
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="sm:invisible">
|
|
||||||
<Dots />
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="rounded-md shadow p-3 bg-white sm:w-1/2">
|
|
||||||
<span class="block text-center pb-3 text-sm text-neutral-400 font-mono"
|
|
||||||
>NOSTR NETWORK'S LATEST EVENTS</span
|
|
||||||
>
|
|
||||||
<div class="flex flex-col">
|
|
||||||
{#each events as tweet}
|
|
||||||
<Tweet time={tweet.time} pubkey={tweet.pubkey} message={tweet.message} />
|
|
||||||
{/each}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
@@ -1,34 +0,0 @@
|
|||||||
<script>
|
|
||||||
import Tweet from '$lib/Tweet.svelte';
|
|
||||||
const replied = {message: "reply one", time: "2m", pubkey: "54f18...8f2a9"};
|
|
||||||
// link.com/p/<pubkey>
|
|
||||||
// link.com/e/<eventid>
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<div class="mb-5"></div>
|
|
||||||
<Tweet
|
|
||||||
message="Lorem ipsum dolor sit amet consectetur adipisicing elit. Pariatur harum suscipit perferendis inventore dolorum numquam voluptatem aperiam reiciendis nostrum vitae!"
|
|
||||||
time="3m"
|
|
||||||
pubkey="c3765...cd0076"
|
|
||||||
replied={replied}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<Tweet
|
|
||||||
message="Lorem ipsum dolor sit amet consectetur adipisicing elit. Pariatur harum suscipit perferendis inventore dolorum numquam voluptatem aperiam reiciendis nostrum vitae!"
|
|
||||||
time="3m"
|
|
||||||
pubkey="c3765...cd0076"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<Tweet
|
|
||||||
message="Lorem ipsum dolor sit amet consectetur adipisicing elit. Pariatur harum suscipit perferendis inventore dolorum numquam voluptatem aperiam reiciendis nostrum vitae!"
|
|
||||||
time="3m"
|
|
||||||
pubkey="c3765...cd0076"
|
|
||||||
replied={replied}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<Tweet
|
|
||||||
message="Lorem ipsum dolor sit amet consectetur adipisicing elit. Pariatur harum suscipit perferendis inventore dolorum numquam voluptatem aperiam reiciendis nostrum vitae!"
|
|
||||||
time="3m"
|
|
||||||
pubkey="c3765...cd0076"
|
|
||||||
replied={replied}
|
|
||||||
/>
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
/*
|
|
||||||
This module is used by the /todos endpoint to
|
|
||||||
make calls to api.svelte.dev, which stores todos
|
|
||||||
for each user. The leading underscore indicates that this is
|
|
||||||
a private module, _not_ an endpoint — visiting /todos/_api
|
|
||||||
will net you a 404 response.
|
|
||||||
|
|
||||||
(The data on the todo app will expire periodically; no
|
|
||||||
guarantees are made. Don't use it to organise your life.)
|
|
||||||
*/
|
|
||||||
|
|
||||||
const base = 'https://api.svelte.dev';
|
|
||||||
|
|
||||||
export function api(method, resource, data) {
|
|
||||||
return fetch(`${base}/${resource}`, {
|
|
||||||
method,
|
|
||||||
headers: {
|
|
||||||
'content-type': 'application/json'
|
|
||||||
},
|
|
||||||
body: data && JSON.stringify(data)
|
|
||||||
});
|
|
||||||
}
|
|
||||||
@@ -1,66 +0,0 @@
|
|||||||
import { api } from './_api';
|
|
||||||
|
|
||||||
export const get = async ({ locals }) => {
|
|
||||||
// locals.userid comes from src/hooks.js
|
|
||||||
const response = await api('get', `todos/${locals.userid}`);
|
|
||||||
|
|
||||||
if (response.status === 404) {
|
|
||||||
// user hasn't created a todo list.
|
|
||||||
// start with an empty array
|
|
||||||
return {
|
|
||||||
body: {
|
|
||||||
todos: []
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
if (response.status === 200) {
|
|
||||||
return {
|
|
||||||
body: {
|
|
||||||
todos: await response.json()
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
|
||||||
status: response.status
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
export const post = async ({ request, locals }) => {
|
|
||||||
const form = await request.formData();
|
|
||||||
|
|
||||||
await api('post', `todos/${locals.userid}`, {
|
|
||||||
text: form.get('text')
|
|
||||||
});
|
|
||||||
|
|
||||||
return {};
|
|
||||||
};
|
|
||||||
|
|
||||||
// If the user has JavaScript disabled, the URL will change to
|
|
||||||
// include the method override unless we redirect back to /todos
|
|
||||||
const redirect = {
|
|
||||||
status: 303,
|
|
||||||
headers: {
|
|
||||||
location: '/todos'
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
export const patch = async ({ request, locals }) => {
|
|
||||||
const form = await request.formData();
|
|
||||||
|
|
||||||
await api('patch', `todos/${locals.userid}/${form.get('uid')}`, {
|
|
||||||
text: form.has('text') ? form.get('text') : undefined,
|
|
||||||
done: form.has('done') ? !!form.get('done') : undefined
|
|
||||||
});
|
|
||||||
|
|
||||||
return redirect;
|
|
||||||
};
|
|
||||||
|
|
||||||
export const del = async ({ request, locals }) => {
|
|
||||||
const form = await request.formData();
|
|
||||||
|
|
||||||
await api('delete', `todos/${locals.userid}/${form.get('uid')}`);
|
|
||||||
|
|
||||||
return redirect;
|
|
||||||
};
|
|
||||||
@@ -1,178 +0,0 @@
|
|||||||
<script>
|
|
||||||
import { enhance } from '$lib/form';
|
|
||||||
import { scale } from 'svelte/transition';
|
|
||||||
import { flip } from 'svelte/animate';
|
|
||||||
|
|
||||||
export let todos;
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<svelte:head>
|
|
||||||
<title>Todos</title>
|
|
||||||
</svelte:head>
|
|
||||||
|
|
||||||
<div class="todos">
|
|
||||||
<h1>Todos</h1>
|
|
||||||
|
|
||||||
<form
|
|
||||||
class="new"
|
|
||||||
action="/todos"
|
|
||||||
method="post"
|
|
||||||
use:enhance={{
|
|
||||||
result: async ({ form }) => {
|
|
||||||
form.reset();
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<input name="text" aria-label="Add todo" placeholder="+ tap to add a todo" />
|
|
||||||
</form>
|
|
||||||
|
|
||||||
{#each todos as todo (todo.uid)}
|
|
||||||
<div
|
|
||||||
class="todo"
|
|
||||||
class:done={todo.done}
|
|
||||||
transition:scale|local={{ start: 0.7 }}
|
|
||||||
animate:flip={{ duration: 200 }}
|
|
||||||
>
|
|
||||||
<form
|
|
||||||
action="/todos?_method=PATCH"
|
|
||||||
method="post"
|
|
||||||
use:enhance={{
|
|
||||||
pending: ({ data }) => {
|
|
||||||
todo.done = !!data.get('done');
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<input type="hidden" name="uid" value={todo.uid} />
|
|
||||||
<input type="hidden" name="done" value={todo.done ? '' : 'true'} />
|
|
||||||
<button class="toggle" aria-label="Mark todo as {todo.done ? 'not done' : 'done'}" />
|
|
||||||
</form>
|
|
||||||
|
|
||||||
<form class="text" action="/todos?_method=PATCH" method="post" use:enhance>
|
|
||||||
<input type="hidden" name="uid" value={todo.uid} />
|
|
||||||
<input aria-label="Edit todo" type="text" name="text" value={todo.text} />
|
|
||||||
<button class="save" aria-label="Save todo" />
|
|
||||||
</form>
|
|
||||||
|
|
||||||
<form
|
|
||||||
action="/todos?_method=DELETE"
|
|
||||||
method="post"
|
|
||||||
use:enhance={{
|
|
||||||
pending: () => (todo.pending_delete = true)
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<input type="hidden" name="uid" value={todo.uid} />
|
|
||||||
<button class="delete" aria-label="Delete todo" disabled={todo.pending_delete} />
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
{/each}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<style>
|
|
||||||
.todos {
|
|
||||||
width: 100%;
|
|
||||||
max-width: var(--column-width);
|
|
||||||
margin: var(--column-margin-top) auto 0 auto;
|
|
||||||
line-height: 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
.new {
|
|
||||||
margin: 0 0 0.5rem 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
input {
|
|
||||||
border: 1px solid transparent;
|
|
||||||
}
|
|
||||||
|
|
||||||
input:focus-visible {
|
|
||||||
box-shadow: inset 1px 1px 6px rgba(0, 0, 0, 0.1);
|
|
||||||
border: 1px solid #ff3e00 !important;
|
|
||||||
outline: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.new input {
|
|
||||||
font-size: 28px;
|
|
||||||
width: 100%;
|
|
||||||
padding: 0.5em 1em 0.3em 1em;
|
|
||||||
box-sizing: border-box;
|
|
||||||
background: rgba(255, 255, 255, 0.05);
|
|
||||||
border-radius: 8px;
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
.todo {
|
|
||||||
display: grid;
|
|
||||||
grid-template-columns: 2rem 1fr 2rem;
|
|
||||||
grid-gap: 0.5rem;
|
|
||||||
align-items: center;
|
|
||||||
margin: 0 0 0.5rem 0;
|
|
||||||
padding: 0.5rem;
|
|
||||||
background-color: white;
|
|
||||||
border-radius: 8px;
|
|
||||||
filter: drop-shadow(2px 4px 6px rgba(0, 0, 0, 0.1));
|
|
||||||
transform: translate(-1px, -1px);
|
|
||||||
transition: filter 0.2s, transform 0.2s;
|
|
||||||
}
|
|
||||||
|
|
||||||
.done {
|
|
||||||
transform: none;
|
|
||||||
opacity: 0.4;
|
|
||||||
filter: drop-shadow(0px 0px 1px rgba(0, 0, 0, 0.1));
|
|
||||||
}
|
|
||||||
|
|
||||||
form.text {
|
|
||||||
position: relative;
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
flex: 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
.todo input {
|
|
||||||
flex: 1;
|
|
||||||
padding: 0.5em 2em 0.5em 0.8em;
|
|
||||||
border-radius: 3px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.todo button {
|
|
||||||
width: 2em;
|
|
||||||
height: 2em;
|
|
||||||
border: none;
|
|
||||||
background-color: transparent;
|
|
||||||
background-position: 50% 50%;
|
|
||||||
background-repeat: no-repeat;
|
|
||||||
}
|
|
||||||
|
|
||||||
button.toggle {
|
|
||||||
border: 1px solid rgba(0, 0, 0, 0.2);
|
|
||||||
border-radius: 50%;
|
|
||||||
box-sizing: border-box;
|
|
||||||
background-size: 1em auto;
|
|
||||||
}
|
|
||||||
|
|
||||||
.done .toggle {
|
|
||||||
background-image: url("data:image/svg+xml,%3Csvg width='22' height='16' viewBox='0 0 22 16' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M20.5 1.5L7.4375 14.5L1.5 8.5909' stroke='%23676778' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
|
|
||||||
}
|
|
||||||
|
|
||||||
.delete {
|
|
||||||
background-image: url("data:image/svg+xml,%3Csvg width='24' height='24' viewBox='0 0 24 24' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M4.5 5V22H19.5V5H4.5Z' fill='%23676778' stroke='%23676778' stroke-width='1.5' stroke-linejoin='round'/%3E%3Cpath d='M10 10V16.5' stroke='white' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3Cpath d='M14 10V16.5' stroke='white' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3Cpath d='M2 5H22' stroke='%23676778' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3Cpath d='M8 5L9.6445 2H14.3885L16 5H8Z' fill='%23676778' stroke='%23676778' stroke-width='1.5' stroke-linejoin='round'/%3E%3C/svg%3E%0A");
|
|
||||||
opacity: 0.2;
|
|
||||||
}
|
|
||||||
|
|
||||||
.delete:hover,
|
|
||||||
.delete:focus {
|
|
||||||
transition: opacity 0.2s;
|
|
||||||
opacity: 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
.save {
|
|
||||||
position: absolute;
|
|
||||||
right: 0;
|
|
||||||
opacity: 0;
|
|
||||||
background-image: url("data:image/svg+xml,%3Csvg width='24' height='24' viewBox='0 0 24 24' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M20.5 2H3.5C2.67158 2 2 2.67157 2 3.5V20.5C2 21.3284 2.67158 22 3.5 22H20.5C21.3284 22 22 21.3284 22 20.5V3.5C22 2.67157 21.3284 2 20.5 2Z' fill='%23676778' stroke='%23676778' stroke-width='1.5' stroke-linejoin='round'/%3E%3Cpath d='M17 2V11H7.5V2H17Z' fill='white' stroke='white' stroke-width='1.5' stroke-linejoin='round'/%3E%3Cpath d='M13.5 5.5V7.5' stroke='%23676778' stroke-width='1.5' stroke-linecap='round'/%3E%3Cpath d='M5.99844 2H18.4992' stroke='%23676778' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E%0A");
|
|
||||||
}
|
|
||||||
|
|
||||||
.todo input:focus + .save,
|
|
||||||
.save:focus {
|
|
||||||
transition: opacity 0.2s;
|
|
||||||
opacity: 1;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 1.5 KiB |
@@ -1,3 +0,0 @@
|
|||||||
# https://www.robotstxt.org/robotstxt.html
|
|
||||||
User-agent: *
|
|
||||||
Disallow:
|
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 352 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 113 KiB |
@@ -1,22 +0,0 @@
|
|||||||
import preprocess from 'svelte-preprocess';
|
|
||||||
import adapter from '@sveltejs/adapter-auto';
|
|
||||||
|
|
||||||
/** @type {import('@sveltejs/kit').Config} */
|
|
||||||
const config = {
|
|
||||||
kit: {
|
|
||||||
adapter: adapter(),
|
|
||||||
|
|
||||||
// Override http methods in the Todo forms
|
|
||||||
methodOverride: {
|
|
||||||
allowed: ['PATCH', 'DELETE']
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
preprocess: [
|
|
||||||
preprocess({
|
|
||||||
postcss: true
|
|
||||||
})
|
|
||||||
]
|
|
||||||
};
|
|
||||||
|
|
||||||
export default config;
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
const config = {
|
|
||||||
content: ['./src/**/*.{html,js,svelte,ts}'],
|
|
||||||
|
|
||||||
theme: {
|
|
||||||
extend: {}
|
|
||||||
},
|
|
||||||
|
|
||||||
plugins: []
|
|
||||||
};
|
|
||||||
|
|
||||||
module.exports = config;
|
|
||||||
7
tailwind.config.js
Normal file
7
tailwind.config.js
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
module.exports = {
|
||||||
|
content: ['./src/**/*.svelte'],
|
||||||
|
theme: {
|
||||||
|
extend: {},
|
||||||
|
},
|
||||||
|
plugins: [],
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user