Parcourir la source

feat: ✨ Added Input components

IceToast il y a 2 ans
Parent
commit
b2d73eeda0

+ 31 - 0
themes/default/views/components/input/checkbox.blade.php

@@ -0,0 +1,31 @@
+<?php
+/**
+ * @required string $name
+ * @required string $label
+ *
+ * @optional string $value
+ */
+?>
+
+<div class="form-group mb-3">
+    <div class="d-flex justify-content-between">
+        <div {{ $attributes->merge(['class' => 'form-check form-switch']) }}>
+            <input class="form-check-input" name="{{$name}}" value="1"
+                   @if(old($name,  $value ?? null) == 1) checked @endif
+                   type="checkbox"
+                   id="{{$name}}">
+            <label class="form-check-label" for="{{$name}}">{{$label}}</label>
+        </div>
+
+        @if(isset($tooltip) && !empty($tooltip))
+            <span><i data-bs-toggle="tooltip" data-bs-placement="top" title="{{$tooltip}}"
+                     class="fas fa-info-circle"></i></span>
+        @endif
+    </div>
+</div>
+
+@error($name)
+<div class="invalid-feedback">{{$message}}</div>
+@enderror
+
+

+ 45 - 0
themes/default/views/components/input/number.blade.php

@@ -0,0 +1,45 @@
+<?php
+/**
+ * @required string $name
+ * @required string $label
+ * @required string $min
+ * @required string $max
+ *
+ * @optional string $tooltip
+ * @optional string $step
+ * @optional string $prepend
+ */
+?>
+
+<div class="form-group mb-3">
+    <div class="d-flex justify-content-between">
+        <label for="{{$name}}">{{$label}}</label>
+        @if(isset($tooltip) && !empty($tooltip))
+            <span><i data-bs-toggle="tooltip" data-bs-placement="top" title="{{$tooltip}}"
+                     class="fas fa-info-circle"></i></span>
+        @endif
+    </div>
+
+    @if(isset($prepend))
+        <div class="input-group">
+            @endif
+            <input value="{{old($name,  $value)}}" id="{{$name}}"
+                   name="{{$name}}"
+                   type="number"
+                   min="{{$min}}"
+                   max="{{$max}}"
+                   @if(isset($step) && !empty($step))
+                   step="{{$step}}"
+                   @endif
+                   class="form-control @error($name)is-invalid @enderror">
+            @if(isset($prepend))
+                <span class="input-group-text">{{$prepend}}</span>
+            @endif
+            @if(isset($prepend))
+        </div>
+    @endif
+
+    @error($name)
+    <div class="invalid-feedback">{{$message}}</div>
+    @enderror
+</div>

+ 32 - 0
themes/default/views/components/input/select.blade.php

@@ -0,0 +1,32 @@
+<?php
+/**
+ * @required string $name
+ * @required string $label
+ *
+ * @optional bool $multiple
+ * @optional string $style
+ * @optional string $tooltip
+ */
+?>
+<div class="form-group mb-3">
+    <div class="d-flex justify-content-between">
+        <label for="{{$name}}">{{$label}}</label>
+        @if(isset($tooltip) && !empty($tooltip))
+            <span><i data-bs-toggle="tooltip" data-bs-placement="top" title="{{$tooltip}}" class="fas fa-info-circle"></i></span>
+        @endif
+    </div>
+
+    <select
+        class="form-control @if(isset($multiple) && $multiple) form-select-lg @endif  @error($name) is-invalid @enderror"
+        @if(isset($multiple) && $multiple)multiple @endif
+        @if(isset($style) && !empty($style))style="{{$style}}" @endif
+        name="{{$name}}@if(isset($multiple) && $multiple)[]@endif"
+        id="{{$name}}">
+
+        {{$slot}}
+    </select>
+
+    @error($name)
+        <div class="invalid-feedback">{{$message}}</div>
+    @enderror
+</div>

+ 37 - 0
themes/default/views/components/input/text.blade.php

@@ -0,0 +1,37 @@
+<?php
+/**
+ * @required string $name
+ * @required string $label
+ *
+ * @optional string $type
+ * @optional string $value
+ * @optional string $tooltip
+ */
+?>
+
+<div class="form-group mb-3">
+    <div class="d-flex justify-content-between">
+        <label for="{{$name}}">{{$label}}</label>
+        @if(isset($tooltip) && !empty($tooltip))
+            <span><i data-bs-toggle="tooltip" data-bs-placement="top" title="{{$tooltip}}"
+                     class="fas fa-info-circle"></i></span>
+        @endif
+    </div>
+
+    @if(isset($prepend))
+        <div class="input-group">
+            @endif
+            <input value="{{old($name,  $value ?? null)}}" id="{{$name}}"
+                   name="{{$name}}"
+                   type="{{$type ?? 'text'}}" class="form-control @error($name)is-invalid @enderror"/>
+            @if(isset($prepend))
+                <span class="input-group-text">{{$prepend}}</span>
+            @endif
+            @if(isset($prepend))
+        </div>
+    @endif
+
+    @error($name)
+    <div class="invalid-feedback">{{$message}}</div>
+    @enderror
+</div>

+ 26 - 0
themes/default/views/components/input/textarea.blade.php

@@ -0,0 +1,26 @@
+<?php
+/**
+ * @required string $name
+ * @required string $label
+ *
+ * @optional string $value
+ * @optional string $rows
+ * @optional string $tooltip
+ * @optional bool $ckeditor
+ */
+?>
+
+<div class="form-group mb-3">
+    <div class="d-flex justify-content-between">
+        <label for="{{$name}}">{{$label}}</label>
+        @if(isset($tooltip) && !empty($tooltip))
+            <span><i data-bs-toggle="tooltip" data-bs-placement="top" title="{{$tooltip}}" class="fas fa-info-circle"></i></span>
+        @endif
+    </div>
+
+    <textarea rows="{{$rows ?? 2}}" id="{{$name}}" name="{{$name}}" class="form-control @isset($ckeditor) ckeditor @endif @error($name)is-invalid @enderror">{{old($name,  $value ?? null)}}</textarea>
+
+    @error($name)
+        <div class="invalid-feedback">{{$message}}</div>
+    @enderror
+</div>