-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Just getting things loaded without panics was a bit of a challenge. For now, I'm committing these changes and will complete the actual editor in other commits. In the medium term, I really need to fix how steps and poses are loaded.
- Loading branch information
Showing
23 changed files
with
614 additions
and
110 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<script> | ||
import { LEFT_RIGHT_COLORING_LIGHT } from '$lib/constants'; | ||
import { PoseWrapper } from '$lib/instructor/bouncy_instructor'; | ||
import Svg from './avatar/Svg.svelte'; | ||
import SvgAvatar from './avatar/SvgAvatar.svelte'; | ||
/** @type {PoseWrapper} */ | ||
export let pose; | ||
export let size = 200; | ||
export let style = LEFT_RIGHT_COLORING_LIGHT; | ||
</script> | ||
|
||
<div class="avatar"> | ||
<Svg width={size} height={size} orderByZ> | ||
<SvgAvatar skeleton={pose.skeleton()} width={size} height={size} {style} | ||
></SvgAvatar> | ||
</Svg> | ||
</div> |
78 changes: 78 additions & 0 deletions
78
bouncy_frontend/src/lib/components/editor/StepEditForm.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
<script> | ||
import { t } from '$lib/i18n'; | ||
import { | ||
PoseWrapper, | ||
StepPositionBuilder, | ||
StepWrapper, | ||
} from '$lib/instructor/bouncy_instructor'; | ||
import { getContext } from 'svelte'; | ||
import DraggableList from '../ui/DraggableList.svelte'; | ||
import UiBox from '../ui/UiBox.svelte'; | ||
import Pose from '../Pose.svelte'; | ||
const localCollectionCtx = getContext('localCollection'); | ||
const availablePoses = localCollectionCtx.poses; | ||
/** @param {StepWrapper} loadedStep */ | ||
export function loadStep(loadedStep) { | ||
step = loadedStep; | ||
stepName = step.name; | ||
} | ||
/** @type {StepWrapper} */ | ||
let step = newStep(); | ||
let stepName = $t('editor.name-input-placeholder'); | ||
$: stepPositionBuilders = step.positions(); | ||
let showAddNewItem = false; | ||
function newStep() { | ||
const idNum = Math.random().toFixed(6).substring(2); | ||
const id = `step-${idNum}`; | ||
const name = `Step ${idNum} Name`; | ||
const step = new StepWrapper(id, name, 'lab'); | ||
localCollectionCtx.addStep(step); | ||
return step; | ||
} | ||
/** @param {PoseWrapper} pose */ | ||
function addPose(pose) { | ||
step.addPosition(new StepPositionBuilder(pose)); | ||
step = step; | ||
} | ||
</script> | ||
|
||
<input id="name" name="name" bind:value={stepName} /> | ||
|
||
<DraggableList items={stepPositionBuilders} bind:showAddNewItem> | ||
<slot slot="main" let:item={position}> | ||
<div class="pose"> | ||
<Pose pose={position.pose()}></Pose> | ||
</div> | ||
</slot> | ||
<slot slot="name" let:item={position}>{position.pose().name('en')}</slot> | ||
</DraggableList> | ||
|
||
{#if showAddNewItem} | ||
<UiBox title="editor.pick-pose-prompt"> | ||
<div> | ||
{#each $availablePoses as pose} | ||
<div | ||
on:click={() => addPose(pose)} | ||
role="button" | ||
tabindex={0} | ||
on:keydown={(event) => { | ||
if (event.key === 'Enter' || event.key === ' ') { | ||
addPose(pose); | ||
} | ||
}} | ||
> | ||
<div class="pose"> | ||
<p>{pose.name('en')}</p> | ||
<Pose {pose}></Pose> | ||
</div> | ||
</div> | ||
{/each} | ||
</div> | ||
</UiBox> | ||
{/if} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.