Skip to content

Commit

Permalink
feat: add custom size to spinner
Browse files Browse the repository at this point in the history
  • Loading branch information
gabaldon committed Aug 29, 2024
1 parent 4972e39 commit 4f7af76
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 5 deletions.
6 changes: 5 additions & 1 deletion src/components/Spinner/WSpinner.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ import WSpinner from './WSpinner.vue'

describe('WSpinner', () => {
it('renders properly', () => {
const wrapper = mount(WSpinner)
const wrapper = mount(WSpinner, {
props: {
size: '16px'
}
})

expect(wrapper.element).toMatchSnapshot()
})
Expand Down
5 changes: 4 additions & 1 deletion src/components/Spinner/WSpinner.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ export const Default: Story = {
setup() {
return { args }
},
template: `<WSpinner />`
template: `<WSpinner v-bind="args" />`,
args: {
size: '30px'
}
})
}
20 changes: 18 additions & 2 deletions src/components/Spinner/WSpinner.vue
Original file line number Diff line number Diff line change
@@ -1,9 +1,25 @@
<template>
<div role="status">
<Spinner aria-hidden="true" class="w-8 h-8 text-gray-100 animate-spin fill-wit-blue-500" />
<div role="status" class="spinner">
<Spinner
aria-hidden="true"
class="w-full h-full text-gray-100 animate-spin fill-wit-blue-500"
/>
<span class="sr-only">Loading...</span>
</div>
</template>
<script lang="ts" setup>
import Spinner from '@/assets/svg/spinner.svg?component'
defineProps({
size: {
type: String,
default: '40px'
}
})
</script>

<style lang="scss">
.spinner {
width: v-bind(size);
height: auto;
}
</style>
3 changes: 2 additions & 1 deletion src/components/Spinner/__snapshots__/WSpinner.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@

exports[`WSpinner > renders properly 1`] = `
<div
class="spinner"
role="status"
>
<svg
aria-hidden="true"
class="w-8 h-8 text-gray-100 animate-spin fill-wit-blue-500"
class="w-full h-full text-gray-100 animate-spin fill-wit-blue-500"
fill="none"
viewBox="0 0 100 101"
xmlns="http://www.w3.org/2000/svg"
Expand Down

0 comments on commit 4f7af76

Please sign in to comment.