Skip to content

feat: folder animations #136

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/components/Folder.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ describe('folder Controls', () => {

it('should render controls within a folder', () => {
mountComponent(() => {
const { position } = useControls('camera', { position: new Vector3(3, 2, 4) })
return { position }
const { cameraPosition } = useControls('camera', { position: new Vector3(3, 2, 4) })
return { cameraPosition }
})
expect(wrapper.html().replace(/style="[^"]*"/, '')).toMatchSnapshot()
expect(wrapper.find('button[data-folder="camera"]').exists()).toBe(true)
Expand All @@ -59,8 +59,8 @@ describe('folder Controls', () => {

it('should have unique keys for controls in different folders', () => {
mountComponent(() => {
const { position: cameraPosition } = useControls('camera', { position: new Vector3(3, 2, 4) })
const { position: lightPosition } = useControls('light', { position: new Vector3(4, 4, 4) })
const { cameraPosition } = useControls('camera', { position: new Vector3(3, 2, 4) })
const { lightPosition } = useControls('light', { position: new Vector3(4, 4, 4) })
return { controls: [cameraPosition, lightPosition], label: 'camera' }
})
const cameraInput = wrapper.find('input#default-cameraPosition-x')
Expand Down
50 changes: 29 additions & 21 deletions src/components/Folder.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const toggle = () => {
</script>

<template>
<div class="tl-mb-4">
<div class="tl-mb-2 tl-transition-all tl-duration-400 tl-ease-in-out">
<button
class="
tl-flex
Expand All @@ -38,6 +38,8 @@ const toggle = () => {
tl-text-xs
tl-font-sans
tl-cursor-pointer
tl-relative
tl-z-10
"
:aria-expanded="isOpen"
aria-haspopup="true"
Expand All @@ -50,27 +52,33 @@ const toggle = () => {
<i :class="isOpen ? 'i-ic:baseline-keyboard-arrow-up' : 'i-ic:baseline-keyboard-arrow-down'"></i>
</button>

<Transition
name="slide"
enter-active-class="tl-animate-fade-in tl-animate-duration-200 tl-animate-ease-in-out"
leave-active-class="tl-animate-fade-out tl-animate-duration-200 tl-animate-ease-in-out"
>
<div
v-show="isOpen"
class="tl-bg-white dark:tl-bg-dark-300 tl-rounded-b tl-pt-4"
role="menu"
<div class="tl-relative tl-overflow-hidden">
<Transition
name="slide"
enter-active-class="tl-transition-[transform,opacity] tl-duration-200 tl-ease-out"
enter-from-class="tl-origin-top tl-scale-y-0 tl-opacity-0"
enter-to-class="tl-origin-top tl-scale-y-100 tl-opacity-100"
leave-active-class="tl-transition-[transform,opacity] tl-duration-200 tl-ease-in"
leave-from-class="tl-origin-top tl-scale-y-100 tl-opacity-100"
leave-to-class="tl-origin-top tl-scale-y-0 tl-opacity-0"
>
<template
v-for="subcontrol in controls"
:key="subcontrol.label"
<div
v-show="isOpen"
class="tl-bg-white dark:tl-bg-dark-300 tl-rounded-b tl-pt-4 tl-pb-2"
role="menu"
>
<ControlInput
:control="subcontrol"
role="menuitem"
@change="newValue => onChange(newValue, subcontrol)"
/>
</template>
</div>
</Transition>
<template
v-for="subcontrol in controls"
:key="subcontrol.label"
>
<ControlInput
:control="subcontrol"
role="menuitem"
@change="newValue => onChange(newValue, subcontrol)"
/>
</template>
</div>
</Transition>
</div>
</div>
</template>
24 changes: 13 additions & 11 deletions src/components/__snapshots__/Folder.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,22 @@ exports[`folder Controls > should render controls within a folder 1`] = `
<div class="tl-pointer-events-none tl-absolute tl-left-0 tl-right-0 tl-top-0 tl-h-8 tl-bg-gradient-linear tl-bg-gradient-to-b tl-from-white dark:tl-from-dark-200 tl-to-transparent tl-z-20 tl-opacity-0 tl-transition-opacity duration-200"></div>
<div class="tl-pointer-events-none tl-absolute tl-left-0 tl-right-0 tl-bottom-0 tl-h-8 tl-bg-gradient-linear tl-bg-gradient-to-t tl-from-white dark:tl-from-dark-200 tl-to-transparent tl-z-20 tl-opacity-0 tl-transition-opacity duration-200"></div>
<div class="tl-h-full tl-overflow-y-auto tl-overflow-x-hidden tl-scrollbar tl-scrollbar-rounded tl-scrollbar-w-4px tl-scrollbar-radius-2 tl-scrollbar-track-radius-4 tl-scrollbar-thumb-radius-4 tl-scrollbar-track-color-gray-100 dark:tl-scrollbar-track-color-dark-300 tl-scrollbar-thumb-color-gray-300 dark:tl-scrollbar-thumb-color-gray-400">
<div class="tl-mb-4"><button class="tl-flex tl-items-center tl-justify-between tl-w-full tl-py-2 tl-px-4 tl-bg-gray-100 dark:tl-bg-dark-300 tl-border-none tl-text-gray-400 dark:tl-text-gray-400 tl-font-bold tl-text-xs tl-font-sans tl-cursor-pointer" aria-expanded="false" aria-haspopup="true" role="button" data-folder="camera" tabindex="0"><span>camera</span><i class="i-ic:baseline-keyboard-arrow-down"></i></button>
<transition-stub name="slide" enteractiveclass="tl-animate-fade-in tl-animate-duration-200 tl-animate-ease-in-out" leaveactiveclass="tl-animate-fade-out tl-animate-duration-200 tl-animate-ease-in-out" appear="false" persisted="true" css="true">
<div class="tl-bg-white dark:tl-bg-dark-300 tl-rounded-b tl-pt-4" role="menu" style="display: none;">
<div role="menuitem">
<div class="tl-flex tl-px-4 tl-justify-between tl-items-center tl-mb-2"><label for="default-cameraPosition" title="position" class="tl-text-gray-500 dark:tl-text-gray-400 tl-w-1/3 tl-truncate">position</label>
<div class="tl-relative tl-w-2/3 tl-flex tl-justify-between tl-gap-0.5">
<div class="tl-flex tl-items-center tl-bg-gray-100 dark:tl-bg-dark-300 tl-rounded tl-border-none tl-outline-none tl-focus:tl-border-gray-200 tl-focus:tl-ring tl-focus:tl-ring-gray-200 tl-w-1/3 tl-w-1/2"><span class="tl-font-bold tl-px-1 tl-py-1 tl-text-0.65rem tl-text-gray-300 dark:tl-text-gray-400">x</span><input id="default-cameraPosition-x" type="number" step="1" class="tl-w-full tl-px-0 tl-p-1 tl-text-right tl-text-0.65rem tl-text-gray-400 dark:tl-text-gray-400 tl-bg-transparent focus:tl-border-gray-200 tl-outline-none tl-border-none tl-font-sans tl-appearence-none" value="3.00"></div>
<div class="tl-flex tl-items-center tl-bg-gray-100 dark:tl-bg-dark-300 tl-rounded tl-border-none tl-outline-none tl-focus:tl-border-gray-200 tl-focus:tl-ring tl-focus:tl-ring-gray-200 tl-w-1/3 tl-w-1/2"><span class="tl-font-bold tl-px-1 tl-py-1 tl-text-0.65rem tl-text-gray-300 dark:tl-text-gray-400">y</span><input id="default-cameraPosition-y" type="number" step="1" class="tl-w-full tl-px-0 tl-p-1 tl-text-right tl-text-0.65rem tl-text-gray-400 dark:tl-text-gray-400 tl-bg-transparent focus:tl-border-gray-200 tl-outline-none tl-border-none tl-font-sans tl-appearence-none" value="2.00"></div>
<div class="tl-flex tl-items-center tl-bg-gray-100 dark:tl-bg-dark-300 tl-rounded tl-border-none tl-outline-none tl-focus:tl-border-gray-200 tl-focus:tl-ring tl-focus:tl-ring-gray-200 tl-w-1/3 tl-w-1/2"><span class="tl-font-bold tl-px-1 tl-py-1 tl-text-0.65rem tl-text-gray-300 dark:tl-text-gray-400">z</span><input id="default-cameraPosition-z" type="number" step="1" class="tl-w-full tl-px-0 tl-p-1 tl-text-right tl-text-0.65rem tl-text-gray-400 dark:tl-text-gray-400 tl-bg-transparent focus:tl-border-gray-200 tl-outline-none tl-border-none tl-font-sans tl-appearence-none" value="4.00"></div>
<div class="tl-mb-2 tl-transition-all tl-duration-400 tl-ease-in-out"><button class="tl-flex tl-items-center tl-justify-between tl-w-full tl-py-2 tl-px-4 tl-bg-gray-100 dark:tl-bg-dark-300 tl-border-none tl-text-gray-400 dark:tl-text-gray-400 tl-font-bold tl-text-xs tl-font-sans tl-cursor-pointer tl-relative tl-z-10" aria-expanded="false" aria-haspopup="true" role="button" data-folder="camera" tabindex="0"><span>camera</span><i class="i-ic:baseline-keyboard-arrow-down"></i></button>
<div class="tl-relative tl-overflow-hidden">
<transition-stub name="slide" enteractiveclass="tl-transition-[transform,opacity] tl-duration-200 tl-ease-out" enterfromclass="tl-origin-top tl-scale-y-0 tl-opacity-0" entertoclass="tl-origin-top tl-scale-y-100 tl-opacity-100" leaveactiveclass="tl-transition-[transform,opacity] tl-duration-200 tl-ease-in" leavefromclass="tl-origin-top tl-scale-y-100 tl-opacity-100" leavetoclass="tl-origin-top tl-scale-y-0 tl-opacity-0" appear="false" persisted="true" css="true">
<div class="tl-bg-white dark:tl-bg-dark-300 tl-rounded-b tl-pt-4 tl-pb-2" role="menu" style="display: none;">
<div role="menuitem">
<div class="tl-flex tl-px-4 tl-justify-between tl-items-center tl-mb-2"><label for="default-cameraPosition" title="position" class="tl-text-gray-500 dark:tl-text-gray-400 tl-w-1/3 tl-truncate">position</label>
<div class="tl-relative tl-w-2/3 tl-flex tl-justify-between tl-gap-0.5">
<div class="tl-flex tl-items-center tl-bg-gray-100 dark:tl-bg-dark-300 tl-rounded tl-border-none tl-outline-none tl-focus:tl-border-gray-200 tl-focus:tl-ring tl-focus:tl-ring-gray-200 tl-w-1/3 tl-w-1/2"><span class="tl-font-bold tl-px-1 tl-py-1 tl-text-0.65rem tl-text-gray-300 dark:tl-text-gray-400">x</span><input id="default-cameraPosition-x" type="number" step="1" class="tl-w-full tl-px-0 tl-p-1 tl-text-right tl-text-0.65rem tl-text-gray-400 dark:tl-text-gray-400 tl-bg-transparent focus:tl-border-gray-200 tl-outline-none tl-border-none tl-font-sans tl-appearence-none" value="3.00"></div>
<div class="tl-flex tl-items-center tl-bg-gray-100 dark:tl-bg-dark-300 tl-rounded tl-border-none tl-outline-none tl-focus:tl-border-gray-200 tl-focus:tl-ring tl-focus:tl-ring-gray-200 tl-w-1/3 tl-w-1/2"><span class="tl-font-bold tl-px-1 tl-py-1 tl-text-0.65rem tl-text-gray-300 dark:tl-text-gray-400">y</span><input id="default-cameraPosition-y" type="number" step="1" class="tl-w-full tl-px-0 tl-p-1 tl-text-right tl-text-0.65rem tl-text-gray-400 dark:tl-text-gray-400 tl-bg-transparent focus:tl-border-gray-200 tl-outline-none tl-border-none tl-font-sans tl-appearence-none" value="2.00"></div>
<div class="tl-flex tl-items-center tl-bg-gray-100 dark:tl-bg-dark-300 tl-rounded tl-border-none tl-outline-none tl-focus:tl-border-gray-200 tl-focus:tl-ring tl-focus:tl-ring-gray-200 tl-w-1/3 tl-w-1/2"><span class="tl-font-bold tl-px-1 tl-py-1 tl-text-0.65rem tl-text-gray-300 dark:tl-text-gray-400">z</span><input id="default-cameraPosition-z" type="number" step="1" class="tl-w-full tl-px-0 tl-p-1 tl-text-right tl-text-0.65rem tl-text-gray-400 dark:tl-text-gray-400 tl-bg-transparent focus:tl-border-gray-200 tl-outline-none tl-border-none tl-font-sans tl-appearence-none" value="4.00"></div>
</div>
</div>
</div>
</div>
</div>
</transition-stub>
</transition-stub>
</div>
</div>
<!--v-if-->
</div>
Expand Down
2 changes: 1 addition & 1 deletion stats.html

Large diffs are not rendered by default.

Loading