Skip to content

Commit

Permalink
fix(components): update button loading state children
Browse files Browse the repository at this point in the history
  • Loading branch information
joshuagraber committed Nov 13, 2024
1 parent 491beed commit 3af1108
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
12 changes: 3 additions & 9 deletions src/components/Button/PdapButton.vue
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
<template>
<button :class="classes">
<component
:is="isLoading ? Spinner : $slots.default"
v-bind="isLoading ? loadingProps : undefined"
/>
<slot v-if="!isLoading" />
<Spinner v-if="isLoading" :show="isLoading" />
</button>
</template>

<script setup lang="ts">
// Imports
import { reactive } from 'vue';
import Spinner from '../Spinner/PdapSpinner.vue';
import { Spinner } from '../Spinner';
// Types
import { PdapButtonProps } from './types';
Expand All @@ -21,10 +19,6 @@ const props = withDefaults(defineProps<PdapButtonProps>(), {
isLoading: false,
});
const loadingProps = {
show: props.isLoading,
};
// CSS class map
const classes = reactive({
'pdap-button': true,
Expand Down
6 changes: 5 additions & 1 deletion src/components/Button/__snapshots__/button.spec.ts.snap
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// 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</button>`;
exports[`Renders button component > Renders a button 1`] = `
<button class="pdap-button pdap-button-primary">Button Content
<!--v-if-->
</button>
`;
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ 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</button>
<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-->
</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>
</div>
Expand Down

0 comments on commit 3af1108

Please # to comment.