diff --git a/src/lib/components/puzzle.svelte b/src/lib/components/puzzle.svelte index a16290f..379298d 100644 --- a/src/lib/components/puzzle.svelte +++ b/src/lib/components/puzzle.svelte @@ -38,7 +38,7 @@ {#if puzzle.tags?.length}
- {#each puzzle.tags as tag} + {#each puzzle.tags.filter((tag) => !['easy', 'medium', 'hard'].includes(tag.name.toLowerCase())) as tag} {tag.name} @@ -63,7 +63,7 @@
{#if puzzle.tags?.length}
- {#each puzzle.tags as tag} + {#each puzzle.tags.filter( (tag) => ['easy', 'medium', 'hard'].includes(tag.name.toLowerCase()) ) as tag} {tag.name} diff --git a/src/lib/components/ui/select/index.ts b/src/lib/components/ui/select/index.ts new file mode 100644 index 0000000..327541c --- /dev/null +++ b/src/lib/components/ui/select/index.ts @@ -0,0 +1,34 @@ +import { Select as SelectPrimitive } from "bits-ui"; + +import Label from "./select-label.svelte"; +import Item from "./select-item.svelte"; +import Content from "./select-content.svelte"; +import Trigger from "./select-trigger.svelte"; +import Separator from "./select-separator.svelte"; + +const Root = SelectPrimitive.Root; +const Group = SelectPrimitive.Group; +const Input = SelectPrimitive.Input; +const Value = SelectPrimitive.Value; + +export { + Root, + Group, + Input, + Label, + Item, + Value, + Content, + Trigger, + Separator, + // + Root as Select, + Group as SelectGroup, + Input as SelectInput, + Label as SelectLabel, + Item as SelectItem, + Value as SelectValue, + Content as SelectContent, + Trigger as SelectTrigger, + Separator as SelectSeparator, +}; diff --git a/src/lib/components/ui/select/select-content.svelte b/src/lib/components/ui/select/select-content.svelte new file mode 100644 index 0000000..93d758e --- /dev/null +++ b/src/lib/components/ui/select/select-content.svelte @@ -0,0 +1,39 @@ + + + +
+ +
+
diff --git a/src/lib/components/ui/select/select-item.svelte b/src/lib/components/ui/select/select-item.svelte new file mode 100644 index 0000000..2cd00a7 --- /dev/null +++ b/src/lib/components/ui/select/select-item.svelte @@ -0,0 +1,40 @@ + + + + + + + + + + {label || value} + + diff --git a/src/lib/components/ui/select/select-label.svelte b/src/lib/components/ui/select/select-label.svelte new file mode 100644 index 0000000..d966450 --- /dev/null +++ b/src/lib/components/ui/select/select-label.svelte @@ -0,0 +1,16 @@ + + + + + diff --git a/src/lib/components/ui/select/select-separator.svelte b/src/lib/components/ui/select/select-separator.svelte new file mode 100644 index 0000000..bc518e6 --- /dev/null +++ b/src/lib/components/ui/select/select-separator.svelte @@ -0,0 +1,11 @@ + + + diff --git a/src/lib/components/ui/select/select-trigger.svelte b/src/lib/components/ui/select/select-trigger.svelte new file mode 100644 index 0000000..ed0bc7e --- /dev/null +++ b/src/lib/components/ui/select/select-trigger.svelte @@ -0,0 +1,27 @@ + + +span]:line-clamp-1", + className + )} + {...$$restProps} + let:builder + on:click + on:keydown +> + +
+ +
+
diff --git a/src/routes/(app)/chapters/[chapterId=id]/+page.svelte b/src/routes/(app)/chapters/[chapterId=id]/+page.svelte index 4fcce22..bf3eea3 100644 --- a/src/routes/(app)/chapters/[chapterId=id]/+page.svelte +++ b/src/routes/(app)/chapters/[chapterId=id]/+page.svelte @@ -1,26 +1,92 @@

{data.chapter.name}

- {#if data.chapter?.puzzles?.length} + {#if !data.chapter?.puzzles?.length} +

Le chapitre ne contient pour l'instant aucun puzzle

+ {:else}

Ils vous restent {data.chapter.puzzles.filter((p) => !p.score).length} puzzles à résoudre sur un total de {data.chapter.puzzles.length}

- {:else} -

Le chapitre ne contient pour l'instant aucun puzzle

{/if}
@@ -36,16 +102,57 @@ {/if}
+
+ + ({ label: theme, value: theme }))} + onSelectedChange={(v) => { + if (v) { + themeList = v.map((item) => item.value); + } else { + themeList = []; + } + }} + > + + + + + {#each Object.entries(themes) as [key, value]} + {key} + {/each} + + + ({ label: difficulty, value: difficulty }))} + onSelectedChange={(v) => { + if (v) { + difficultyList = v.map((item) => item.value); + } else { + difficultyList = []; + } + }} + > + + + + + {#each Object.entries(difficulties) as [key, value]} + {key} + {/each} + + +
    - {#if data.chapter?.puzzles?.length} - {#each data.chapter.puzzles as puzzle (puzzle.id)} + {#if !filteredPuzzles.length} +
  • +

    Aucun puzzle trouvé

    +
  • + {:else} + {#each filteredPuzzles as puzzle (puzzle.id)} - {:else} -
  • -

    Aucun puzzle trouvé

    -
  • {/each} {/if}