-
-
Notifications
You must be signed in to change notification settings - Fork 222
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
196 additions
and
208 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 31 additions & 29 deletions
60
resources/views/components/frameworks/tailwind/toggleable.blade.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,41 @@ | ||
<div> | ||
@if($column->toggleable['enabled'] === true) | ||
<div class="items-center" x-data="{ toggle_{{ $row->id }}: {{ $row->$field }} }"> | ||
<div class="items-center" | ||
x-data="{ toggle_{{ $field }}_{{ $row->id }}: {{ $row->{$field} }} }"> | ||
<div class="relative rounded-full w-12 h-6 transition duration-200 ease-linear" | ||
:class="[toggle_{{ $row->id }} === 1 ? 'bg-green-400' : 'bg-gray-400']"> | ||
<label for="toggle_{{ $row->id }}" | ||
class="absolute left-0 bg-white border-2 mb-2 w-6 h-6 rounded-full transition transform duration-100 ease-linear cursor-pointer" | ||
:class="[toggle_{{ $row->id }} === 1 ? 'translate-x-full border-green-400' : 'translate-x-0 border-gray-400']"></label> | ||
<input type="checkbox" id="toggle_{{ $row->id }}" name="toggle_{{ $row->id }}" | ||
:class="[toggle_{{ $field }}_{{ $row->{$primaryKey} }} === 1 ? 'bg-green-400' : 'bg-gray-400']"> | ||
<label | ||
class="absolute left-0 bg-white border-2 mb-2 w-6 h-6 rounded-full transition transform duration-100 ease-linear cursor-pointer" | ||
:class="[toggle_{{ $field }}_{{ $row->id }} === 1 ? 'translate-x-full border-green-400' : 'translate-x-0 border-gray-400']"></label> | ||
<input type="checkbox" | ||
class="appearance-none w-full h-full active:outline-none focus:outline-none" | ||
@click="saveToggleableInput((toggle_{{ $row->id }} === 0 ? toggle_{{ $row->id }} = 1 : toggle_{{ $row->id }} = 0), {{ $row->id }}, '{{ $field }}')"> | ||
@click="saveToggleableInput((toggle_{{ $field }}_{{ $row->{$primaryKey} }} === 0 ? toggle_{{ $field }}_{{ $row->{$primaryKey} }} = 1 : toggle_{{ $field }}_{{ $row->{$primaryKey} }} = 0), {{ $row->{$primaryKey} }}, '{{ $field }}')"> | ||
</div> | ||
</div> | ||
@else | ||
<div class="flex flex-row"> | ||
@if($row->$field === 0) | ||
<div style="padding-top: 0.1em; padding-bottom: 0.1rem" | ||
class="text-xs px-3 text-center w-full bg-red-200 text-red-800 rounded-full"> | ||
{{ $column->toggleable['default'][1] }} | ||
</div> | ||
@else | ||
<div style="padding-top: 0.1em; padding-bottom: 0.1rem" | ||
class="text-xs px-3 text-center w-full bg-blue-200 text-blue-800 rounded-full"> | ||
{{ $column->toggleable['default'][0] }} | ||
<div class="flex flex-row"> | ||
@if($row->{$field} === 0) | ||
<div style="padding-top: 0.1em; padding-bottom: 0.1rem" | ||
class="text-xs px-3 text-center w-full bg-red-200 text-red-800 rounded-full"> | ||
{{ $column->toggleable['default'][1] }} | ||
</div> | ||
@else | ||
<div style="padding-top: 0.1em; padding-bottom: 0.1rem" | ||
class="text-xs px-3 text-center w-full bg-blue-200 text-blue-800 rounded-full"> | ||
{{ $column->toggleable['default'][0] }} | ||
</div> | ||
@endif | ||
</div> | ||
@endif | ||
</div> | ||
@endif | ||
<script> | ||
function saveToggleableInput(value, id, field) { | ||
document.getElementsByClassName('message')[0].style.display = "none"; | ||
window.livewire.emit('eventToggleChanged', { | ||
id: id, | ||
field: field, | ||
value: value | ||
}) | ||
} | ||
</script> | ||
</div> | ||
<script> | ||
function saveToggleableInput(value, id, field) { | ||
document.getElementsByClassName('message')[0].style.display = "none"; | ||
window.livewire.emit('eventToggleChanged', { | ||
id: id, | ||
field: field, | ||
value: value | ||
}) | ||
} | ||
</script> |
Oops, something went wrong.