Skip to content

Commit b142db8

Browse files
authored
Add BooleanFilter option for Bootstrap
1 parent d96df8e commit b142db8

File tree

1 file changed

+40
-24
lines changed

1 file changed

+40
-24
lines changed
Lines changed: 40 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,45 @@
11
@php
22
$defaultValue = ($filter->hasFilterDefaultValue() ? (bool) $filter->getFilterDefaultValue() : false)
33
@endphp
4-
<div class="flex flex-cols"
5-
x-data="newBooleanFilter('{{ $filter->getKey() }}', '{{ $tableName }}', '{{ $defaultValue }}')"
6-
>
7-
<x-livewire-tables::tools.filter-label :$filter :$filterLayout :$tableName :$isTailwind :$isBootstrap4 :$isBootstrap5 :$isBootstrap />
8-
<input id="thisId" type="checkbox" name="switch" class="hidden" :checked="value" />
4+
@if($isTailwind)
5+
<div class="flex flex-cols"
6+
x-data="newBooleanFilter('{{ $filter->getKey() }}', '{{ $tableName }}', '{{ $defaultValue }}')"
7+
>
8+
<x-livewire-tables::tools.filter-label :$filter :$filterLayout :$tableName :$isTailwind :$isBootstrap4 :$isBootstrap5 :$isBootstrap />
9+
<input id="thisId" type="checkbox" name="switch" class="hidden" :checked="value" />
910

10-
<button x-cloak {{ $filterInputAttributes->merge([
11-
":class" => "(value == 1 || value == true) ? '".$filterInputAttributes['activeColor']."' : '".$filterInputAttributes['inactiveColor']."'",
12-
])
13-
->class([
14-
'relative inline-flex h-6 py-0.5 ml-4 focus:outline-none rounded-full w-10' => ($filterInputAttributes['default-styling'] ?? true)
15-
])
16-
->except(['default-styling','default-colors','activeColor','inactiveColor','blobColor'])
17-
}}>
18-
<span :class="(value == 1 || value == true) ? 'translate-x-[18px]' : 'translate-x-0.5'" class="w-5 h-5 duration-200 ease-in-out rounded-full shadow-md {{ $filterInputAttributes['blobColor'] }}"></span>
19-
</button>
20-
<template x-if="(value == 1 || value == true)">
21-
<button @click="toggleStatusWithReset" type="button"
22-
class="flex-shrink-0 ml-1 h-6 w-6 rounded-full inline-flex items-center justify-center text-indigo-400 hover:bg-indigo-200 hover:text-indigo-500 focus:outline-none focus:bg-indigo-500 focus:text-white"
23-
>
24-
25-
<span class="sr-only">{{ __($localisationPath.'Remove filter option') }}</span>
26-
<x-heroicon-m-x-mark class="h-6 w-6" />
11+
<button x-cloak {{ $filterInputAttributes->merge([
12+
":class" => "(value == 1 || value == true) ? '".$filterInputAttributes['activeColor']."' : '".$filterInputAttributes['inactiveColor']."'",
13+
])
14+
->class([
15+
'relative inline-flex h-6 py-0.5 ml-4 focus:outline-none rounded-full w-10' => ($filterInputAttributes['default-styling'] ?? true)
16+
])
17+
->except(['default-styling','default-colors','activeColor','inactiveColor','blobColor'])
18+
}}>
19+
<span :class="(value == 1 || value == true) ? 'translate-x-[18px]' : 'translate-x-0.5'" class="w-5 h-5 duration-200 ease-in-out rounded-full shadow-md {{ $filterInputAttributes['blobColor'] }}"></span>
2720
</button>
28-
</template>
29-
</div>
21+
<template x-if="(value == 1 || value == true)">
22+
<button @click="toggleStatusWithReset" type="button"
23+
class="flex-shrink-0 ml-1 h-6 w-6 rounded-full inline-flex items-center justify-center text-indigo-400 hover:bg-indigo-200 hover:text-indigo-500 focus:outline-none focus:bg-indigo-500 focus:text-white"
24+
>
25+
26+
<span class="sr-only">{{ __($localisationPath.'Remove filter option') }}</span>
27+
<x-heroicon-m-x-mark class="h-6 w-6" />
28+
</button>
29+
</template>
30+
</div>
31+
@elseif($isBootstrap4)
32+
<div class="custom-control custom-switch"
33+
x-data="newBooleanFilter('{{ $filter->getKey() }}', '{{ $tableName }}', '{{ $defaultValue }}')"
34+
>
35+
<x-livewire-tables::tools.filter-label :$filter :$filterLayout :$tableName :$isTailwind :$isBootstrap4 :$isBootstrap5 :$isBootstrap />
36+
<input id="thisId" type="checkbox" name="switch" class="custom-control-input" role="switch" :checked="value" @click="toggleStatusWithUpdate" x-ref="switchButton"/>
37+
</div>
38+
@else
39+
<div class="form-check form-switch"
40+
x-data="newBooleanFilter('{{ $filter->getKey() }}', '{{ $tableName }}', '{{ $defaultValue }}')"
41+
>
42+
<x-livewire-tables::tools.filter-label :$filter :$filterLayout :$tableName :$isTailwind :$isBootstrap4 :$isBootstrap5 :$isBootstrap />
43+
<input id="thisId" type="checkbox" name="switch" class="form-check-input" role="switch" :checked="value" @click="toggleStatusWithUpdate" x-ref="switchButton"/>
44+
</div>
45+
@endif

0 commit comments

Comments
 (0)