From 78ddb35052d8d25f5e87a3d6a09fd05db124cb43 Mon Sep 17 00:00:00 2001 From: Daevid66 Date: Fri, 6 Dec 2024 22:49:30 +0100 Subject: [PATCH 1/5] initial help center feature --- ProblemSource/AdminApp/package-lock.json | 70 ++++++++++++++ ProblemSource/AdminApp/package.json | 17 ++-- .../AdminApp/src/help/categories/en/faq.md | 4 + .../src/help/categories/en/support.md | 4 + .../src/help/posts/en/about-the-project.md | 13 +++ .../en/can-other-teachers-create-accounts.md | 8 ++ .../how-can-i-increase-my-training-quota.md | 7 ++ .../AdminApp/src/help/posts/en/how-to-install | 9 ++ .../en/personally-identifiable-information.md | 20 ++++ .../src/help/posts/en/what-does-the-bars-mean | 10 ++ .../posts/en/where-can-i-sign-up-collegues.md | 8 ++ .../AdminApp/src/help/posts/en/why-limit.md | 11 +++ .../AdminApp/src/routes/+layout.svelte | 5 +- ProblemSource/AdminApp/src/routes/+layout.ts | 29 +++--- .../AdminApp/src/routes/help/+layout.ts | 2 + .../src/routes/help/[lang]/+page.svelte | 22 +++++ .../AdminApp/src/routes/help/[lang]/+page.ts | 38 ++++++++ .../routes/help/[lang]/[slug]/+page.svelte | 13 +++ .../src/routes/help/[lang]/[slug]/+page.ts | 21 +++++ .../AdminApp/src/routes/help/question.svelte | 61 ++++++++++++ .../AdminApp/src/services/redirects.ts | 93 ++++++++++--------- .../AdminApp/src/utilities/ClickOutside.ts | 11 +++ .../src/utilities/ExpandTransition.ts | 16 ++++ ProblemSource/AdminApp/svelte.config.js | 11 ++- 24 files changed, 430 insertions(+), 73 deletions(-) create mode 100644 ProblemSource/AdminApp/src/help/categories/en/faq.md create mode 100644 ProblemSource/AdminApp/src/help/categories/en/support.md create mode 100644 ProblemSource/AdminApp/src/help/posts/en/about-the-project.md create mode 100644 ProblemSource/AdminApp/src/help/posts/en/can-other-teachers-create-accounts.md create mode 100644 ProblemSource/AdminApp/src/help/posts/en/how-can-i-increase-my-training-quota.md create mode 100644 ProblemSource/AdminApp/src/help/posts/en/how-to-install create mode 100644 ProblemSource/AdminApp/src/help/posts/en/personally-identifiable-information.md create mode 100644 ProblemSource/AdminApp/src/help/posts/en/what-does-the-bars-mean create mode 100644 ProblemSource/AdminApp/src/help/posts/en/where-can-i-sign-up-collegues.md create mode 100644 ProblemSource/AdminApp/src/help/posts/en/why-limit.md create mode 100644 ProblemSource/AdminApp/src/routes/help/+layout.ts create mode 100644 ProblemSource/AdminApp/src/routes/help/[lang]/+page.svelte create mode 100644 ProblemSource/AdminApp/src/routes/help/[lang]/+page.ts create mode 100644 ProblemSource/AdminApp/src/routes/help/[lang]/[slug]/+page.svelte create mode 100644 ProblemSource/AdminApp/src/routes/help/[lang]/[slug]/+page.ts create mode 100644 ProblemSource/AdminApp/src/routes/help/question.svelte create mode 100644 ProblemSource/AdminApp/src/utilities/ClickOutside.ts create mode 100644 ProblemSource/AdminApp/src/utilities/ExpandTransition.ts diff --git a/ProblemSource/AdminApp/package-lock.json b/ProblemSource/AdminApp/package-lock.json index affbf90d..670430e9 100644 --- a/ProblemSource/AdminApp/package-lock.json +++ b/ProblemSource/AdminApp/package-lock.json @@ -29,6 +29,7 @@ "eslint": "8.16.0", "eslint-config-prettier": "8.3.0", "eslint-plugin-svelte3": "4.0.0", + "mdsvex": "^0.11.1", "prettier": "2.6.2", "prettier-plugin-svelte": "2.7.0", "svelte": "3.55.0", @@ -733,6 +734,13 @@ "dev": true, "license": "MIT" }, + "node_modules/@types/unist": { + "version": "2.0.11", + "resolved": "https://registry.npmjs.org/@types/unist/-/unist-2.0.11.tgz", + "integrity": "sha512-CmBKiL6NNo/OqgmMn95Fk9Whlp2mtvIv+KNpQKN2F4SjvrEesubTRWGYSg+BnWZOnlCaSTU1sMpsBOzgbYhnsA==", + "dev": true, + "license": "MIT" + }, "node_modules/@typescript-eslint/eslint-plugin": { "version": "5.27.0", "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.27.0.tgz", @@ -2147,6 +2155,22 @@ "@jridgewell/sourcemap-codec": "^1.5.0" } }, + "node_modules/mdsvex": { + "version": "0.11.1", + "resolved": "https://registry.npmjs.org/mdsvex/-/mdsvex-0.11.1.tgz", + "integrity": "sha512-8g1WIKP8AD+KyW6EOSXkEUkxuKL3uX+Tqpv6MUyMFCXvDOb8FDuTFoaOSqi/1CKXVXTLdP/RZU2WS4W9pnuOmA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/unist": "^2.0.3", + "prism-svelte": "^0.4.7", + "prismjs": "^1.17.1", + "vfile-message": "^2.0.4" + }, + "peerDependencies": { + "svelte": ">=3 <6" + } + }, "node_modules/merge2": { "version": "1.4.1", "resolved": "https://registry.npmjs.org/merge2/-/merge2-1.4.1.tgz", @@ -2480,6 +2504,23 @@ "svelte": "^3.2.0" } }, + "node_modules/prism-svelte": { + "version": "0.4.7", + "resolved": "https://registry.npmjs.org/prism-svelte/-/prism-svelte-0.4.7.tgz", + "integrity": "sha512-yABh19CYbM24V7aS7TuPYRNMqthxwbvx6FF/Rw920YbyBWO3tnyPIqRMgHuSVsLmuHkkBS1Akyof463FVdkeDQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/prismjs": { + "version": "1.29.0", + "resolved": "https://registry.npmjs.org/prismjs/-/prismjs-1.29.0.tgz", + "integrity": "sha512-Kx/1w86q/epKcmte75LNrEoT+lX8pBpavuAbvJWRXar7Hz8jrtF+e3vY751p0R8H9HdArwaCTNDDzHg/ScJK1Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, "node_modules/psl": { "version": "1.10.0", "resolved": "https://registry.npmjs.org/psl/-/psl-1.10.0.tgz", @@ -3232,6 +3273,20 @@ "node": ">=12.18" } }, + "node_modules/unist-util-stringify-position": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/unist-util-stringify-position/-/unist-util-stringify-position-2.0.3.tgz", + "integrity": "sha512-3faScn5I+hy9VleOq/qNbAd6pAx7iH5jYBMS9I1HgQVijz/4mv5Bvw5iw1sC/90CODiKo81G/ps8AJrISn687g==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/unist": "^2.0.2" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, "node_modules/universalify": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.2.0.tgz", @@ -3268,6 +3323,21 @@ "dev": true, "license": "MIT" }, + "node_modules/vfile-message": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/vfile-message/-/vfile-message-2.0.4.tgz", + "integrity": "sha512-DjssxRGkMvifUOJre00juHoP9DPWuzjxKuMDrhNbk2TdaYYBNMStsNhEOt3idrtI12VQYM/1+iM0KOzXi4pxwQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/unist": "^2.0.0", + "unist-util-stringify-position": "^2.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, "node_modules/vite": { "version": "4.2.0", "resolved": "https://registry.npmjs.org/vite/-/vite-4.2.0.tgz", diff --git a/ProblemSource/AdminApp/package.json b/ProblemSource/AdminApp/package.json index e86eb26c..d147a5fe 100644 --- a/ProblemSource/AdminApp/package.json +++ b/ProblemSource/AdminApp/package.json @@ -14,25 +14,26 @@ }, "devDependencies": { "@playwright/test": "1.25.0", + "@sveltejs/adapter-auto": "2.0.0", "@sveltejs/adapter-static": "2.0.1", + "@sveltejs/kit": "1.5.0", "@types/color-convert": "2.0.0", + "@types/node": "18.15.5", "@typescript-eslint/eslint-plugin": "5.27.0", "@typescript-eslint/parser": "5.27.0", "@vitejs/plugin-basic-ssl": "1.0.1", "eslint": "8.16.0", "eslint-config-prettier": "8.3.0", "eslint-plugin-svelte3": "4.0.0", + "mdsvex": "^0.11.1", "prettier": "2.6.2", "prettier-plugin-svelte": "2.7.0", + "svelte": "3.55.0", + "svelte-check": "3.0.1", "svelte-preprocess": "5.0.3", - "@sveltejs/adapter-auto": "2.0.0", - "@sveltejs/kit": "1.5.0", - "@types/node": "18.15.5", - "svelte": "3.55.0", - "svelte-check": "3.0.1", - "tslib": "2.4.1", - "typescript": "5.6.3", - "vite": "4.2.0" + "tslib": "2.4.1", + "typescript": "5.6.3", + "vite": "4.2.0" }, "type": "module", "dependencies": { diff --git a/ProblemSource/AdminApp/src/help/categories/en/faq.md b/ProblemSource/AdminApp/src/help/categories/en/faq.md new file mode 100644 index 00000000..9ac5d35e --- /dev/null +++ b/ProblemSource/AdminApp/src/help/categories/en/faq.md @@ -0,0 +1,4 @@ +--- +title: Frequently asked Questions +posted: 'Dec 6, 2024' +--- diff --git a/ProblemSource/AdminApp/src/help/categories/en/support.md b/ProblemSource/AdminApp/src/help/categories/en/support.md new file mode 100644 index 00000000..da6cd9ff --- /dev/null +++ b/ProblemSource/AdminApp/src/help/categories/en/support.md @@ -0,0 +1,4 @@ +--- +title: Support +posted: 'Dec 6, 2024' +--- diff --git a/ProblemSource/AdminApp/src/help/posts/en/about-the-project.md b/ProblemSource/AdminApp/src/help/posts/en/about-the-project.md new file mode 100644 index 00000000..8305a39a --- /dev/null +++ b/ProblemSource/AdminApp/src/help/posts/en/about-the-project.md @@ -0,0 +1,13 @@ +--- +title: About the project +categories: faq +posted: 'Dec 6, 2024' +--- + +We are pleased to announce that Vektor is being resurrected this spring with the help of research funding from a Wallenberg Foundation and based in the Karolinska Institutet. +A group of selected teachers have received invitations to participate, because they have previously been successful users of the program. They can administer their training through the Teacher admin page. + +The app looks and works just like before - however you access it via login on a website (Training app page), not through an app installed through Apples App Store or Google Play. +As before, it will contain the training schedule that we found best based on previous research. We will also vary a few percent of the time in order to make the app even better in the future through analyses. + +We will not save any personal data from the users of the training app, and the use of the app is approved by the Ethics Review Authority. diff --git a/ProblemSource/AdminApp/src/help/posts/en/can-other-teachers-create-accounts.md b/ProblemSource/AdminApp/src/help/posts/en/can-other-teachers-create-accounts.md new file mode 100644 index 00000000..344621a7 --- /dev/null +++ b/ProblemSource/AdminApp/src/help/posts/en/can-other-teachers-create-accounts.md @@ -0,0 +1,8 @@ +--- +title: Can other teachers create accounts? +categories: faq +posted: 'Dec 6, 2024' +--- + +The training program is currently only available to a small group of invited users. +We are investigating options for making it publicly available. diff --git a/ProblemSource/AdminApp/src/help/posts/en/how-can-i-increase-my-training-quota.md b/ProblemSource/AdminApp/src/help/posts/en/how-can-i-increase-my-training-quota.md new file mode 100644 index 00000000..f9cc3fed --- /dev/null +++ b/ProblemSource/AdminApp/src/help/posts/en/how-can-i-increase-my-training-quota.md @@ -0,0 +1,7 @@ +--- +title: How can I increase my training quota? +categories: faq +posted: 'Dec 6, 2024' +--- + +For each training that has completed at least 5 training days, your training quota (the number of trainings you can create) increases by 1. diff --git a/ProblemSource/AdminApp/src/help/posts/en/how-to-install b/ProblemSource/AdminApp/src/help/posts/en/how-to-install new file mode 100644 index 00000000..11815fd9 --- /dev/null +++ b/ProblemSource/AdminApp/src/help/posts/en/how-to-install @@ -0,0 +1,9 @@ +--- +title: How do I install the training app +categories: faq +posted: 'Dec 6, 2024' +--- + +Currently, the training app is not available for installing from App Store or Google Play Store. +You can access the app from a browser at Training app page +In order to make the app feel more like a native app, you can enable Progressive Web App (PWA) mode by following these instructions: [https://mobilesyrup.com/2020/05/24/how-install-progressive-web-app-pwa-android-ios-pc-mac](https://mobilesyrup.com/2020/05/24/how-install-progressive-web-app-pwa-android-ios-pc-mac/) diff --git a/ProblemSource/AdminApp/src/help/posts/en/personally-identifiable-information.md b/ProblemSource/AdminApp/src/help/posts/en/personally-identifiable-information.md new file mode 100644 index 00000000..e9b64582 --- /dev/null +++ b/ProblemSource/AdminApp/src/help/posts/en/personally-identifiable-information.md @@ -0,0 +1,20 @@ +--- +title: Personally Identifiable Information (PII) +categories: faq +posted: 'Dec 6, 2024' +--- + +#### For all users (of training app and/or teacher admin) + +No IP addresses are stored on servers +No tracking cookies are used +All servers are located in the EU + +#### For training app users + +No email address or other PII is entered when creating a training account +We don't provide any means for the user to input text + +#### For teacher admin users + +Email is stored plain-text, password is stored as salted/hashed diff --git a/ProblemSource/AdminApp/src/help/posts/en/what-does-the-bars-mean b/ProblemSource/AdminApp/src/help/posts/en/what-does-the-bars-mean new file mode 100644 index 00000000..a73e6577 --- /dev/null +++ b/ProblemSource/AdminApp/src/help/posts/en/what-does-the-bars-mean @@ -0,0 +1,10 @@ +--- +title: What do the bars in the training view mean? +categories: faq +posted: 'Dec 6, 2024' +--- + +The training statistics algorithms have not yet been finalized. We will be updating this article soon! +Accuracy +Effective time/day +Days trained diff --git a/ProblemSource/AdminApp/src/help/posts/en/where-can-i-sign-up-collegues.md b/ProblemSource/AdminApp/src/help/posts/en/where-can-i-sign-up-collegues.md new file mode 100644 index 00000000..1527befd --- /dev/null +++ b/ProblemSource/AdminApp/src/help/posts/en/where-can-i-sign-up-collegues.md @@ -0,0 +1,8 @@ +--- +title: Where can I sign up colleagues? +categories: faq +posted: 'Dec 6, 2024' +--- + +Currently, we are only allowing a fairly low number of teachers and trainings in our system. +We are looking into making the program publicly available, but we don't see it happening until the second half of 2023 at the earliest. diff --git a/ProblemSource/AdminApp/src/help/posts/en/why-limit.md b/ProblemSource/AdminApp/src/help/posts/en/why-limit.md new file mode 100644 index 00000000..9a7e4121 --- /dev/null +++ b/ProblemSource/AdminApp/src/help/posts/en/why-limit.md @@ -0,0 +1,11 @@ +--- +title: Why is there a limit on the number of trainings I can create? +categories: faq +posted: 'Dec 6, 2024' +--- + +The training is now done from a web browser, instead of from an installed app. + +This may cause problems in some schools, and since our capacity to provide support is low, we have limited the number of trainings that any one teacher can create. + +For every training that has completed at least 5 days, your training quota will increase by 1. diff --git a/ProblemSource/AdminApp/src/routes/+layout.svelte b/ProblemSource/AdminApp/src/routes/+layout.svelte index dba9e31b..d594746f 100644 --- a/ProblemSource/AdminApp/src/routes/+layout.svelte +++ b/ProblemSource/AdminApp/src/routes/+layout.svelte @@ -1,7 +1,4 @@ + +

Math App 2 - Help center

+{#each categories as category} +

{category.title}

+ {#each getPostOfCategory(category.slug) as post} + + + Link + + {/each} +{/each} diff --git a/ProblemSource/AdminApp/src/routes/help/[lang]/+page.ts b/ProblemSource/AdminApp/src/routes/help/[lang]/+page.ts new file mode 100644 index 00000000..341c8f52 --- /dev/null +++ b/ProblemSource/AdminApp/src/routes/help/[lang]/+page.ts @@ -0,0 +1,38 @@ +import { SvelteComponentTyped } from 'svelte'; +import type { PageLoad } from './$types'; + +export const load: PageLoad = ({ params }) => { + let posts: Array<{ title: string; categories: string[]; posted: Date; slug: string; content: ConstructorOfATypedSvelteComponent; lang: string }> = []; + const allPosts = import.meta.glob('/src/help/posts/**/*.md', { eager: true }); // Load all Markdown files + for (const path in allPosts) { + const file: { metadata: { title: string; categories: string; posted: string }; default: ConstructorOfATypedSvelteComponent } = allPosts[path] as any; + if (!path.includes(`/${params.lang}/`)) continue; // Filter by language + + const metadata = file.metadata; + const slug = path.split('/').at(-1)?.replace('.md', '') || 'non-existing'; + const title = metadata.title; + const categories = metadata.categories?.split('|') || []; + const posted = new Date(metadata.posted); + const content = file.default; + const lang = params.lang; + posts.push({ slug, title, categories, posted, content, lang }); + } + + let categories: Array<{ title: string; posted: Date; slug: string }> = []; + const allCategories = import.meta.glob('/src/help/categories/**/*.md', { eager: true }); // Load all Markdown files + for (const path in allCategories) { + const file: { metadata: { title: string; categories: string; posted: string } } = allCategories[path] as any; + if (!path.includes(`/${params.lang}/`)) continue; // Filter by language + + const metadata = file.metadata; + const slug = path.split('/').at(-1)?.replace('.md', '') || 'non-existing'; + const title = metadata.title; + const posted = new Date(metadata.posted); + + categories.push({ slug, title, posted }); + } + return { + posts, + categories + }; +}; diff --git a/ProblemSource/AdminApp/src/routes/help/[lang]/[slug]/+page.svelte b/ProblemSource/AdminApp/src/routes/help/[lang]/[slug]/+page.svelte new file mode 100644 index 00000000..c275c75a --- /dev/null +++ b/ProblemSource/AdminApp/src/routes/help/[lang]/[slug]/+page.svelte @@ -0,0 +1,13 @@ + + + + {data.title} + + +

{data.title}

+{#if data.content} + +{/if} diff --git a/ProblemSource/AdminApp/src/routes/help/[lang]/[slug]/+page.ts b/ProblemSource/AdminApp/src/routes/help/[lang]/[slug]/+page.ts new file mode 100644 index 00000000..16366f8b --- /dev/null +++ b/ProblemSource/AdminApp/src/routes/help/[lang]/[slug]/+page.ts @@ -0,0 +1,21 @@ +import { SvelteComponentTyped } from 'svelte'; + +const allPosts = import.meta.glob('/src/help/posts/**/*.md', { eager: true }); + +export const load = async ({ params }) => { + const allPosts = import.meta.glob('/src/help/posts/**/*.md', { eager: true }); // Load all Markdown files + + console.log('allPosts', allPosts); + const path = '/src/help/posts/' + params.lang + '/' + params.slug + '.md'; + const file: { metadata: { title: string; categories: string; posted: string }; default: ConstructorOfATypedSvelteComponent } = allPosts[path] as any; + + const metadata = file.metadata; + const slug = path.split('/').at(-1)?.replace('.md', '') || 'non-existing'; + const title = metadata.title; + const categories = metadata.categories?.split('|') || []; + const posted = new Date(metadata.posted); + const content = file.default; + const lang = params.lang; + console.log({ slug, title, categories, posted, content, lang }); + return { slug, title, categories, posted, content, lang }; +}; diff --git a/ProblemSource/AdminApp/src/routes/help/question.svelte b/ProblemSource/AdminApp/src/routes/help/question.svelte new file mode 100644 index 00000000..d55048b4 --- /dev/null +++ b/ProblemSource/AdminApp/src/routes/help/question.svelte @@ -0,0 +1,61 @@ + + +
{ + showAnswer = !showAnswer; + }}> +
+ {#if showAnswer} + ! + {:else} + ? + {/if} +
+
+

{question}

+ {#if showAnswer} +
+
+
+ {/if} +
+
+ + diff --git a/ProblemSource/AdminApp/src/services/redirects.ts b/ProblemSource/AdminApp/src/services/redirects.ts index 6f7cf121..f19adaa6 100644 --- a/ProblemSource/AdminApp/src/services/redirects.ts +++ b/ProblemSource/AdminApp/src/services/redirects.ts @@ -1,48 +1,49 @@ -import { goto } from "$app/navigation"; -import { base } from "$app/paths"; -import { userStore } from "../globalStore"; -import { get } from "svelte/store"; +import { goto } from '$app/navigation'; +import { base } from '$app/paths'; +import { userStore } from '../globalStore'; +import { get } from 'svelte/store'; export async function handleRedirects(routeId: string) { - await userStore.inited; - const user = get(userStore); - - console.log("handleRedirect", user, routeId, window.location.pathname); - - if (/\/login$/.test(window.location.pathname)) { - return; - } - - const _goto = (url: string) => { - //goto(url); // seems my svelte routing has broken with some update..? - window.location.href = url; - } - - if (!user) { - const returnUrl = window.location.pathname.substring(base.length) + window.location.search; - const next = base + '/login' + - (window.location.search.indexOf("returnUrl") >= 0 - ? window.location.search - : "?returnUrl=" + encodeURIComponent(returnUrl)); - - console.log("next", next); - - if (routeId !== '/login') { - _goto(next); // TODO: for some reason the url parameters are removed..? - } - } else { - if (routeId === '/login' || routeId === '/') { - if (user.role === 'Admin') { - _goto(base + '/admin'); - } else { - _goto(base + '/teacher'); - } - } else { - console.warn("no routeId"); - // TODO: why redirect here? - // if (user.role !== 'Admin' && routeId?.indexOf('/admin') !== 0) { - // goto(base + '/login'); - // } - } - } -} \ No newline at end of file + await userStore.inited; + const user = get(userStore); + + console.log('handleRedirect', user, routeId, window.location.pathname); + + if (/\/login$/.test(window.location.pathname)) { + return; + } + + if (window.location.pathname.includes('/help/')) { + return; + } + + const _goto = (url: string) => { + //goto(url); // seems my svelte routing has broken with some update..? + window.location.href = url; + }; + + if (!user) { + const returnUrl = window.location.pathname.substring(base.length) + window.location.search; + const next = base + '/login' + (window.location.search.indexOf('returnUrl') >= 0 ? window.location.search : '?returnUrl=' + encodeURIComponent(returnUrl)); + + console.log('next', next); + + if (routeId !== '/login') { + _goto(next); // TODO: for some reason the url parameters are removed..? + } + } else { + if (routeId === '/login' || routeId === '/') { + if (user.role === 'Admin') { + _goto(base + '/admin'); + } else { + _goto(base + '/teacher'); + } + } else { + console.warn('no routeId'); + // TODO: why redirect here? + // if (user.role !== 'Admin' && routeId?.indexOf('/admin') !== 0) { + // goto(base + '/login'); + // } + } + } +} diff --git a/ProblemSource/AdminApp/src/utilities/ClickOutside.ts b/ProblemSource/AdminApp/src/utilities/ClickOutside.ts new file mode 100644 index 00000000..03cc95a2 --- /dev/null +++ b/ProblemSource/AdminApp/src/utilities/ClickOutside.ts @@ -0,0 +1,11 @@ +export default function clickOutside(node: HTMLElement, handler: () => void): { destroy: () => void } { + const onClick = (event: MouseEvent) => node && !node.contains(event.target as HTMLElement) && !event.defaultPrevented && handler(); + + document.addEventListener('click', onClick, true); + + return { + destroy() { + document.removeEventListener('click', onClick, true); + } + }; +} diff --git a/ProblemSource/AdminApp/src/utilities/ExpandTransition.ts b/ProblemSource/AdminApp/src/utilities/ExpandTransition.ts new file mode 100644 index 00000000..e961f2fb --- /dev/null +++ b/ProblemSource/AdminApp/src/utilities/ExpandTransition.ts @@ -0,0 +1,16 @@ +import { cubicInOut } from 'svelte/easing'; + +export const ExpandTransition = (el: HTMLElement, data?: any) => { + el.style.overflow = 'hidden'; + const elementHeight = el.offsetHeight; + return { + css: (t: number) => { + return ` + opacity: ${t}; + max-height: ${elementHeight * t}px; + `; + }, + easing: cubicInOut, + duration: 300 + }; +}; diff --git a/ProblemSource/AdminApp/svelte.config.js b/ProblemSource/AdminApp/svelte.config.js index 218f050d..4f121c40 100644 --- a/ProblemSource/AdminApp/svelte.config.js +++ b/ProblemSource/AdminApp/svelte.config.js @@ -1,19 +1,26 @@ //import adapter from '@sveltejs/adapter-auto'; import adapter from '@sveltejs/adapter-static'; import { vitePreprocess } from '@sveltejs/kit/vite'; +import { mdsvex } from 'mdsvex'; // import preprocess from 'svelte-preprocess'; +/** @type {import('mdsvex').MdsvexOptions} */ +const mdsvexOptions = { + extensions: ['.md'] +} + /** @type {import('@sveltejs/kit').Config} */ const config = { // Consult https://github.com/sveltejs/svelte-preprocess // for more information about preprocessors // preprocess: preprocess(), - preprocess: vitePreprocess(), + extensions: ['.svelte', '.md'], + preprocess: [vitePreprocess(), mdsvex(mdsvexOptions)], kit: { // adapter: adapter() adapter: adapter({ fallback: 'index.html' }), - prerender: { entries: [] }, + prerender: { entries: ['/help/en', '/help/en/first'] }, paths: { base: "/admin", // Not working: From e751af7b77cdad77e603770e916945515dbbb72e Mon Sep 17 00:00:00 2001 From: JWMB Date: Mon, 9 Dec 2024 18:06:12 +0100 Subject: [PATCH 2/5] remove links to humany.net --- ProblemSource/AdminApp/src/routes/+layout.svelte | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ProblemSource/AdminApp/src/routes/+layout.svelte b/ProblemSource/AdminApp/src/routes/+layout.svelte index d594746f..fc8e1ff7 100644 --- a/ProblemSource/AdminApp/src/routes/+layout.svelte +++ b/ProblemSource/AdminApp/src/routes/+layout.svelte @@ -27,7 +27,7 @@ {#if data.pageInited}