Button loading re-factoring..

This commit is contained in:
Cüneyt Şentürk 2022-06-16 18:32:41 +03:00
parent 68e0b539d5
commit 9b0cb3da35
12 changed files with 71 additions and 39 deletions

View File

@ -41,8 +41,9 @@
override="class" override="class"
data-loading-text="{{ trans('general.loading') }}" data-loading-text="{{ trans('general.loading') }}"
> >
<span>{{ trans('general.send') }}</span> <x-button.loading>
<x-button.loading v-if="form.loading" text="{{ trans('general.send') }}" text-hide="[{'opacity-0': form.loading}]" /> {{ trans('general.send') }}
</x-button.loading>
</x-button> </x-button>
</div> </div>
</x-form> </x-form>

View File

@ -70,8 +70,9 @@
override="class" override="class"
data-loading-text="{{ trans('general.loading') }}" data-loading-text="{{ trans('general.loading') }}"
> >
<span>{{ trans('auth.login') }}</span> <x-button.loading>
<x-button.loading v-if="form.loading" text="{{ trans('auth.login') }}" text-hide="[{'opacity-0': form.loading}]" /> {{ trans('auth.login') }}
</x-button.loading>
</x-button> </x-button>
</div> </div>
</x-form> </x-form>

View File

@ -58,8 +58,9 @@
override="class" override="class"
data-loading-text="{{ trans('general.loading') }}" data-loading-text="{{ trans('general.loading') }}"
> >
<span>{{ trans('auth.reset') }}</span> <x-button.loading>
<x-button.loading v-if="form.loading" text="{{ trans('auth.reset') }}" text-hide="[{'opacity-0': form.loading}]" /> {{ trans('auth.reset') }}
</x-button.loading>
</x-button> </x-button>
</div> </div>
</x-form> </x-form>

View File

@ -264,8 +264,9 @@
class="flex items-center justify-center bg-transparent hover:bg-gray-200 px-3 py-1.5 text-base rounded-lg disabled:opacity-50" class="flex items-center justify-center bg-transparent hover:bg-gray-200 px-3 py-1.5 text-base rounded-lg disabled:opacity-50"
override="class" override="class"
> >
<span>{{ trans('reconciliations.save_draft') }}</span> <x-button.loading>
<x-button.loading v-if="form.loading" text="{{ trans('reconciliations.save_draft') }}" text-hide="[{'opacity-0': form.loading}]" /> {{ trans('reconciliations.save_draft') }}
</x-button.loading>
</x-button> </x-button>
<div v-if="reconcile"> <div v-if="reconcile">
@ -278,8 +279,9 @@
@click="onReconcileSubmit" @click="onReconcileSubmit"
data-loading-text="{{ trans('general.loading') }}" data-loading-text="{{ trans('general.loading') }}"
> >
<span>{{ trans('reconciliations.reconcile') }}</span> <x-button.loading action="! reconcile">
<x-button.loading v-if="form.loading" text="{{ trans('reconciliations.reconcile') }}" text-hide="[{'opacity-1': reconcile}]" /> {{ trans('reconciliations.reconcile') }}
</x-button.loading>
</x-button> </x-button>
</x-tooltip> </x-tooltip>
</div> </div>
@ -292,8 +294,9 @@
@click="onReconcileSubmit" @click="onReconcileSubmit"
data-loading-text="{{ trans('general.loading') }}" data-loading-text="{{ trans('general.loading') }}"
> >
<span>{{ trans('reconciliations.reconcile') }}</span> <x-button.loading action="! reconcile">
<x-button.loading v-if="form.loading" text="{{ trans('reconciliations.reconcile') }}" text-hide="[{'opacity-1': reconcile}]" /> {{ trans('reconciliations.reconcile') }}
</x-button.loading>
</x-button> </x-button>
</div> </div>
</div> </div>

View File

@ -203,9 +203,11 @@
class="relative flex items-center justify-center bg-transparent hover:bg-gray-200 px-3 py-1.5 text-base rounded-lg disabled:opacity-50" class="relative flex items-center justify-center bg-transparent hover:bg-gray-200 px-3 py-1.5 text-base rounded-lg disabled:opacity-50"
override="class" override="class"
> >
<span>{{ trans('general.save') }}</span> <x-button.loading>
<x-button.loading v-if="form.loading" text="{{ trans('general.save') }}" text-hide="[{'opacity-1': reconcile}]" /> {{ trans('general.save') }}
</x-button.loading>
</x-button> </x-button>
<div v-if="reconcile"> <div v-if="reconcile">
<x-tooltip id="tooltip-reconcile" placement="top" message="{{ trans('reconciliations.irreconcilable') }}"> <x-tooltip id="tooltip-reconcile" placement="top" message="{{ trans('reconciliations.irreconcilable') }}">
<x-button <x-button
@ -216,11 +218,13 @@
@click="onReconcileSubmit" @click="onReconcileSubmit"
data-loading-text="{{ trans('general.loading') }}" data-loading-text="{{ trans('general.loading') }}"
> >
<span>{{ trans('reconciliations.reconcile') }}</span> <x-button.loading action="! reconcile">
<x-button.loading v-if="form.loading" text="{{ trans('reconciliations.reconcile') }}" text-hide="[{'opacity-1': reconcile}]" /> {{ trans('reconciliations.reconcile') }}
</x-button.loading>
</x-button> </x-button>
</x-tooltip> </x-tooltip>
</div> </div>
<div v-else> <div v-else>
<x-button <x-button
type="button" type="button"
@ -230,8 +234,9 @@
@click="onReconcileSubmit" @click="onReconcileSubmit"
data-loading-text="{{ trans('general.loading') }}" data-loading-text="{{ trans('general.loading') }}"
> >
<span>{{ trans('reconciliations.reconcile') }}"</span> <x-button.loading action="! reconcile">
<x-button.loading v-if="form.loading" text="{{ trans('reconciliations.reconcile') }}" text-hide="[{'opacity-1': reconcile}]" /> {{ trans('reconciliations.reconcile') }}
</x-button.loading>
</x-button> </x-button>
</div> </div>
</div> </div>

View File

@ -40,9 +40,10 @@
{{ trans('general.cancel') }} {{ trans('general.cancel') }}
</button> </button>
<button :disabled="form.loading" type="button" class="relative flex items-center justify-center bg-green hover:bg-green-700 text-white px-6 py-1.5 text-base rounded-lg disabled:bg-green-100" @click="addTemplate"> <button :disabled="form.loading" type="button" class="relative flex items-center justify-center bg-green hover:bg-green-700 text-white px-6 py-1.5 text-base rounded-lg disabled:bg-green-100" @click="addTemplate">
<span>{{ trans('general.confirm') }}</span> <x-button.loading>
<x-button.loading v-if="form.loading" text="{{ trans('general.confirm') }}" text-hide="[{'opacity-0': form.loading}]" /> {{ trans('general.confirm') }}
</x-button.loading>
</button> </button>
</div> </div>
</template> </template>

View File

@ -47,8 +47,9 @@
::disabled="form.loading" ::disabled="form.loading"
override="class" override="class"
> >
<span>{{ trans('import.import') }}</span> <x-button.loading>
<x-button.loading v-if="form.loading" text="{{ trans('import.import') }}" text-hide="[{'opacity-0': form.loading}]" /> {{ trans('import.import') }}
</x-button.loading>
</x-button> </x-button>
</div> </div>
</div> </div>

View File

@ -1,9 +1,21 @@
@props('action')
@php
if (empty($action)) {
$action = 'form.loading';
}
@endphp
<i <i
@class([ @class([
'animate-submit delay-[0.28s] absolute w-2 h-2 rounded-full left-0 right-0 -top-3.5 m-auto', 'animate-submit delay-[0.28s] absolute w-2 h-2 rounded-full left-0 right-0 -top-3.5 m-auto',
'before:absolute before:w-2 before:h-2 before:rounded-full before:animate-submit before:delay-[0.14s]', 'before:absolute before:w-2 before:h-2 before:rounded-full before:animate-submit before:delay-[0.14s]',
'after:absolute after:w-2 after:h-2 after:rounded-full after:animate-submit before:-left-3.5 after:-right-3.5 after:delay-[0.42s]' 'after:absolute after:w-2 after:h-2 after:rounded-full after:animate-submit before:-left-3.5 after:-right-3.5 after:delay-[0.42s]'
]) ])
{{ $attributes }} {{ $attributes }}
v-if="{{ $action }}"
> >
</i> </i>
<span :class="[{'opacity-0': {{ $action }}}]">
{!! $slot !!}
</span>

View File

@ -17,8 +17,9 @@
::disabled="form.loading" ::disabled="form.loading"
override="class" override="class"
> >
<span>{{ trans('general.save') }}</span> <x-button.loading>
<x-button.loading v-if="form.loading" text="{{ trans('general.save') }}" text-hide="[{'opacity-0': form.loading}]" /> {{ trans('general.save') }}
</x-button.loading>
</x-button> </x-button>
</div> </div>
@stack('save_buttons_end') @stack('save_buttons_end')

View File

@ -21,8 +21,9 @@
@click="onModuleLoadMore('releases')" @click="onModuleLoadMore('releases')"
class="w-48 bg-green m-auto block whitespace-nowrap px-4 py-2 border border-transparent rounded-md shadow-sm text-base font-medium text-white text-center js-learn-more js-button-modal-submit hover:bg-green-700 disabled:bg-green-300" class="w-48 bg-green m-auto block whitespace-nowrap px-4 py-2 border border-transparent rounded-md shadow-sm text-base font-medium text-white text-center js-learn-more js-button-modal-submit hover:bg-green-700 disabled:bg-green-300"
> >
<span>{{ trans('modules.see_more') }}</span> <x-button.loading action="loadMoreLoading">
<x-button.loading v-if="loadMoreLoading" text="{{ trans('modules.see_more') }}" text-hide="[{'opacity-0': loadMoreLoading}]" /> {{ trans('modules.see_more') }}
</x-button.loading>
</button> </button>
</div> </div>

View File

@ -21,8 +21,9 @@
@click="onModuleLoadMore('reviews')" @click="onModuleLoadMore('reviews')"
class="w-48 bg-green m-auto block whitespace-nowrap px-4 py-2 border border-transparent rounded-md shadow-sm text-base font-medium text-white text-center js-learn-more js-button-modal-submit hover:bg-green-700 disabled:bg-green-300" class="w-48 bg-green m-auto block whitespace-nowrap px-4 py-2 border border-transparent rounded-md shadow-sm text-base font-medium text-white text-center js-learn-more js-button-modal-submit hover:bg-green-700 disabled:bg-green-300"
> >
<span>{{ trans('modules.see_more') }}</span> <x-button.loading action="loadMoreLoading">
<x-button.loading v-if="loadMoreLoading" text="{{ trans('modules.see_more') }}" text-hide="[{'opacity-0': loadMoreLoading}]" /> {{ trans('modules.see_more') }}
</x-button.loading>
</button> </button>
</div> </div>

View File

@ -30,12 +30,16 @@
@if ($seeMore) @if ($seeMore)
<div class="flex items-center mt-10"> <div class="flex items-center mt-10">
<button type="button" id="button-pre-load" @click="onloadMore" <button
type="button"
id="button-pre-load"
@click="onloadMore"
:disabled="loadMoreLoading" :disabled="loadMoreLoading"
class="w-48 m-auto relative flex items-center justify-center bg-green hover:bg-green-700 text-white px-6 py-1.5 text-base rounded-lg disabled:bg-green-100 js-learn-more js-button-modal-submit" class="w-48 m-auto relative flex items-center justify-center bg-green hover:bg-green-700 text-white px-6 py-1.5 text-base rounded-lg disabled:bg-green-100 js-learn-more js-button-modal-submit"
> >
<span>{{ trans('modules.see_more') }}</span> <x-button.loading action="loadMoreLoading">
<x-button.loading v-if="loadMoreLoading" text="{{ trans('modules.see_more') }}" text-hide="[{'opacity-0': loadMoreLoading}]" /> {{ trans('modules.see_more') }}
</x-button.loading>
</button> </button>
<x-form.input.hidden name="see_more_path" value="{{ route('apps.load-more', ['type' => $type]) }}" /> <x-form.input.hidden name="see_more_path" value="{{ route('apps.load-more', ['type' => $type]) }}" />