Skip to content

Commit

Permalink
feat: IconButton new states and new spinner component
Browse files Browse the repository at this point in the history
* Replace CircleSpinner to FidgetSpinner
  • Loading branch information
Perdolique committed Sep 11, 2024
1 parent d839de4 commit 9b2f1a2
Show file tree
Hide file tree
Showing 7 changed files with 67 additions and 46 deletions.
4 changes: 3 additions & 1 deletion app/assets/styles/_base.scss
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@

// Buttons
--button-color-text: ghostwhite;

--button-color-disabled: #ccc;
--button-color-disabled-text: #666;
// Inputs
--input-height: 3rem;
--input-spacing-horizontal: 1rem;
Expand All @@ -81,6 +82,7 @@
--input-color-placeholder: #8c8c8c;
--input-color-background: ghostwhite;


// Secondary inputs
--input-secondary-color-main: ghostwhite;
--input-secondary-color-text: #287892;
Expand Down
30 changes: 0 additions & 30 deletions app/components/CircleSpinner.vue

This file was deleted.

22 changes: 22 additions & 0 deletions app/components/FidgetSpinner.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<template>
<Icon
name="tabler:fidget-spinner"
:class="$style.component"
/>
</template>

<style module>
@keyframes spin {
0% {
rotate: 0;
}
100% {
rotate: 360deg;
}
}
.component {
animation: spin 1s linear infinite;
}
</style>
37 changes: 29 additions & 8 deletions app/components/IconButton.vue
Original file line number Diff line number Diff line change
@@ -1,26 +1,41 @@
<template>
<button :class="[$style.button, {
[size]: true,
secondary
}]">
<button
:class="[$style.button, {
[size]: true,
secondary
}]"
:disabled="isButtonDisabled"
>
<FidgetSpinner v-if="loading" />

<Icon
class="icon"
v-else
:name="iconName"
size="1em"
/>
</button>
</template>

<script lang="ts" setup>
interface Props {
import FidgetSpinner from './FidgetSpinner.vue';
interface Props {
readonly iconName: string;
readonly loading?: boolean;
readonly disabled?: boolean;
readonly secondary?: boolean;
readonly size?: 'm' | 's' | 'xs';
}
const {
size = 'm'
} = defineProps<Props>();
size = 'm',
loading = false,
disabled = false
} = defineProps<Props>()
const isButtonDisabled = computed(() => {
return disabled || loading
});
</script>

<style module>
Expand Down Expand Up @@ -74,5 +89,11 @@
background-color: var(--input-secondary-color-active);
}
}
&:disabled {
background-color: var(--button-color-disabled);
color: var(--button-color-disabled-text);
cursor: not-allowed;
}
}
</style>
9 changes: 7 additions & 2 deletions app/components/PerdSearch/PerdSearch.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,12 @@
{{ label }}
</label>

<CircleSpinner :class="[$style.spinner, { visible: searching }]" />
<FidgetSpinner
:class="[$style.spinner, {
visible: searching
}]"
size="1.5em"
/>

<div
:class="[$style.dropdown, {
Expand Down Expand Up @@ -61,7 +66,7 @@
<script lang="ts" setup generic="Option">
import type { InputHTMLAttributes } from 'vue';
import { watchDebounced, onClickOutside } from '@vueuse/core';
import CircleSpinner from '~/components/CircleSpinner.vue';
import FidgetSpinner from '~/components/FidgetSpinner.vue';
import SearchOption from './SearchOption.vue';
import EmptyOption from './EmptyOption.vue';
import DefaultOption from './DefaultOption.vue';
Expand Down
6 changes: 3 additions & 3 deletions app/components/dialogs/CreateChecklistDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@
</form>

<div :class="[$style.loader, { visible: loading }]">
<CircleSpinner />
<FidgetSpinner size="36px" />
</div>
</ModalDialog>
</template>

<script lang="ts" setup>
import { limits } from '~~/constants';
import PerdButton from '~/components/PerdButton.vue'
import CircleSpinner from '~/components/CircleSpinner.vue'
import FidgetSpinner from '~/components/FidgetSpinner.vue'
import ModalDialog from './ModalDialog.vue'
interface Props {
Expand Down Expand Up @@ -114,7 +114,7 @@
inset: 0;
justify-content: center;
align-items: center;
background-color: rgb(0 0 0 / 25%);
background-color: rgb(0 0 0 / 35%);
border-radius: var(--border-radius-24);
transition:
opacity 0.3s ease-out,
Expand Down
5 changes: 3 additions & 2 deletions app/pages/auth/twitch.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@
💀
</div>

<CircleSpinner
<FidgetSpinner
v-else
size="32px"
/>
</div>

Expand All @@ -34,7 +35,7 @@

<script lang="ts" setup>
import { startPagePath } from '~~/constants'
import CircleSpinner from '~/components/CircleSpinner.vue'
import FidgetSpinner from '~/components/FidgetSpinner.vue'
import PerdLink from '~/components/PerdLink.vue';
definePageMeta({
Expand Down

0 comments on commit 9b2f1a2

Please sign in to comment.