@props([ // unique name for identifying the toggle element // useful for checking the value of the toggle when form is submitted 'name' => 'bw-toggle', // label to display next to the toggle element 'label' => '', // the position of the label above. left or right 'label_position' => config('bladewind.toggle.label_position', 'left'), 'labelPosition' => config('bladewind.toggle.label_position', 'left'), // sets or unsets disabled on the toggle element 'disabled' => false, // sets or unsets checked on the toggle element 'checked' => false, // background color to display when toggle is active 'color' => 'primary', // should the label and toggle element be justified in their parent element? 'justified' => config('bladewind.toggle.justified', false), // how big should the toggle bar be. Options available are thin, thick, thicker 'bar' => config('bladewind.toggle.bar', 'thick'), // javascript function to run when toggle is clicked 'onclick' => 'javascript:void(0)', // css for label 'class' => '', // build size of the bar and circle 'bar_circle_size' => [ 'thin' => 'w-12 h-3 after:w-5 after:h-5', 'thick' => 'w-12 h-7 after:w-5 after:h-5', 'thicker' => 'w-[4.5rem] h-10 after:w-8 after:h-8', ], ]) @php // reset variables for Laravel 8 support if ($labelPosition !== $label_position) $label_position = $labelPosition; $name = preg_replace('/[\s-]/', '_', $name); $disabled = filter_var($disabled, FILTER_VALIDATE_BOOLEAN); $checked = filter_var($checked, FILTER_VALIDATE_BOOLEAN); $justified = filter_var($justified, FILTER_VALIDATE_BOOLEAN); $bar = (!in_array($bar, ['thin', 'thick', 'thicker'])) ? 'thick' : $bar; $colour = (!in_array($color, ['primary', 'red', 'yellow', 'green', 'blue', 'pink', 'cyan', 'gray', 'purple', 'orange', 'fuchsia', 'indigo', 'violet'])) ? 'primary' : $color; $bar_colour = "peer-checked:bg-$colour-600 after:border-$colour-100"; @endphp