ui: Almost all interface done with Svelte

This commit is contained in:
nemunaire 2021-08-30 12:46:18 +02:00
commit 7e13cf28bd
54 changed files with 2809 additions and 16 deletions

View file

@ -0,0 +1,42 @@
import { derived } from 'svelte/store';
import { my } from './my.js';
import { themesStore } from './themes.js';
export const myThemes = derived([my, themesStore], ([$my, $themesStore]) => {
const themes = {};
for (let key in $themesStore.themes) {
themes[key] = {exercice_solved: 0};
if ($my && $my.exercices) {
for (let k in $themesStore.themes[key].exercices) {
if ($my.exercices[k] && $my.exercices[k].solved) {
themes[key].exercice_solved++;
}
}
}
}
return themes;
});
export const tags = derived([my, themesStore], ([$my, $themesStore]) => {
const tags = {};
for (let key in $themesStore.themes) {
for (let k in $themesStore.themes[key].exercices) {
$themesStore.themes[key].exercices[k].tags.forEach((tag) => {
if (!tags[tag])
tags[tag] = {count: 1, solved: 0};
else
tags[tag].count += 1;
if ($my && $my.exercices && $my.exercices[k] && $my.exercices[k].solved)
tags[tag].solved += 1;
});
}
}
return tags;
});