Skip to content

Commit 5488074

Browse files
committed
feat(editor): added working number input with range slider
1 parent fde4846 commit 5488074

3 files changed

Lines changed: 69 additions & 3 deletions

File tree

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?php
2+
3+
namespace App\View\Components\Editor;
4+
5+
use Illuminate\View\Component;
6+
7+
class InputRange extends Component
8+
{
9+
public $changeEvent;
10+
11+
public $defaultValue;
12+
13+
public $min;
14+
15+
public $max;
16+
17+
public $step;
18+
19+
/**
20+
* Create a new component instance.
21+
*
22+
* @return void
23+
*/
24+
public function __construct($changeEvent, $default, $min = 0, $max = 100, $step = 1)
25+
{
26+
$this->changeEvent = $changeEvent;
27+
$this->defaultValue = $default;
28+
$this->min = $min;
29+
$this->max = $max;
30+
$this->step = $step;
31+
}
32+
33+
/**
34+
* Get the view / contents that represent the component.
35+
*
36+
* @return \Illuminate\Contracts\View\View|\Closure|string
37+
*/
38+
public function render()
39+
{
40+
return view('components.editor.input-range');
41+
}
42+
}

resources/views/components/editor.blade.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
<div class="grid grid-cols-1 lg:grid-cols-3 gap-12"
33
@icon-changed.window="iconName = $event.detail"
44
@color-changed.window="color = $event.detail.replace('#', '')"
5+
@size-changed.window="size = $event.detail"
56
x-data="Editor()">
67

78
<div class="md:col-span-2 text-left p-10 rounded-lg" style="background: linear-gradient(145deg, #0f0f10, #171719, #171719, #171719);">
@@ -23,6 +24,7 @@
2324

2425
<x-editor.input-icon-select change-event="icon-changed" />
2526
<x-editor.input-color-select change-event="color-changed" default="#333" />
27+
<x-editor.input-range change-event="size-changed" default="50" />
2628
</div>
2729

2830
{{-- PIN WITH ICON --}}
@@ -46,7 +48,7 @@
4648
<h2 class="font-bold text-xl mb-4">Preview</h2>
4749

4850
<div class="bg-gray-200 p-12 rounded-lg">
49-
<img x-cloak :src="iconUrl()" :height="size+'px'" :width="size+'px'" alt="Preview" class="block mx-auto" />
51+
<img x-cloak :src="iconUrl()" alt="Preview" class="block mx-auto" />
5052
</div>
5153

5254
<div x-text="'Test: '+iconUrl()" class="text-white"></div>
@@ -57,13 +59,13 @@
5759
<script>
5860
function Editor() {
5961
return {
60-
size: 100,
62+
size: 50,
6163
iconName: 'fa-solid fa-map-location',
6264
color: '333',
6365
experience: 'icon',
6466
6567
iconUrl() {
66-
return '/api/v3/font-awesome/v6/icon?size=100&icon='+this.iconName+'&color='+this.color;
68+
return '/api/v3/font-awesome/v6/icon?size='+this.size+'&icon='+this.iconName+'&color='+this.color;
6769
}
6870
}
6971
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<div x-data="InputRange()" class="max-w-screen-xl mx-auto">
2+
3+
Text Input:<br />
4+
<input class="w-full border" type="input" x-model="value" />
5+
6+
Range Input:<br />
7+
<input class="w-full" type="range" x-model="value" min="{{ $min }}" max="{{ $max }}" step="{{ $step }}" />
8+
9+
</div>
10+
11+
<script>
12+
function InputRange() {
13+
return {
14+
value: {{ $defaultValue }},
15+
init() {
16+
this.$watch('value', value => {
17+
this.$dispatch('{{ $changeEvent }}', this.value);
18+
});
19+
}
20+
}
21+
}
22+
</script>

0 commit comments

Comments
 (0)