Skip to content

Commit

Permalink
fix tab types.
Browse files Browse the repository at this point in the history
  • Loading branch information
fiatjaf committed Sep 2, 2023
1 parent 8b6f38d commit 201423d
Show file tree
Hide file tree
Showing 6 changed files with 84 additions and 15 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"@sveltejs/kit": "^1.20.4",
"@types/markdown-it": "^13.0.1",
"autoprefixer": "^10.4.14",
"eslint-plugin-svelte": "^2.33.0",
"postcss": "^8.4.24",
"postcss-load-config": "^4.0.1",
"svelte": "^4.0.5",
Expand All @@ -34,4 +35,4 @@
"marked": "^7.0.5",
"nostr-tools": "^1.14.2"
}
}
}
3 changes: 2 additions & 1 deletion src/components/Article.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
import type { NDKEvent } from "@nostr-dev-kit/ndk";
import { formatDate } from "$lib/utils";
import { parse } from "$lib/articleParser.js";
import type { TabType } from "$lib/types";
export let eventid: string;
export let createChild: (type: string, data: string) => void;
export let createChild: (type: TabType, data: string) => void;
let event: NDKEvent | null = null;
function addClickListenerToWikilinks() {
Expand Down
3 changes: 2 additions & 1 deletion src/components/Search.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
import { wikiKind } from '$lib/consts';
import type { NDKEvent } from '@nostr-dev-kit/ndk';
import { onMount } from 'svelte';
import type { TabType } from '$lib/types';
export let query: string;
export let replaceSelf: (newType: string, newData: string) => void;
export let replaceSelf: (newType: TabType, newData: string) => void;
let results: NDKEvent[] = [];
let tried = 0;
Expand Down
11 changes: 5 additions & 6 deletions src/components/Tab.svelte
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script lang="ts">
import { tabs } from '$lib/state';
import type { Tab } from '$lib/types';
import type { Tab, TabType } from '$lib/types';
import { generateRandomNumber, scrollTabIntoView } from '$lib/utils';
import Article from './Article.svelte';
import Search from './Search.svelte';
Expand All @@ -15,11 +15,10 @@
}
}
function createChild(type: string, data: string) {
// Create child
function createChild(type: TabType, data: string) {
const index = $tabs.findIndex((item) => item.id === tab.id);
if (index !== -1) {
const newChild = {
const newChild: Tab = {
id: generateRandomNumber(),
parent: tab.id,
type: type,
Expand All @@ -31,7 +30,7 @@
}
}
function replaceSelf(newType: string, newData: string) {
function replaceSelf(newType: TabType, newData: string) {
const index = $tabs.findIndex((item) => item.id === tab.id);
if (index !== -1) {
const newTabs = $tabs.slice();
Expand All @@ -42,7 +41,7 @@
newTabs.splice(childIndex, 1);
}
});
const updatedTab = {
const updatedTab: Tab = {
id: generateRandomNumber(),
type: newType,
data: newData
Expand Down
4 changes: 3 additions & 1 deletion src/lib/types.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
export type Tab = {
id: number;
type: 'welcome' | 'articlefind' | 'article';
type: TabType;
parent?: number;
data?: string;
};

export type TabType = 'welcome' | 'articlefind' | 'article';
75 changes: 70 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1096,7 +1096,7 @@ debug@^3.2.7:
dependencies:
ms "^2.1.1"

debug@^4.1.1, debug@^4.3.2, debug@^4.3.4:
debug@^4.1.1, debug@^4.3.1, debug@^4.3.2, debug@^4.3.4:
version "4.3.4"
resolved "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz"
integrity sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==
Expand Down Expand Up @@ -1442,6 +1442,23 @@ eslint-plugin-import@^2.27.5:
semver "^6.3.1"
tsconfig-paths "^3.14.2"

eslint-plugin-svelte@^2.33.0:
version "2.33.0"
resolved "https://registry.yarnpkg.com/eslint-plugin-svelte/-/eslint-plugin-svelte-2.33.0.tgz#c52a867965e902aa9a4d1559606b7e2b27f01b53"
integrity sha512-kk7Z4BfxVjFYJseFcOpS8kiKNio7KnAnhFagmM89h1wNSKlM7tIn+uguNQppKM9leYW+S+Us0Rjg2Qg3zsEcvg==
dependencies:
"@eslint-community/eslint-utils" "^4.2.0"
"@jridgewell/sourcemap-codec" "^1.4.14"
debug "^4.3.1"
esutils "^2.0.3"
known-css-properties "^0.28.0"
postcss "^8.4.5"
postcss-load-config "^3.1.4"
postcss-safe-parser "^6.0.0"
postcss-selector-parser "^6.0.11"
semver "^7.5.3"
svelte-eslint-parser ">=0.33.0 <1.0.0"

eslint-rule-docs@^1.1.5:
version "1.1.235"
resolved "https://registry.npmjs.org/eslint-rule-docs/-/eslint-rule-docs-1.1.235.tgz"
Expand All @@ -1455,15 +1472,15 @@ eslint-scope@^5.1.1:
esrecurse "^4.3.0"
estraverse "^4.1.1"

eslint-scope@^7.2.2:
eslint-scope@^7.0.0, eslint-scope@^7.2.2:
version "7.2.2"
resolved "https://registry.npmjs.org/eslint-scope/-/eslint-scope-7.2.2.tgz"
integrity sha512-dOt21O7lTMhDM+X9mB4GX+DZrZtCUJPL/wlcTqxyrx5IvO0IYtILdtrQGQp+8n5S0gwSVmOf9NQrjMOgfQZlIg==
dependencies:
esrecurse "^4.3.0"
estraverse "^5.2.0"

eslint-visitor-keys@^3.3.0, eslint-visitor-keys@^3.4.1, eslint-visitor-keys@^3.4.3:
eslint-visitor-keys@^3.0.0, eslint-visitor-keys@^3.3.0, eslint-visitor-keys@^3.4.1, eslint-visitor-keys@^3.4.3:
version "3.4.3"
resolved "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.4.3.tgz"
integrity sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag==
Expand Down Expand Up @@ -1526,7 +1543,7 @@ esm-loader-typescript@^1.0.4:
semver "^7.5.3"
typescript "^5.1.6"

espree@^9.6.0, espree@^9.6.1:
espree@^9.0.0, espree@^9.6.0, espree@^9.6.1:
version "9.6.1"
resolved "https://registry.npmjs.org/espree/-/espree-9.6.1.tgz"
integrity sha512-oruZaFkjorTpF32kDSI5/75ViwGeZginGGy2NoOSg3Q9bnwlnmDm4HLnkl0RE3n+njDXR037aY1+x58Z/zFdwQ==
Expand Down Expand Up @@ -1566,7 +1583,7 @@ estree-walker@^3.0.0, estree-walker@^3.0.3:
dependencies:
"@types/estree" "^1.0.0"

esutils@^2.0.2:
esutils@^2.0.2, esutils@^2.0.3:
version "2.0.3"
resolved "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz"
integrity sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==
Expand Down Expand Up @@ -2184,6 +2201,11 @@ kleur@^4.1.5:
resolved "https://registry.npmjs.org/kleur/-/kleur-4.1.5.tgz"
integrity sha512-o+NO+8WrRiQEE4/7nwRJhN1HWpVmJm511pBHUxPLtp0BUISzlBplORYSmTclCnJvQq2tKu/sgl3xVpkc7ZWuQQ==

known-css-properties@^0.28.0:
version "0.28.0"
resolved "https://registry.yarnpkg.com/known-css-properties/-/known-css-properties-0.28.0.tgz#8a8be010f368b3036fe6ab0ef4bbbed972bd6274"
integrity sha512-9pSL5XB4J+ifHP0e0jmmC98OGC1nL8/JjS+fi6mnTlIf//yt/MfVLtKg7S6nCtj/8KTcWX7nRlY0XywoYY1ISQ==

levn@^0.4.1:
version "0.4.1"
resolved "https://registry.npmjs.org/levn/-/levn-0.4.1.tgz"
Expand Down Expand Up @@ -2778,6 +2800,14 @@ postcss-js@^4.0.1:
dependencies:
camelcase-css "^2.0.1"

postcss-load-config@^3.1.4:
version "3.1.4"
resolved "https://registry.yarnpkg.com/postcss-load-config/-/postcss-load-config-3.1.4.tgz#1ab2571faf84bb078877e1d07905eabe9ebda855"
integrity sha512-6DiM4E7v4coTE4uzA8U//WhtPwyhiim3eyjEMFCnUpzbrkK9wJHgKDT2mR+HbtSrd/NubVaYTOpSpjUl8NQeRg==
dependencies:
lilconfig "^2.0.5"
yaml "^1.10.2"

postcss-load-config@^4.0.1:
version "4.0.1"
resolved "https://registry.npmjs.org/postcss-load-config/-/postcss-load-config-4.0.1.tgz"
Expand All @@ -2793,6 +2823,16 @@ postcss-nested@^6.0.1:
dependencies:
postcss-selector-parser "^6.0.11"

postcss-safe-parser@^6.0.0:
version "6.0.0"
resolved "https://registry.yarnpkg.com/postcss-safe-parser/-/postcss-safe-parser-6.0.0.tgz#bb4c29894171a94bc5c996b9a30317ef402adaa1"
integrity sha512-FARHN8pwH+WiS2OPCxJI8FuRJpTVnn6ZNFiqAM2aeW2LwTHWWmWgIyKC6cUo0L8aeKiF/14MNvnpls6R2PBeMQ==

postcss-scss@^4.0.7:
version "4.0.7"
resolved "https://registry.yarnpkg.com/postcss-scss/-/postcss-scss-4.0.7.tgz#cfe5507aaff81b3d8992039ad015da4bd3dccd2f"
integrity sha512-xPv2GseoyXPa58Nro7M73ZntttusuCmZdeOojUFR5PZDz2BR62vfYx1w9TyOnp1+nYFowgOMipsCBhxzVkAEPw==

postcss-selector-parser@6.0.10:
version "6.0.10"
resolved "https://registry.npmjs.org/postcss-selector-parser/-/postcss-selector-parser-6.0.10.tgz"
Expand Down Expand Up @@ -2823,6 +2863,15 @@ postcss@^8.4.23, postcss@^8.4.24, postcss@^8.4.27:
picocolors "^1.0.0"
source-map-js "^1.0.2"

postcss@^8.4.28, postcss@^8.4.5:
version "8.4.29"
resolved "https://registry.yarnpkg.com/postcss/-/postcss-8.4.29.tgz#33bc121cf3b3688d4ddef50be869b2a54185a1dd"
integrity sha512-cbI+jaqIeu/VGqXEarWkRCCffhjgXc0qjBtXpqJhTBohMUjUQnbBr0xqX3vEKudc4iviTewcJo5ajcec5+wdJw==
dependencies:
nanoid "^3.3.6"
picocolors "^1.0.0"
source-map-js "^1.0.2"

prelude-ls@^1.2.1:
version "1.2.1"
resolved "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz"
Expand Down Expand Up @@ -3242,6 +3291,17 @@ svelte-check@^3.4.3:
svelte-preprocess "^5.0.4"
typescript "^5.0.3"

"svelte-eslint-parser@>=0.33.0 <1.0.0":
version "0.33.0"
resolved "https://registry.yarnpkg.com/svelte-eslint-parser/-/svelte-eslint-parser-0.33.0.tgz#66a0779e3d336c44bfdb6e72e0a74e33b1f84fb7"
integrity sha512-5awZ6Bs+Tb/zQwa41PSdcLynAVQTwW0HGyCBjtbAQ59taLZqDgQSMzRlDmapjZdDtzERm0oXDZNE0E+PKJ6ryg==
dependencies:
eslint-scope "^7.0.0"
eslint-visitor-keys "^3.0.0"
espree "^9.0.0"
postcss "^8.4.28"
postcss-scss "^4.0.7"

svelte-hmr@^0.15.3:
version "0.15.3"
resolved "https://registry.npmjs.org/svelte-hmr/-/svelte-hmr-0.15.3.tgz"
Expand Down Expand Up @@ -3638,6 +3698,11 @@ yallist@^4.0.0:
resolved "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz"
integrity sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==

yaml@^1.10.2:
version "1.10.2"
resolved "https://registry.yarnpkg.com/yaml/-/yaml-1.10.2.tgz#2301c5ffbf12b467de8da2333a459e29e7920e4b"
integrity sha512-r3vXyErRCYJ7wg28yvBY5VSoAF8ZvlcW9/BwUzEtUsjvX/DKs24dIkuwjtuprwJJHsbyUbLApepYTR1BN4uHrg==

yaml@^2.1.1:
version "2.3.2"
resolved "https://registry.npmjs.org/yaml/-/yaml-2.3.2.tgz"
Expand Down

0 comments on commit 201423d

Please sign in to comment.