add transitions
This commit is contained in:
parent
8779d8ae31
commit
d6f07a26e5
@ -5,17 +5,31 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { genApi } from '$lib/store/api.js';
|
import { genApi } from '$lib/store/api.js';
|
||||||
|
import { writable } from 'svelte/store';
|
||||||
import { setContext } from 'svelte';
|
import { setContext } from 'svelte';
|
||||||
import Beer from '$lib/components/Beer.svelte';
|
import Beer from '$lib/components/Beer.svelte';
|
||||||
import Router from 'svelte-spa-router';
|
import Router from 'svelte-spa-router';
|
||||||
import Campaigns from '$lib/components/Campaigns.svelte';
|
import Campaigns from '$lib/components/Campaigns.svelte';
|
||||||
import Campaign from '$lib/components/Campaign.svelte';
|
import Campaign from '$lib/components/Campaign.svelte';
|
||||||
import Battle from '$lib/components/Battle.svelte';
|
import Battle from '$lib/components/Battle.svelte';
|
||||||
|
import { push } from 'svelte-spa-router';
|
||||||
|
|
||||||
const api = genApi();
|
const api = genApi();
|
||||||
|
|
||||||
setContext('api', api);
|
setContext('api', api);
|
||||||
|
|
||||||
|
const transition = writable('');
|
||||||
|
transition.goRight = (uri) => {
|
||||||
|
transition.set('right');
|
||||||
|
push(uri);
|
||||||
|
};
|
||||||
|
transition.goLeft = (uri) => {
|
||||||
|
transition.set('left');
|
||||||
|
push(uri);
|
||||||
|
};
|
||||||
|
|
||||||
|
setContext('transition', transition);
|
||||||
|
|
||||||
const routes = {
|
const routes = {
|
||||||
// Exact path
|
// Exact path
|
||||||
'/': Campaigns,
|
'/': Campaigns,
|
||||||
|
@ -25,10 +25,14 @@
|
|||||||
</h5>
|
</h5>
|
||||||
</nav>
|
</nav>
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
|
{#key params.battleId}
|
||||||
|
<div in:fly={flyParams} class="body">
|
||||||
<h6>
|
<h6>
|
||||||
<span
|
<span
|
||||||
>Chapter {chapter},
|
>Chapter {chapter},
|
||||||
<span class="battleNbr">battle {chapterBattle}</span></span
|
<span class="battleNbr">battle {chapterBattle}</span
|
||||||
|
></span
|
||||||
>
|
>
|
||||||
<span class="status">{status}</span>
|
<span class="status">{status}</span>
|
||||||
</h6>
|
</h6>
|
||||||
@ -47,7 +51,9 @@
|
|||||||
selection={city.selection}
|
selection={city.selection}
|
||||||
choices={status !== 'ongoing'
|
choices={status !== 'ongoing'
|
||||||
? []
|
? []
|
||||||
: city.choices.filter((c) => c !== city.selection)}
|
: city.choices.filter(
|
||||||
|
(c) => c !== city.selection,
|
||||||
|
)}
|
||||||
/>
|
/>
|
||||||
{/if}
|
{/if}
|
||||||
</dd>
|
</dd>
|
||||||
@ -84,7 +90,10 @@
|
|||||||
step="0.5"
|
step="0.5"
|
||||||
value={difficulty}
|
value={difficulty}
|
||||||
on:change={({ target: { value } }) =>
|
on:change={({ target: { value } }) =>
|
||||||
event.setBattleDifficulty(params.battleId, value)}
|
event.setBattleDifficulty(
|
||||||
|
params.battleId,
|
||||||
|
value,
|
||||||
|
)}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -115,20 +124,28 @@
|
|||||||
{#if status === 'upcoming'}
|
{#if status === 'upcoming'}
|
||||||
<button>Start battle</button>
|
<button>Start battle</button>
|
||||||
{:else if status === 'ongoing'}
|
{:else if status === 'ongoing'}
|
||||||
<button on:click={battleVerdict('won')}>Battle won</button>
|
<button on:click={battleVerdict('won')}
|
||||||
<button class="tertiary" on:click={battleVerdict('lost')}
|
>Battle won</button
|
||||||
>Battle lost</button
|
>
|
||||||
|
<button
|
||||||
|
class="tertiary"
|
||||||
|
on:click={battleVerdict('lost')}>Battle lost</button
|
||||||
>
|
>
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
{/key}
|
||||||
|
|
||||||
<footer class="fixed">
|
<footer class="fixed">
|
||||||
<nav>
|
<nav>
|
||||||
<a
|
<a
|
||||||
href={`#/campaign/${$activeCampaign?._id}` +
|
on:click={() =>
|
||||||
|
transition.goLeft(
|
||||||
|
`#/campaign/${$activeCampaign?._id}` +
|
||||||
(battle?.id == 1
|
(battle?.id == 1
|
||||||
? ''
|
? ''
|
||||||
: `/battle/${parseInt(battle?.id) - 1}`)}
|
: `/battle/${parseInt(battle?.id) - 1}`),
|
||||||
|
)}
|
||||||
>
|
>
|
||||||
<button class="circle transparent">
|
<button class="circle transparent">
|
||||||
<i>arrow_backward</i>
|
<i>arrow_backward</i>
|
||||||
@ -136,9 +153,12 @@
|
|||||||
</a>
|
</a>
|
||||||
{#if battles?.length > battle?.id}
|
{#if battles?.length > battle?.id}
|
||||||
<a
|
<a
|
||||||
href={`#/campaign/${$activeCampaign?._id}/battle/${
|
on:click={() =>
|
||||||
|
transition.goRight(
|
||||||
|
`/campaign/${$activeCampaign?._id}/battle/${
|
||||||
battle?.id + 1
|
battle?.id + 1
|
||||||
}`}
|
}`,
|
||||||
|
)}
|
||||||
>
|
>
|
||||||
<button class="circle transparent">
|
<button class="circle transparent">
|
||||||
<i>arrow_forward</i>
|
<i>arrow_forward</i>
|
||||||
@ -155,6 +175,8 @@
|
|||||||
import { getContext } from 'svelte';
|
import { getContext } from 'svelte';
|
||||||
import AdditionalCharacter from './Battle/AdditionalCharacter.svelte';
|
import AdditionalCharacter from './Battle/AdditionalCharacter.svelte';
|
||||||
|
|
||||||
|
import { fly } from 'svelte/transition';
|
||||||
|
|
||||||
export let params;
|
export let params;
|
||||||
|
|
||||||
export let api = getContext('api');
|
export let api = getContext('api');
|
||||||
@ -199,6 +221,16 @@
|
|||||||
const changeCity = ({ target: { value } }) => {
|
const changeCity = ({ target: { value } }) => {
|
||||||
event?.setCity(params.battleId, value);
|
event?.setCity(params.battleId, value);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const transition = getContext('transition');
|
||||||
|
let flyParams = { x: 200, duration: 0 };
|
||||||
|
$: if ($transition) {
|
||||||
|
flyParams.duration = 200;
|
||||||
|
flyParams.x = $transition === 'right' ? 200 : -200;
|
||||||
|
transition.set('');
|
||||||
|
} else {
|
||||||
|
flyParams.duration = 0;
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
@ -14,6 +14,8 @@
|
|||||||
</nav>
|
</nav>
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
|
{#key params.campaignId}
|
||||||
|
<div in:fly={flyParams} class="body">
|
||||||
{#if $activeCampaign}
|
{#if $activeCampaign}
|
||||||
{#if status !== 'ongoing'}
|
{#if status !== 'ongoing'}
|
||||||
<h6>{status}</h6>{/if}
|
<h6>{status}</h6>{/if}
|
||||||
@ -24,7 +26,12 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<h6>Chapter 1</h6>
|
<h6>Chapter 1</h6>
|
||||||
<Battle {...battles[0]} {campaignId} chapter={1} chapterBattle={1} />
|
<Battle
|
||||||
|
{...battles[0]}
|
||||||
|
{campaignId}
|
||||||
|
chapter={1}
|
||||||
|
chapterBattle={1}
|
||||||
|
/>
|
||||||
<div class="medium-divider" />
|
<div class="medium-divider" />
|
||||||
<Battle
|
<Battle
|
||||||
{...battles[1] ?? { id: 'notYet' }}
|
{...battles[1] ?? { id: 'notYet' }}
|
||||||
@ -107,6 +114,7 @@
|
|||||||
/>
|
/>
|
||||||
<div class="medium-divider" />
|
<div class="medium-divider" />
|
||||||
{/if}
|
{/if}
|
||||||
|
</div>{/key}
|
||||||
<footer class="fixed">
|
<footer class="fixed">
|
||||||
<nav>
|
<nav>
|
||||||
<a href={`#/campaign/${$activeCampaign?._id}/battle/1`}>
|
<a href={`#/campaign/${$activeCampaign?._id}/battle/1`}>
|
||||||
@ -121,6 +129,7 @@
|
|||||||
<script>
|
<script>
|
||||||
import * as R from 'remeda';
|
import * as R from 'remeda';
|
||||||
import Battle from './Campaign/Battle.svelte';
|
import Battle from './Campaign/Battle.svelte';
|
||||||
|
import { fly } from 'svelte/transition';
|
||||||
|
|
||||||
import { getContext } from 'svelte';
|
import { getContext } from 'svelte';
|
||||||
|
|
||||||
@ -144,7 +153,7 @@
|
|||||||
R.groupBy(({ id }) => R.clamp(1 + parseInt(id / 2), { max: 4 })),
|
R.groupBy(({ id }) => R.clamp(1 + parseInt(id / 2), { max: 4 })),
|
||||||
);
|
);
|
||||||
|
|
||||||
$: console.log(byChapter);
|
let flyParams = { x: 200, duration: 200 };
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
Loading…
Reference in New Issue
Block a user