Merge remote-tracking branch 'origin/master'

This commit is contained in:
Mawoka
2022-08-26 17:38:55 +02:00
8 changed files with 93 additions and 80 deletions
+1 -1
View File
@@ -14,7 +14,7 @@ repos:
hooks: hooks:
- id: black - id: black
- repo: https://github.com/pre-commit/mirrors-prettier - repo: https://github.com/pre-commit/mirrors-prettier
rev: 'v2.7.1' # Use the sha / tag you want to point at rev: 'v3.0.0-alpha.0' # Use the sha / tag you want to point at
hooks: hooks:
- id: prettier - id: prettier
files: "^frontend/" files: "^frontend/"
+10 -4
View File
@@ -7,7 +7,8 @@
import { Swiper, SwiperSlide } from 'swiper/svelte'; import { Swiper, SwiperSlide } from 'swiper/svelte';
import 'swiper/css'; import 'swiper/css';
import 'swiper/css/pagination'; import 'swiper/css/pagination';
import { Pagination, EffectCoverflow } from 'swiper'; import 'swiper/css/navigation';
import { Pagination, EffectCoverflow, Keyboard, Mousewheel, Navigation } from 'swiper';
import { QuizQuestionType } from '$lib/quiz_types.js'; import { QuizQuestionType } from '$lib/quiz_types.js';
import { getLocalization } from '../i18n'; import { getLocalization } from '../i18n';
import { alertModal } from '../stores'; import { alertModal } from '../stores';
@@ -42,7 +43,7 @@
plausible('Started Game', { props: { quiz_id: id } }); plausible('Started Game', { props: { quiz_id: id } });
window.location.assign(`/admin?token=${data.game_id}&pin=${data.game_pin}&connect=1`); window.location.assign(`/admin?token=${data.game_id}&pin=${data.game_pin}&connect=1`);
}; };
/*
const deleteQuiz = async (to_delete: string) => { const deleteQuiz = async (to_delete: string) => {
if (!confirm('Do you really want to delete this quiz?')) { if (!confirm('Do you really want to delete this quiz?')) {
return; return;
@@ -52,13 +53,16 @@
}); });
window.location.reload(); window.location.reload();
}; };
*/
</script> </script>
<div class="w-screen p-8"> <div class="w-screen p-8">
<Swiper <Swiper
grabCursor={true} grabCursor={true}
effect={'coverflow'} effect={'coverflow'}
modules={[EffectCoverflow, Pagination]} modules={[EffectCoverflow, Pagination, Mousewheel, Navigation]}
navigation={true}
slidesPerView={1} slidesPerView={1}
mousewheel={true} mousewheel={true}
centeredSlides={true} centeredSlides={true}
@@ -84,8 +88,10 @@
pagination={{ pagination={{
clickable: true clickable: true
}} }}
keyboard={{ enabled: true }}
grabCursor={true} grabCursor={true}
modules={[Pagination]} navigation={true}
modules={[Pagination, Keyboard, Navigation]}
> >
<SwiperSlide> <SwiperSlide>
<div class="grid grid-cols-6 h-full"> <div class="grid grid-cols-6 h-full">
+56 -61
View File
@@ -43,69 +43,70 @@
<nav <nav
class="w-screen px-4 lg:px-10 py-2 flex flex-col lg:flex-row lg:items-center fixed backdrop-blur-2xl bg-white/70 shadow-md z-30 top-0" class="w-screen px-4 lg:px-10 py-2 flex flex-col lg:flex-row lg:items-center fixed backdrop-blur-2xl bg-white/70 shadow-md z-30 top-0"
> >
<section class="w-full lg:w-max flex justify-between"> <section class="w-full lg:w-max grid grid-cols-3 lg:grid-cols-2">
<a href="/" class="font-black tracking-tight text-xl text-black marck-script link-hover" <a href="/" class="font-black tracking-tight text-xl text-black marck-script link-hover"
>ClassQuiz</a >ClassQuiz</a
> >
<div class="flex justify-center">
<button <a
class="lg:hidden" class="lg:pl-6 text-lg font-medium lg:px-4 text-gray-600 hover:text-green-600 link-hover"
id="open-menu" href="/play">{$t('words.play')}</a
on:click={toggleMenu}
class:hidden={!openMenu}
aria-label="Open navbar"
>
<svg
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
display="block"
id="TextAlignJustified"
> >
<path d="M3 6h18M3 12h18M3 18h18" /> </div>
</svg> <div class="flex justify-end">
</button> <button
class="lg:hidden dark:text-black"
<!-- Close menu --> id="open-menu"
<button on:click={toggleMenu}
class="hidden" class:hidden={!openMenu}
id="close-menu" aria-label="Open navbar"
class:hidden={openMenu}
on:click={toggleMenu}
aria-label="Close navbar"
>
<svg
xmlns="http://www.w3.org/2000/svg"
width="14"
height="14"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="3"
stroke-linecap="round"
stroke-linejoin="round"
display="block"
id="Cross"
> >
<path d="M20 20L4 4m16 0L4 20" /> <svg
</svg> xmlns="http://www.w3.org/2000/svg"
</button> width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
display="block"
id="TextAlignJustified"
>
<path d="M3 6h18M3 12h18M3 18h18" />
</svg>
</button>
<!-- Close menu -->
<button
class="hidden dark:text-black"
id="close-menu"
class:hidden={openMenu}
on:click={toggleMenu}
aria-label="Close navbar"
>
<svg
xmlns="http://www.w3.org/2000/svg"
width="14"
height="14"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="3"
stroke-linecap="round"
stroke-linejoin="round"
display="block"
id="Cross"
>
<path d="M20 20L4 4m16 0L4 20" />
</svg>
</button>
</div>
</section> </section>
<ul id="menu-items" class="lg:flex w-full flex-col lg:flex-row lg:pl-6" class:hidden={openMenu}> <ul id="menu-items" class="lg:flex w-full flex-col lg:flex-row" class:hidden={openMenu}>
{#if $signedIn} {#if $signedIn}
<li class="py-2">
<a
class="text-lg font-medium lg:px-4 text-gray-600 hover:text-green-600 link-hover"
href="/play">{$t('words.play')}</a
>
</li>
<li class="py-2"> <li class="py-2">
<a <a
class="text-lg font-medium lg:px-4 text-gray-600 hover:text-green-600 link-hover" class="text-lg font-medium lg:px-4 text-gray-600 hover:text-green-600 link-hover"
@@ -131,12 +132,6 @@
> >
</li> </li>
{:else} {:else}
<li class="py-2">
<a
class="text-lg font-medium lg:px-4 text-gray-600 hover:text-green-600 link-hover"
href="/play">{$t('words.play')}</a
>
</li>
<li class="py-2"> <li class="py-2">
<a <a
class="text-lg font-medium lg:px-4 text-gray-600 hover:text-green-600 link-hover" class="text-lg font-medium lg:px-4 text-gray-600 hover:text-green-600 link-hover"
+17
View File
@@ -0,0 +1,17 @@
/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
import { redirect } from '@sveltejs/kit';
export const load = async ({ parent }) => {
const { email } = await parent();
if (email) {
throw redirect(302, '/dashboard');
}
return {
email
};
};
@@ -1,5 +1,4 @@
import { redirect } from '@sveltejs/kit'; import { redirect } from '@sveltejs/kit';
import { signedIn } from '$lib/stores';
export async function load({ parent }) { export async function load({ parent }) {
const { email } = await parent(); const { email } = await parent();
+1 -5
View File
@@ -7,7 +7,7 @@
import type { Question } from '$lib/quiz_types'; import type { Question } from '$lib/quiz_types';
import { getLocalization } from '$lib/i18n'; import { getLocalization } from '$lib/i18n';
import Footer from '$lib/footer.svelte'; import Footer from '$lib/footer.svelte';
import { alertModal, navbarVisible, signedIn } from '$lib/stores'; import { navbarVisible, signedIn } from '$lib/stores';
import Spinner from '$lib/Spinner.svelte'; import Spinner from '$lib/Spinner.svelte';
import MiniSearch from 'minisearch'; import MiniSearch from 'minisearch';
@@ -45,19 +45,15 @@
for (let i = 0; i < quizzes.length; i++) { for (let i = 0; i < quizzes.length; i++) {
id_to_position_map[quizzes[i].id] = i; id_to_position_map[quizzes[i].id] = i;
} }
console.log(id_to_position_map);
return quizzes_to_show; return quizzes_to_show;
}; };
let suggestions = []; let suggestions = [];
const search = () => { const search = () => {
console.log(search_term);
if (search_term === '') { if (search_term === '') {
console.log('HELLO');
quizzes_to_show = []; quizzes_to_show = [];
quizzes_to_show = quizzes; quizzes_to_show = quizzes;
console.log(quizzes_to_show);
quizzes_to_show = quizzes_to_show; quizzes_to_show = quizzes_to_show;
} else { } else {
const res = minisearch.search(search_term); const res = minisearch.search(search_term);
-1
View File
@@ -26,7 +26,6 @@
resp_data_temp = resp_data_temp.replaceAll('<em>', '<mark>'); resp_data_temp = resp_data_temp.replaceAll('<em>', '<mark>');
resp_data_temp = resp_data_temp.replaceAll('</em>', '</mark>'); resp_data_temp = resp_data_temp.replaceAll('</em>', '</mark>');
resp_data = JSON.parse(resp_data_temp); resp_data = JSON.parse(resp_data_temp);
console.log('Success!', resp_data);
} else { } else {
console.error('Error!', res.status); console.error('Error!', res.status);
} }
@@ -89,13 +89,14 @@
{$t('words.start')} {$t('words.start')}
</button> </button>
{:else} {:else}
<button <div use:tippy={{ content: 'You need to be logged in to start a game' }}>
class="px-4 py-2 leading-5 text-white transition-colors duration-200 transform bg-gray-700 rounded text-center hover:bg-gray-600 focus:outline-none cursor-not-allowed opacity-50" <button
disabled class="px-4 py-2 leading-5 text-white transition-colors duration-200 transform bg-gray-700 rounded text-center hover:bg-gray-600 focus:outline-none cursor-not-allowed opacity-50"
use:tippy={{ content: 'You need to be logged in to start a game' }} disabled
> >
{$t('words.start')} {$t('words.start')}
</button> </button>
</div>
{/if} {/if}
</div> </div>
<div class="flex justify-center"> <div class="flex justify-center">