Skip to content

Commit

Permalink
Merge pull request #14 from mkocansey/main
Browse files Browse the repository at this point in the history
Replaced $css attribute with Laravel's $attributes->merge() to allow …
  • Loading branch information
mkocansey authored May 26, 2022
2 parents a0e286d + bad4923 commit 2da5129
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
9 changes: 4 additions & 5 deletions src/resources/views/components/button.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@
'has_spinner' => 'false', // will show a spinner
'show_spinner' => 'false', // will show a spinner
'can_submit' => 'false', // will make this <button type="submit">
'onclick' => '', // a function to call onclick on the button
'disabled' => 'false', // set to true to disable the button
'css' => '',
'color' => 'blue', // red, yellow, green, blue, purple, orange, cyan, black
'coloring' => [
'bg' => [
Expand Down Expand Up @@ -48,11 +46,12 @@
@php
$button_type = ($can_submit == 'false') ? 'button' : 'submit';
$spinner_css = ($show_spinner == 'true') ? '' : 'hidden';
$primary_color = ($type=='primary') ? $coloring['bg'][$color]. ' '. $coloring['focus'][$color]. ' '. $coloring['hover_active'][$color] : '';
$is_disabled = ($disabled == 'true') ? 'disabled' : '';
@endphp
<button
@if ($onclick !== '') onclick="{!! $onclick !!}" @endif
{{ $attributes->merge(['class' => "bw-button $size $type $name $primary_color $is_disabled"]) }}
@if ($disabled == 'true') disabled="true" @endif
type="{{$button_type}}"
class="bw-button {{$size}} {{$type}} {{$name}} {{$css}} @if($type=='primary'){{$coloring['bg'][$color]}} {{$coloring['focus'][$color]}} {{$coloring['hover_active'][$color]}}@endif @if ($disabled == 'true')disabled @endif">
type="{{$button_type}}">
<span>{{ $slot }}</span> @if ($has_spinner == 'true') <x-bladewind::spinner css="{{$spinner_css}}"></x-bladewind::spinner> @endif
</button>
4 changes: 3 additions & 1 deletion src/resources/views/components/input.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@
@php
$name = preg_replace('/[\s-]/', '_', $name);
$required_symbol = ($label == '' && $required == 'true') ? ' *' : '';
$is_required = ($required == 'true') ? 'required' : '';
$placeholder_color = ($label !== '') ? 'placeholder-transparent' : '';
@endphp
<div class="relative w-full @if($add_clearing == 'true') mb-2 @endif">
<input
class="bw-input w-full border border-slate-300/50 dark:text-white/80 dark:border-slate-700 dark:bg-slate-600 dark:focus:border-slate-900 peer @if($required == 'true') required @endif {{$name}} {{$css}} @if($label !== '')placeholder-transparent @endif"
{{ $attributes->merge(['class' => "bw-input w-full border border-slate-300/50 dark:text-white/80 dark:border-slate-700 dark:bg-slate-600 dark:focus:border-slate-900 peer $is_required $name $css $placeholder_color"]) }}
type="{{ $type }}"
id="{{ $name }}"
name="{{ $name }}"
Expand Down
8 changes: 6 additions & 2 deletions src/resources/views/components/textarea.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,14 @@
@php
$name = preg_replace('/[\s-]/', '_', $name);
$required_symbol = ($label == '' && $required == 'true') ? ' *' : '';
$is_required = ($required == 'true') ? 'required' : '';
$placeholder_color = ($label !== '') ? 'placeholder-transparent' : '';
@endphp
<div class="relative w-full @if($add_clearing == 'true') mb-2 @endif">
<textarea class="bw-input w-full border border-slate-300/50 dark:border-slate-700 dark:bg-gray-700/90 dark:focus:border-slate-900 peer @if($required == 'true') required @endif {{$name}} {{$css}} @if($label !== '')placeholder-transparent @endif"
id="{{ $name }}" name="{{ $name }}" placeholder="{{ ($label !== '') ? $label : $placeholder }}{{$required_symbol}}">{{ $selected_value }}</textarea>
<textarea {{ $attributes->merge(['class' => "bw-input w-full border border-slate-300/50 dark:border-slate-700 dark:bg-gray-700/90 dark:focus:border-slate-900 peer $is_required $name $css $placeholder_color"]) }}
id="{{ $name }}"
name="{{ $name }}"
placeholder="{{ ($label !== '') ? $label : $placeholder }}{{$required_symbol}}">{{ $selected_value }}</textarea>
@if($label !== '')
<label for="{{ $name }}" class="form-label bg-white text-blue-900/40 dark:bg-gray-700/90 dark:text-gray-400" onclick="dom_el('.{{$name}}').focus()">{{ $label }}
@if($required == 'true') <span class="text-red-400/80" style="zoom:90%"><svg xmlns="http://www.w3.org/2000/svg" class="h-3 w-3 inline-block -mt-1" viewBox="0 0 20 20" fill="currentColor">
Expand Down

0 comments on commit 2da5129

Please sign in to comment.