Skip to content

Commit

Permalink
fix: allow setting of icon names
Browse files Browse the repository at this point in the history
  • Loading branch information
phpsa committed Nov 29, 2023
1 parent f02f232 commit 7dd5e8a
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 19 deletions.
19 changes: 4 additions & 15 deletions resources/views/password.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,17 +142,10 @@ class="fi-fo-text-input"
>
@if ($isRevealable())
<button type="button" class="flex hidden inset-y-0 right-0 justify-self-end items-center p-1 text-gray-400 hover:text-gray-700 dark:hover:text-gray-200" @click="show = !show" :class="{'hidden': !show, 'block': show }">
<!-- Heroicon name: eye -->
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-5 h-5">
<path stroke-linecap="round" stroke-linejoin="round" d="M2.036 12.322a1.012 1.012 0 010-.639C3.423 7.51 7.36 4.5 12 4.5c4.638 0 8.573 3.007 9.963 7.178.07.207.07.431 0 .639C20.577 16.49 16.64 19.5 12 19.5c-4.638 0-8.573-3.007-9.963-7.178z" />
<path stroke-linecap="round" stroke-linejoin="round" d="M15 12a3 3 0 11-6 0 3 3 0 016 0z" />
</svg>
{{svg($getShowIcon(), "w-5 h-5")}}
</button>
<button type="button" class="flex hidden inset-y-0 right-0 items-center p-1 text-gray-400 hover:text-gray-700 dark:hover:text-gray-200" @click="show = !show" :class="{'block': !show, 'hidden': show }">
<!-- Heroicon name: eye-slash -->
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-5 h-5">
<path stroke-linecap="round" stroke-linejoin="round" d="M3.98 8.223A10.477 10.477 0 001.934 12C3.226 16.338 7.244 19.5 12 19.5c.993 0 1.953-.138 2.863-.395M6.228 6.228A10.45 10.45 0 0112 4.5c4.756 0 8.773 3.162 10.065 7.498a10.523 10.523 0 01-4.293 5.774M6.228 6.228L3 3m3.228 3.228l3.65 3.65m7.894 7.894L21 21m-3.228-3.228l-3.65-3.65m0 0a3 3 0 10-4.243-4.243m4.242 4.242L9.88 9.88" />
</svg>
{{svg($getHideIcon(), "w-5 h-5")}}
</button>
@endif
@if ($isGeneratable())
Expand All @@ -161,9 +154,7 @@ class="fi-fo-text-input"
x-on:click.prevent="generatePasswd()"
class="text-gray-400 hover:text-gray-700 dark:hover:text-gray-200 p-1"
>
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-5 h-5">
<path stroke-linecap="round" stroke-linejoin="round" d="M15.75 5.25a3 3 0 013 3m3 0a6 6 0 01-7.029 5.912c-.563-.097-1.159.026-1.563.43L10.5 17.25H8.25v2.25H6v2.25H2.25v-2.818c0-.597.237-1.17.659-1.591l6.499-6.499c.404-.404.527-1 .43-1.563A6 6 0 1121.75 8.25z" />
</svg>
{{svg($getGenerateIcon(), "w-5 h-5")}}

</button>
@endif
Expand All @@ -174,9 +165,7 @@ class="text-gray-400 hover:text-gray-700 dark:hover:text-gray-200 p-1"
x-on:click.prevent="copyPassword()"
class="text-gray-400 hover:text-gray-700 dark:hover:text-gray-200 p-1"
>
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-5 h-5">
<path stroke-linecap="round" stroke-linejoin="round" d="M15.75 17.25v3.375c0 .621-.504 1.125-1.125 1.125h-9.75a1.125 1.125 0 01-1.125-1.125V7.875c0-.621.504-1.125 1.125-1.125H6.75a9.06 9.06 0 011.5.124m7.5 10.376h3.375c.621 0 1.125-.504 1.125-1.125V11.25c0-4.46-3.243-8.161-7.5-8.876a9.06 9.06 0 00-1.5-.124H9.375c-.621 0-1.125.504-1.125 1.125v3.5m7.5 10.375H9.375a1.125 1.125 0 01-1.125-1.125v-9.25m12 6.625v-1.875a3.375 3.375 0 00-3.375-3.375h-1.5a1.125 1.125 0 01-1.125-1.125v-1.5a3.375 3.375 0 00-3.375-3.375H9.75" />
</svg>
{{svg($getCopyIcon(), "w-5 h-5")}}

</button>
@endif
Expand Down
2 changes: 1 addition & 1 deletion src/Password.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class Password extends TextInput

protected string $showIcon = 'heroicon-o-eye';

protected string $hideIcon = 'heroicon-o-eye-off';
protected string $hideIcon = 'heroicon-o-eye-slash';

protected bool|Closure $revealable = true;

Expand Down
5 changes: 3 additions & 2 deletions src/Traits/CanCopy.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

trait CanCopy
{
protected bool|Closure $copyable = false;
protected bool|Closure $copyable = true;

protected string $copyIcon = 'heroicon-o-clipboard';

Expand Down Expand Up @@ -57,7 +57,8 @@ public function getCopyText(): string
return $this->evaluate($this->copyText ?? __('Copied to clipboard'));
}

public function shouldNotifyOnCopy(): bool {
public function shouldNotifyOnCopy(): bool
{
return $this->evaluate($this->notifyOnCopy);
}
}
2 changes: 1 addition & 1 deletion src/Traits/CanGenerate.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ trait CanGenerate
{
protected string $generateIcon = 'heroicon-o-key';

protected bool|Closure $generatable = false;
protected bool|Closure $generatable = true;

protected int $passwordMinLen = 8;

Expand Down

0 comments on commit 7dd5e8a

Please sign in to comment.