From 7b9222fcffc1f40da3b0e5f314a2ccc6f5b90254 Mon Sep 17 00:00:00 2001 From: Nikolay Gagarinov Date: Thu, 14 Mar 2024 21:54:28 +0500 Subject: [PATCH] use components for auth forms --- resources/lang/en/settings.php | 4 ++ resources/views/auth/login.blade.php | 27 +++------- .../views/auth/passwords/email.blade.php | 10 +--- .../views/auth/passwords/reset.blade.php | 27 ++-------- resources/views/auth/register.blade.php | 50 +++++-------------- .../components/bs/form/checkbox.blade.php | 4 ++ .../views/components/bs/form/email.blade.php | 7 +++ .../components/bs/form/password.blade.php | 7 +++ .../views/components/bs/form/submit.blade.php | 4 +- 9 files changed, 52 insertions(+), 88 deletions(-) create mode 100644 resources/views/components/bs/form/checkbox.blade.php create mode 100644 resources/views/components/bs/form/email.blade.php create mode 100644 resources/views/components/bs/form/password.blade.php diff --git a/resources/lang/en/settings.php b/resources/lang/en/settings.php index 215cb920..07ad38a2 100644 --- a/resources/lang/en/settings.php +++ b/resources/lang/en/settings.php @@ -6,4 +6,8 @@ 'github_name' => 'GitHub nickname', 'hexlet_nickname' => 'Hexlet nickname', ], + 'account' => [ + 'password' => 'Password', + 'reset_password' => 'Reset password', + ], ]; diff --git a/resources/views/auth/login.blade.php b/resources/views/auth/login.blade.php index 4c937105..72a26340 100644 --- a/resources/views/auth/login.blade.php +++ b/resources/views/auth/login.blade.php @@ -8,28 +8,17 @@
{{ html()->form()->route('login')->open() }} -
- {{ html()->label(__('login.email'))->for('email')->class('form-label') }} - {{ html()->email('email')->class(['form-control', 'is-invalid' => $errors->has('email')]) }} - @error('email') - {{ $errors->first('email') }} - @enderror -
-
- {{ html()->label(__('login.password'))->for('password')->class('form-label') }} - {{ html()->password('password')->class(['form-control', 'is-invalid' => $errors->has('password')]) }} - @error('password') - {{ $errors->first('password') }} - @enderror -
-
- {{ html()->checkbox('remember')->class('form-check-input') }} - {{ html()->label(__('login.remember_me'))->for('remember')->class('form-label') }} -
- {{ html()->submit(__('login.submit'))->class('btn btn-primary btn-block') }} + + + + + + + {{ __('login.register') }} {{ __('login.reset_password') }} {{ __('auth.with_github') }} + {{ html()->form()->close() }}
diff --git a/resources/views/auth/passwords/email.blade.php b/resources/views/auth/passwords/email.blade.php index 7f4d57d5..39d98add 100644 --- a/resources/views/auth/passwords/email.blade.php +++ b/resources/views/auth/passwords/email.blade.php @@ -19,14 +19,8 @@ @endif {{ html()->form()->action(route('password.email'))->open() }} -
- {{ html()->label(__(__('passwords.reset_password.email')))->for('email')->class('form-label') }} - {{ html()->email('email')->class(['form-control', 'is-invalid' => $errors->has('email')]) }} - @error('email') - {{ $errors->first('email') }} - @enderror -
- {{ html()->submit(__('passwords.reset_password.button_send_link'))->class('btn btn-primary btn-block') }} + + {{ html()->form()->close() }} diff --git a/resources/views/auth/passwords/reset.blade.php b/resources/views/auth/passwords/reset.blade.php index 4a109ce3..840b0eda 100644 --- a/resources/views/auth/passwords/reset.blade.php +++ b/resources/views/auth/passwords/reset.blade.php @@ -11,29 +11,10 @@ {{ html()->form()->action(route('password.update'))->open() }} {{ html()->hidden('token')->value($token )}} -
- {{ html()->label(__(__('passwords.reset_password.email')))->for('email')->class('form-label') }} - {{ html()->email('email')->class(['form-control', 'is-invalid' => $errors->has('email')]) }} - @error('email') - {{ $errors->first('email') }} - @enderror -
-
- {{ html()->label(__('passwords.reset_password.password'))->for('password')->class('form-label') }} - {{ html()->password('password')->class(['form-control', 'is-invalid' => $errors->has('password')]) }} @error('password') - {{ $errors->first('password') }} - @enderror -
-
- {{ html()->label(__('passwords.reset_password.confirm_password'))->for('password')->class('form-label') }} - {{ html()->password('password_confirmation')->class(['form-control', 'is-invalid' => $errors->has('password_confirmation')]) }} - @error('password_confirmation') - {{ $errors->first('password_confirmation') }} - @enderror -
-
- {{ html()->submit(__('passwords.reset_password.button'))->class('btn btn-primary btn-block') }} -
+ + + + {{ html()->form()->close() }} diff --git a/resources/views/auth/register.blade.php b/resources/views/auth/register.blade.php index 1a1036b4..a930412a 100644 --- a/resources/views/auth/register.blade.php +++ b/resources/views/auth/register.blade.php @@ -8,43 +8,19 @@ {{ __('register.title') }}
-
- {{ html()->form()->route('register')->open() }} - {{ html()->label(__('register.email'))->for('email')->class('form-label') }} - {{ html()->email('email')->class(['form-control', 'is-invalid' => $errors->has('email')]) }} - @error('email') - {{ $errors->first('email') }} - @enderror -
-
- {{ html()->label(__('register.name'))->for('email')->class('form-label') }} - {{ html()->text('name')->class(['form-control', 'is-invalid' => $errors->has('name')]) }} - @error('name') - {{ $errors->first('name') }} - @enderror -
-
- {{ html()->label(__('register.password'))->for('password')->class('form-label') }} - {{ html()->password('password')->class(['form-control', 'is-invalid' => $errors->has('password')]) }} - @error('password') - {{ $errors->first('password') }} - @enderror -
-
- {{ html()->label(__('register.password_confirmation'))->for('password')->class('form-label') }} - {{ html()->password('password_confirmation')->class(['form-control', 'is-invalid' => $errors->has('password_confirmation')]) }} - @error('password_confirmation') - {{ $errors->first('password_confirmation') }} - @enderror -
-
- {{ html()->submit(__('register.submit'))->class('btn btn-primary btn-block') }} -
- + {{ html()->form()->route('register')->open() }} + + + + + + + + {{ html()->form()->close() }}
diff --git a/resources/views/components/bs/form/checkbox.blade.php b/resources/views/components/bs/form/checkbox.blade.php new file mode 100644 index 00000000..75dbac9b --- /dev/null +++ b/resources/views/components/bs/form/checkbox.blade.php @@ -0,0 +1,4 @@ +
+ {{ html()->checkbox($name)->class('form-check-input') }} + {{ html()->label(__($label))->for($name)->class('form-label') }} +
diff --git a/resources/views/components/bs/form/email.blade.php b/resources/views/components/bs/form/email.blade.php new file mode 100644 index 00000000..99096f55 --- /dev/null +++ b/resources/views/components/bs/form/email.blade.php @@ -0,0 +1,7 @@ +
+ {{ html()->label(__($label))->for($name)->class('form-label') }} + {{ html()->email($name)->class(['form-control', 'is-invalid' => $errors->has($name)]) }} + @error($name) + {{ $errors->first($name) }} + @enderror +
diff --git a/resources/views/components/bs/form/password.blade.php b/resources/views/components/bs/form/password.blade.php new file mode 100644 index 00000000..6692874a --- /dev/null +++ b/resources/views/components/bs/form/password.blade.php @@ -0,0 +1,7 @@ +
+ {{ html()->label(__($label))->for($name)->class('form-label') }} + {{ html()->password($name)->class(['form-control', 'is-invalid' => $errors->has($name)]) }} + @error($name) + {{ $errors->first($name) }} + @enderror +
diff --git a/resources/views/components/bs/form/submit.blade.php b/resources/views/components/bs/form/submit.blade.php index 3f358d55..09989c54 100644 --- a/resources/views/components/bs/form/submit.blade.php +++ b/resources/views/components/bs/form/submit.blade.php @@ -1 +1,3 @@ -{{ html()->submit(__($text ?? 'layout.submit'))->class('btn btn-primary btn-block') }} +
+ {{ html()->submit(__($text ?? 'layout.submit'))->class('btn btn-primary btn-block') }} +