Skip to content

Commit

Permalink
fix: button loading overlap (#119)
Browse files Browse the repository at this point in the history
  • Loading branch information
joshuagraber authored Nov 12, 2024
1 parent 7ace5f7 commit d35efc6
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 11 deletions.
22 changes: 19 additions & 3 deletions src/components/Button/PdapButton.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
<template>
<button :class="classes">
<slot v-if="!isLoading" />
<slot v-if="isLoading && $slots.loading" name="loading" />
<Spinner :show="isLoading && !$slots.loading" />
<TransitionGroup mode="out-in">
<slot v-if="!isLoading" />
<slot v-if="isLoading && $slots.loading" name="loading" />
<Spinner v-if="isLoading && !$slots.loading" :show="isLoading" />
</TransitionGroup>
</button>
</template>

Expand Down Expand Up @@ -77,3 +79,17 @@ export default {
}
}
</style>

<style scoped>
@media (prefers-reduced-motion: no-preference) {
.v-enter-active,
.v-leave-active {
transition: opacity 0.5s ease;
}
.v-enter-from,
.v-leave-to {
opacity: 0;
}
}
</style>
8 changes: 4 additions & 4 deletions src/components/Button/__snapshots__/button.spec.ts.snap
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html

exports[`Renders button component > Renders a button 1`] = `
<button class="pdap-button pdap-button-primary">Button Content
<!--v-if-->
<transition-stub appear="true" css="true" persisted="false">
<button class="pdap-button pdap-button-primary">
<transition-group-stub appear="false" css="true" mode="out-in" persisted="false">Button Content
<!--v-if-->
</transition-stub>
<!--v-if-->
</transition-group-stub>
</button>
`;
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ exports[`QuickSearchForm component > Renders a QuickSearchForm 1`] = `
<!--v-if-->
</label>
</div>
<button class="pdap-button pdap-button-primary flex-grow-0 flex-shrink-0 basis-full max-w-[unset] mt-4" type="submit">Search Data Sources
<!--v-if-->
<transition-stub appear="true" css="true" persisted="false">
<button class="pdap-button pdap-button-primary flex-grow-0 flex-shrink-0 basis-full max-w-[unset] mt-4" type="submit">
<transition-group-stub appear="false" css="true" mode="out-in" persisted="false">Search Data Sources
<!--v-if-->
<!--v-if-->
</transition-stub>
</transition-group-stub>
</button>
</form>
<p class="max-w-[unset] text-med"> For example, you could search for <a> stops in Pittsburgh </a> or <a> complaints everywhere </a> . </p>
Expand Down

0 comments on commit d35efc6

Please sign in to comment.