Repository navigation
chore(templates): extract scroll-arrows state into useScrollArrows - #145
Conversation
2c7713a to
3d816bd
Compare
Already present transitively via @nextcloud/vue, but the app is about to import from it directly (useScrollArrows), so it needs to be declared rather than relied on implicitly. Assisted-by: ClaudeCode:claude Co-Authored-By: Claude <noreply@anthropic.com> Signed-off-by: James Manuel <moodyjmz@users.noreply.github.com>
3d816bd to
652ec79
Compare
|
/compile |
| <ul ref="list" class="template-section__list" @scroll="updateArrows"> | ||
| <ul ref="list" | ||
| class="template-section__list" | ||
| :aria-label="t('office', '{creator} templates, scrollable', { creator: creator.label })"> |
There was a problem hiding this comment.
Would it make sense to drop the ", scrollable" part? Screen readers would already announce it as a list with N items, and the cards are plain buttons, so keyboard users get there anyway.
There was a problem hiding this comment.
Agreed, dropped. The label is now just {creator} templates.
|
|
||
| expect(resizeObserverInstances[0].disconnect).toHaveBeenCalled() | ||
| globalThis.ResizeObserver = OriginalResizeObserver | ||
| }) |
There was a problem hiding this comment.
This test just tests vue-use internal behaviour so i would argue we can drop it.
There was a problem hiding this comment.
Dropped. It was the only user of withSetup, so that helper is gone too.
juliusknorr
left a comment
There was a problem hiding this comment.
Nice cleanup 👍
Minor comments in line and i would not consider this a feat but rather a chore commit (also for proper positioning in the changelog).
TemplateSection.vue's list ref, canScrollLeft/canScrollRight, updateArrows(), scrollByStep(), and the ResizeObserver onMounted/ onUnmounted wiring were stateful logic with no direct template dependency, inline in the component. Pulled into a composable built on @vueuse/core's useScroll/useResizeObserver instead of hand-rolled scroll tracking, following the reuse-before-you-write ladder. Establishes src/composables/ and its convention for later extractions: individual refs returned (not a reactive() object, which breaks destructuring). Also gives the template list an aria-label naming the creator, so screen readers can tell one creator's list from another's. PR 1 of #134. Assisted-by: ClaudeCode:claude Co-Authored-By: Claude <noreply@anthropic.com> Signed-off-by: James Manuel <moodyjmz@users.noreply.github.com>
e563261 to
d599975
Compare
|
/compile |
Signed-off-by: nextcloud-command <nextcloud-command@users.noreply.github.com>
Summary
PR 1 of #134 — proof of concept for adopting Vue composables as the layer between
src/services/(data) andsrc/components/(render): stateful logic with no direct template dependency.TemplateSection.vue's scroll-arrow state (listref,canScrollLeft/canScrollRight,updateArrows(),scrollByStep(), theResizeObservermount/unmount wiring) intosrc/composables/useScrollArrows.ts, built on@vueuse/core'suseScroll/useResizeObserverrather than hand-rolled — reuse-before-you-write, extended from@nextcloud/*packages to general-purpose Vue utilities.@vueuse/coreas a direct dependency (previously only present transitively via@nextcloud/vue; both now resolve to the same 14.4.0, no duplicate copy in the tree).src/composables/and its convention for PR 2 and beyond: return individual refs (not areactive()object — breaks silently on destructuring).aria-labelnaming its creator.Reuse before you write
@vueuse/core'suseScroll/useResizeObserver— see commit message and #134 for the ladder rationale.Test plan
npm run lintnpm run stylelintnpm run test:unit(154 passing, includes 7 new composable tests + a new a11y test)npm run buildRefs #134.
🤖 Generated with Claude Code