-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from thedevdojo/fortifyOut
Adding updates with fortify
- Loading branch information
Showing
24 changed files
with
573 additions
and
370 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
111 changes: 111 additions & 0 deletions
111
resources/views/components/elements/input-code.blade.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
@props([ | ||
// total number of boxes to display | ||
'digits' => 4, | ||
'eventCallback' => null | ||
]) | ||
|
||
<div x-data=" | ||
{ | ||
total_digits: @js($digits), | ||
eventCallback: @js($eventCallback), | ||
moveCursorNext (index, digits, evt) { | ||
if (!isNaN(parseInt(evt.key)) && parseInt(evt.key) >= 0 && parseInt(evt.key) <= 9 && index != digits) { | ||
evt.preventDefault(); | ||
evt.stopPropagation(); | ||
this.$refs['input' + index].value = evt.key; | ||
this.$refs['input' + (index+1)].focus(); | ||
} else { | ||
if (evt.key === 'Backspace') { | ||
evt.preventDefault(); | ||
evt.stopPropagation(); | ||
if (index > 1) { | ||
if (this.$refs['input' + index].value !== '') { | ||
this.$refs['input' + index].value = ''; | ||
} else { | ||
if (index > 1) { | ||
this.$refs['input' + (index-1)].value=''; | ||
this.$refs['input' + (index-1)].focus(); | ||
} | ||
} | ||
} else { | ||
this.$refs['input' + index].value = ''; | ||
} | ||
} else { | ||
} | ||
} | ||
let that = this; | ||
setTimeout(function(){ | ||
that.$refs.pin.value = that.generateCode(); | ||
if (index === digits && [...Array(digits).keys()].every(i => that.$refs['input' + (i + 1)].value !== '')) { | ||
that.submitCallback(); | ||
} | ||
}, 100); | ||
{{-- console.log(this.generateCode()); --}} | ||
}, | ||
submitCallback(){ | ||
if(this.eventCallback){ | ||
window.dispatchEvent(new CustomEvent(this.eventCallback, { detail: { code: this.generateCode() }})); | ||
} | ||
}, | ||
pasteValue(event){ | ||
event.preventDefault(); | ||
{{-- let paste = (event.clipboardData || window.clipboardData).getData('text'); --}} | ||
let paste = (event.clipboardData || window.clipboardData).getData('text'); | ||
for (let i = 0; i < paste.length; i++) { | ||
if (i < this.total_digits) { | ||
this.$refs['input' + (i + 1)].value = paste[i]; | ||
} | ||
let focusLastInput = (paste.length <= this.total_digits) ? paste.length : this.total_digits; | ||
this.$refs['input' + focusLastInput].focus(); | ||
if(paste.length >= this.total_digits){ | ||
let that = this; | ||
setTimeout(function(){ | ||
that.$refs.pin.value = that.generateCode(); | ||
that.submitCallback(); | ||
}, 100); | ||
} | ||
} | ||
}, | ||
generateCode() { | ||
let code = ''; | ||
for (let i = 1; i <= this.total_digits; i++) { | ||
code += this.$refs['input' + i].value; | ||
} | ||
return code; | ||
}, | ||
}" | ||
x-init=" | ||
$refs.input1.focus(); | ||
" | ||
class="relative" | ||
> | ||
<div class="flex"> | ||
<div class="flex mx-auto space-x-2"> | ||
@for ($x = 1; $x <= $digits; $x++) | ||
<input | ||
x-ref="input{{ $x }}" | ||
numeric="true" | ||
type="number" | ||
x-on:paste="pasteValue" | ||
x-on:keydown="moveCursorNext({{ $x }}, {{ $digits }}, event)" | ||
x-on:focus="$el.select()" | ||
class="w-12 h-12 font-light text-center text-black rounded-md border shadow-sm appearance-none auth-component-code-input dark:text-dark-400 border-zinc-200 focus:border-2" | ||
maxlength="1" | ||
/> | ||
@endfor | ||
</div> | ||
</div> | ||
<input {{ $attributes->whereStartsWith('id') }} type="hidden" x-ref="pin" name="pin" /> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<meta charset="utf-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
<meta name="csrf-token" content="{{ csrf_token() }}"> | ||
|
||
<title>{{ $title ?? 'Auth' }}</title> | ||
@if(config('devdojo.auth.settings.dev_mode')) | ||
@vite(['packages/devdojo/auth/resources/css/auth.css', 'packages/devdojo/auth/resources/css/auth.js']) | ||
@else | ||
<script src="/auth/build/assets/scripts.js"></script> | ||
<link rel="stylesheet" href="/auth/build/assets/styles.css" /> | ||
@endif | ||
|
||
@php | ||
$buttonRGBColor = \Devdojo\Auth\Helper::convertHexToRGBString(config('devdojo.auth.appearance.color.button')); | ||
$inputBorderRGBColor = \Devdojo\Auth\Helper::convertHexToRGBString(config('devdojo.auth.appearance.color.input_border')); | ||
@endphp | ||
<style> | ||
.auth-component-button:focus{ | ||
--tw-ring-opacity: 1; --tw-ring-color: rgb({{ $buttonRGBColor }} / var(--tw-ring-opacity)); | ||
} | ||
.auth-component-input{ | ||
color: {{ config('devdojo.auth.appearance.color.input_text') }} | ||
} | ||
.auth-component-input:focus, .auth-component-code-input:focus{ | ||
--tw-ring-color: rgb({{ $inputBorderRGBColor }} / var(--tw-ring-opacity)); | ||
border-color: rgb({{ $inputBorderRGBColor }} / var(--tw-border-opacity)); | ||
} | ||
.auth-component-input-label-focused{ | ||
color: {{ config('devdojo.auth.appearance.color.input_border') }} | ||
} | ||
</style> | ||
|
||
@if(file_exists(public_path('auth/app.css'))) | ||
<link rel="stylesheet" href="/auth/app.css" /> | ||
@endif | ||
|
||
<link href="{{ url(config('devdojo.auth.appearance.favicon.light')) }}" rel="icon" media="(prefers-color-scheme: light)" /> | ||
<link href="{{ url(config('devdojo.auth.appearance.favicon.dark')) }}" rel="icon" media="(prefers-color-scheme: dark)" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.