Skip to content

Commit

Permalink
Add rtl option for inputs container
Browse files Browse the repository at this point in the history
  • Loading branch information
sadegh19b committed Oct 8, 2024
1 parent f34dccc commit 19ac309
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
3 changes: 2 additions & 1 deletion resources/views/components/otp-input.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
$isAutofocused = $isAutofocused();
$inputType = $getType();
$autocomplete = $getAutocomplete();
$isRtl = $getInputsContainerDirection();
@endphp

<x-dynamic-component
Expand Down Expand Up @@ -80,7 +81,7 @@
e.preventDefault();
},
}">
<div class="flex justify-between gap-6 fi-otp-input-container">
<div class="flex justify-between gap-6 fi-otp-input-container" dir="{{ $isRtl ? 'rtl' : 'ltr' }}">

@foreach(range(1, $numberInput) as $column)

Expand Down
15 changes: 14 additions & 1 deletion src/Components/OtpInput.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ class OtpInput extends Field implements Contracts\CanBeLengthConstrained, Contra

protected int | \Closure | null $numberInput = 4;

protected bool | \Closure | null $isRtl = false;

protected string | \Closure | null $type = 'number';


public function numberInput(int | \Closure $number = 4):static
{
$this->numberInput = $number;
Expand All @@ -42,12 +42,14 @@ public function getNumberInput():int
public function password(): static
{
$this->type = 'password';

return $this;
}

public function text(): static
{
$this->type = 'text';

return $this;
}

Expand All @@ -56,4 +58,15 @@ public function getType(): string
return $this->evaluate($this->type);
}

public function rtl(bool|\Closure $condition = false): static
{
$this->isRtl = $condition;

return $this;
}

public function getInputsContainerDirection(): string
{
return $this->evaluate($this->isRtl);
}
}

0 comments on commit 19ac309

Please sign in to comment.