Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix switch bg color #5736

Merged
merged 1 commit into from
Dec 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
fix switch bg color
  • Loading branch information
pxpm committed Dec 18, 2024
commit ca15c4e3fc5918f7d087db1d520bc01353d498f9
10 changes: 7 additions & 3 deletions src/resources/views/crud/fields/switch.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

<div class="d-inline-flex align-items-center">
{{-- Switch --}}
<label class="form-switch switch switch-sm switch-label switch-pill switch-{{ $field['color'] }} mb-0" style="--bg-color: {{ $field['color'] }};">
<label class="form-switch switch switch-sm switch-label switch-pill switch-{{ $field['color'] }} mb-0" style="--bg-switch-checked-color: {{ $field['color'] }};">
<input
type="hidden"
name="{{ $field['name'] }}"
Expand All @@ -23,7 +23,8 @@
type="checkbox"
data-init-function="bpFieldInitSwitch"
{{ (bool) $field['value'] ? 'checked' : '' }}
class="switch-input form-check-input" />
class="switch-input form-check-input"
/>
<span
class="switch-slider"
data-checked="{{ $field['onLabel'] ?? '' }}"
Expand Down Expand Up @@ -86,7 +87,10 @@ function bpFieldInitSwitch($element) {
@bassetBlock('backpack/crud/fields/switch-field.css')
<style>
.switch-input:checked+.switch-slider {
background-color: var(--bg-color);
background-color: var(--bg-switch-checked-color);
}
.form-switch .form-check-input:checked {
background-color: var(--bg-switch-checked-color);
}
</style>
@endBassetBlock
Expand Down
Loading