ui: Handle standalone exercice in menus and pages

This commit is contained in:
nemunaire 2024-03-16 10:17:29 +01:00
parent d234bbf272
commit 13a11269a8
4 changed files with 82 additions and 28 deletions

View File

@ -10,11 +10,11 @@
import { current_exercice } from '$lib/stores/exercices';
import { my } from '$lib/stores/my.js';
import { current_theme, max_solved } from '$lib/stores/themes.js';
import { current_theme, max_solved, themesStore } from '$lib/stores/themes.js';
import { myThemes, themes } from '$lib/stores/mythemes.js';
</script>
<Dropdown nav inNavbar active={$current_theme}>
<Dropdown nav inNavbar active={$current_theme && $current_theme.id != 0}>
<DropdownToggle nav caret>
<Icon name="tv" />
Scenarii
@ -22,6 +22,7 @@
<DropdownMenu class="niceborder">
<div>
{#each $themes as th, index}
{#if th.id != 0}
<DropdownItem href="{th.urlid}" active={$current_theme && $current_theme.id == th.id}>
{th.name}
{#if $max_solved > 1 && th.solved == $max_solved}
@ -43,10 +44,43 @@
{#if $my && $my.team_id}{$myThemes[th.id].exercice_solved}/{/if}{th.exercice_count}
</Badge>
</DropdownItem>
{/if}
{/each}
</div>
</DropdownMenu>
</Dropdown>
{#if $themesStore && $themesStore["0"] && $themesStore["0"].exercices}
<Dropdown nav inNavbar active={$current_theme && $current_theme && $current_theme.id == 0}>
<DropdownToggle nav caret>
<Icon name="pencil" />
Défis
</DropdownToggle>
<DropdownMenu class="niceborder">
<div>
{#each $themesStore["0"].exercices as exercice, index}
<DropdownItem href="{$themesStore["0"].urlid}/{exercice.urlid}" active={$current_theme && $current_theme.id == 0 && $current_exercice && $current_exercice.id == exercice.id}>
{exercice.title}
{#if exercice.solved}
<Badge color="secondary">
<Icon name="check" />
</Badge>
{/if}
{#if exercice.curcoeff > 1}
<Badge color="success">
<Icon name="gift-fill" />
</Badge>
{/if}
{#if $themesStore["0"].locked || exercice.disabled}
<Badge color="light">
<Icon name="lock-fill" />
</Badge>
{/if}
</DropdownItem>
{/each}
</div>
</DropdownMenu>
</Dropdown>
{/if}
<style>
div {

View File

@ -35,7 +35,11 @@
<Column header="Raison">
{#if row.reason == "Validation"}
<Badge color="success"><Icon name="check" /></Badge>
{#if !$exercices_idx[row.id_exercice].id_theme == 0}
Défi validé
{:else}
Étape validée
{/if}
{:else if row.reason == "First blood"}
<Badge color="light"><Icon name="trophy" /></Badge>
Bonus premier sang
@ -56,7 +60,7 @@
{row.reason}
{/if}
{#if row.id_exercice && $exercices_idx[row.id_exercice]}
sur <a href="/{$themes[$exercices_idx[row.id_exercice].id_theme].urlid}/{$exercices_idx[row.id_exercice].urlid}">
: <a href="/{$themes[$exercices_idx[row.id_exercice].id_theme].urlid}/{$exercices_idx[row.id_exercice].urlid}">
{$exercices_idx[row.id_exercice].title}
</a>
{/if}

View File

@ -50,11 +50,25 @@
<div style="background-image: url({heading_image})" class="page-header">
<Container class="text-primary">
<h1 class="display-2">
{#if $current_theme.urlid == "_"}
<a href="{$current_theme.urlid}">{#if $current_exercice}{$current_exercice.title}{:else}Défis indépendants{/if}</a>
{:else}
<a href="{$current_theme.urlid}">{$current_theme.name}</a>
{/if}
</h1>
<h2>{@html current_authors}</h2>
<h2>
{#if current_authors}
{@html current_authors}
{:else}
{$challengeInfo.authors}
{/if}
</h2>
</Container>
{#if heading_image}
<div class="headerfade"></div>
{:else}
<div style="height: 3rem;"></div>
{/if}
</div>
<Container>
<slot></slot>

View File

@ -27,6 +27,8 @@
Vous n'avez pas encore accès à ce défi.
</Alert>
{:else}
{#if $current_theme.id != 0}
<ThemeNav theme={$current_theme} exercice={$current_exercice} />
{/if}
<slot></slot>
{/if}