diff --git a/src/Console/InstallCommand.php b/src/Console/InstallCommand.php index 1e2295674..4fb1c98cb 100644 --- a/src/Console/InstallCommand.php +++ b/src/Console/InstallCommand.php @@ -14,8 +14,7 @@ class InstallCommand extends Command * * @var string */ - protected $signature = 'breeze:install - {--inertia : Indicates that the Inertia stack should be installed} + protected $signature = 'breeze:install {stack=blade : The development stack that should be installed} {--composer=global : Absolute path to the Composer binary which should be used to install packages}'; /** @@ -32,8 +31,12 @@ class InstallCommand extends Command */ public function handle() { - if ($this->option('inertia')) { - return $this->installInertiaStack(); + if ($this->argument('stack') === 'vue') { + return $this->installInertiaVueStack(); + } + + if ($this->argument('stack') === 'react') { + return $this->installInertiaReactStack(); } // NPM Packages... @@ -94,11 +97,11 @@ public function handle() } /** - * Install the Inertia Breeze stack. + * Install the Inertia Vue Breeze stack. * * @return void */ - protected function installInertiaStack() + protected function installInertiaVueStack() { // Install Inertia... $this->requireComposerPackages('inertiajs/inertia-laravel:^0.4.1', 'laravel/sanctum:^2.6', 'tightenco/ziggy:^1.0'); @@ -112,9 +115,9 @@ protected function installInertiaStack() '@tailwindcss/forms' => '^0.2.1', '@vue/compiler-sfc' => '^3.0.5', 'autoprefixer' => '^10.2.4', - 'postcss' => '^8.2.1', - 'postcss-import' => '^12.0.1', - 'tailwindcss' => '^2.0.3', + 'postcss' => '^8.2.13', + 'postcss-import' => '^14.0.1', + 'tailwindcss' => '^2.1.2', 'vue' => '^3.0.5', 'vue-loader' => '^16.1.2', ] + $packages; @@ -122,7 +125,7 @@ protected function installInertiaStack() // Controllers... (new Filesystem)->ensureDirectoryExists(app_path('Http/Controllers/Auth')); - (new Filesystem)->copyDirectory(__DIR__.'/../../stubs/inertia/app/Http/Controllers/Auth', app_path('Http/Controllers/Auth')); + (new Filesystem)->copyDirectory(__DIR__.'/../../stubs/inertia-common/app/Http/Controllers/Auth', app_path('Http/Controllers/Auth')); // Requests... (new Filesystem)->ensureDirectoryExists(app_path('Http/Requests/Auth')); @@ -131,26 +134,26 @@ protected function installInertiaStack() // Middleware... $this->installMiddlewareAfter('SubstituteBindings::class', '\App\Http\Middleware\HandleInertiaRequests::class'); - copy(__DIR__.'/../../stubs/inertia/app/Http/Middleware/HandleInertiaRequests.php', app_path('Http/Middleware/HandleInertiaRequests.php')); + copy(__DIR__.'/../../stubs/inertia-common/app/Http/Middleware/HandleInertiaRequests.php', app_path('Http/Middleware/HandleInertiaRequests.php')); // Views... - copy(__DIR__.'/../../stubs/inertia/resources/views/app.blade.php', resource_path('views/app.blade.php')); + copy(__DIR__.'/../../stubs/inertia-common/resources/views/app.blade.php', resource_path('views/app.blade.php')); // Components + Pages... (new Filesystem)->ensureDirectoryExists(resource_path('js/Components')); (new Filesystem)->ensureDirectoryExists(resource_path('js/Layouts')); (new Filesystem)->ensureDirectoryExists(resource_path('js/Pages')); - (new Filesystem)->copyDirectory(__DIR__.'/../../stubs/inertia/resources/js/Components', resource_path('js/Components')); - (new Filesystem)->copyDirectory(__DIR__.'/../../stubs/inertia/resources/js/Layouts', resource_path('js/Layouts')); - (new Filesystem)->copyDirectory(__DIR__.'/../../stubs/inertia/resources/js/Pages', resource_path('js/Pages')); + (new Filesystem)->copyDirectory(__DIR__.'/../../stubs/inertia-vue/resources/js/Components', resource_path('js/Components')); + (new Filesystem)->copyDirectory(__DIR__.'/../../stubs/inertia-vue/resources/js/Layouts', resource_path('js/Layouts')); + (new Filesystem)->copyDirectory(__DIR__.'/../../stubs/inertia-vue/resources/js/Pages', resource_path('js/Pages')); // Tests... (new Filesystem)->copyDirectory(__DIR__.'/../../stubs/default/tests/Feature', base_path('tests/Feature')); // Routes... - copy(__DIR__.'/../../stubs/inertia/routes/web.php', base_path('routes/web.php')); - copy(__DIR__.'/../../stubs/inertia/routes/auth.php', base_path('routes/auth.php')); + copy(__DIR__.'/../../stubs/inertia-common/routes/web.php', base_path('routes/web.php')); + copy(__DIR__.'/../../stubs/inertia-common/routes/auth.php', base_path('routes/auth.php')); // "Dashboard" Route... $this->replaceInFile('/home', '/dashboard', resource_path('js/Pages/Welcome.vue')); @@ -158,12 +161,91 @@ protected function installInertiaStack() $this->replaceInFile('/home', '/dashboard', app_path('Providers/RouteServiceProvider.php')); // Tailwind / Webpack... - copy(__DIR__.'/../../stubs/inertia/tailwind.config.js', base_path('tailwind.config.js')); - copy(__DIR__.'/../../stubs/inertia/webpack.mix.js', base_path('webpack.mix.js')); - copy(__DIR__.'/../../stubs/inertia/webpack.config.js', base_path('webpack.config.js')); - copy(__DIR__.'/../../stubs/inertia/jsconfig.json', base_path('jsconfig.json')); - copy(__DIR__.'/../../stubs/inertia/resources/css/app.css', resource_path('css/app.css')); - copy(__DIR__.'/../../stubs/inertia/resources/js/app.js', resource_path('js/app.js')); + copy(__DIR__.'/../../stubs/inertia-common/tailwind.config.js', base_path('tailwind.config.js')); + copy(__DIR__.'/../../stubs/inertia-common/webpack.mix.js', base_path('webpack.mix.js')); + copy(__DIR__.'/../../stubs/inertia-common/webpack.config.js', base_path('webpack.config.js')); + copy(__DIR__.'/../../stubs/inertia-common/jsconfig.json', base_path('jsconfig.json')); + copy(__DIR__.'/../../stubs/inertia-common/resources/css/app.css', resource_path('css/app.css')); + copy(__DIR__.'/../../stubs/inertia-vue/resources/js/app.js', resource_path('js/app.js')); + + $this->info('Breeze scaffolding installed successfully.'); + $this->comment('Please execute the "npm install && npm run dev" command to build your assets.'); + } + + /** + * Install the Inertia React Breeze stack. + * + * @return void + */ + protected function installInertiaReactStack() + { + // Install Inertia... + $this->requireComposerPackages('inertiajs/inertia-laravel:^0.3.5', 'laravel/sanctum:^2.6', 'tightenco/ziggy:^1.0'); + + // NPM Packages... + $this->updateNodePackages(function ($packages) { + return [ + '@headlessui/react' => '^1.2.0', + '@inertiajs/inertia' => '^0.8.4', + '@inertiajs/inertia-react' => '^0.5.12', + '@inertiajs/progress' => '^0.2.4', + '@tailwindcss/forms' => '^0.3.2', + 'autoprefixer' => '^10.2.4', + 'postcss' => '^8.2.13', + 'postcss-import' => '^14.0.1', + 'tailwindcss' => '^2.1.2', + 'react' => '^17.0.2', + 'react-dom' => '^17.0.2', + '@babel/preset-react' => '^7.13.13', + ] + $packages; + }); + + // Controllers... + (new Filesystem)->ensureDirectoryExists(app_path('Http/Controllers/Auth')); + (new Filesystem)->copyDirectory(__DIR__.'/../../stubs/inertia-common/app/Http/Controllers/Auth', app_path('Http/Controllers/Auth')); + + // Requests... + (new Filesystem)->ensureDirectoryExists(app_path('Http/Requests/Auth')); + (new Filesystem)->copyDirectory(__DIR__.'/../../stubs/default/App/Http/Requests/Auth', app_path('Http/Requests/Auth')); + + // Middleware... + $this->installMiddlewareAfter('SubstituteBindings::class', '\App\Http\Middleware\HandleInertiaRequests::class'); + + copy(__DIR__.'/../../stubs/inertia-common/app/Http/Middleware/HandleInertiaRequests.php', app_path('Http/Middleware/HandleInertiaRequests.php')); + + // Views... + copy(__DIR__.'/../../stubs/inertia-common/resources/views/app.blade.php', resource_path('views/app.blade.php')); + + // Components + Pages... + (new Filesystem)->ensureDirectoryExists(resource_path('js/Components')); + (new Filesystem)->ensureDirectoryExists(resource_path('js/Layouts')); + (new Filesystem)->ensureDirectoryExists(resource_path('js/Pages')); + + (new Filesystem)->copyDirectory(__DIR__.'/../../stubs/inertia-react/resources/js/Components', resource_path('js/Components')); + (new Filesystem)->copyDirectory(__DIR__.'/../../stubs/inertia-react/resources/js/Layouts', resource_path('js/Layouts')); + (new Filesystem)->copyDirectory(__DIR__.'/../../stubs/inertia-react/resources/js/Pages', resource_path('js/Pages')); + + // Tests... + (new Filesystem)->copyDirectory(__DIR__.'/../../stubs/default/tests/Feature', base_path('tests/Feature')); + + // Routes... + copy(__DIR__.'/../../stubs/inertia-common/routes/web.php', base_path('routes/web.php')); + copy(__DIR__.'/../../stubs/inertia-common/routes/auth.php', base_path('routes/auth.php')); + + // "Dashboard" Route... + $this->replaceInFile('/home', '/dashboard', resource_path('js/Pages/Welcome.js')); + $this->replaceInFile('Home', 'Dashboard', resource_path('js/Pages/Welcome.js')); + $this->replaceInFile('/home', '/dashboard', app_path('Providers/RouteServiceProvider.php')); + + // Tailwind / Webpack... + copy(__DIR__.'/../../stubs/inertia-common/tailwind.config.js', base_path('tailwind.config.js')); + copy(__DIR__.'/../../stubs/inertia-common/webpack.mix.js', base_path('webpack.mix.js')); + copy(__DIR__.'/../../stubs/inertia-common/webpack.config.js', base_path('webpack.config.js')); + copy(__DIR__.'/../../stubs/inertia-common/jsconfig.json', base_path('jsconfig.json')); + copy(__DIR__.'/../../stubs/inertia-common/resources/css/app.css', resource_path('css/app.css')); + copy(__DIR__.'/../../stubs/inertia-react/resources/js/app.js', resource_path('js/app.js')); + + $this->replaceInFile('.vue()', '.react()', base_path('webpack.mix.js')); $this->info('Breeze scaffolding installed successfully.'); $this->comment('Please execute the "npm install && npm run dev" command to build your assets.'); diff --git a/stubs/default/resources/views/auth/verify-email.blade.php b/stubs/default/resources/views/auth/verify-email.blade.php index fed7184ee..dc0ae7f40 100644 --- a/stubs/default/resources/views/auth/verify-email.blade.php +++ b/stubs/default/resources/views/auth/verify-email.blade.php @@ -31,7 +31,7 @@ @csrf diff --git a/stubs/default/resources/views/layouts/navigation.blade.php b/stubs/default/resources/views/layouts/navigation.blade.php index 32240e06b..c083d6036 100644 --- a/stubs/default/resources/views/layouts/navigation.blade.php +++ b/stubs/default/resources/views/layouts/navigation.blade.php @@ -41,7 +41,7 @@ - {{ __('Log out') }} + {{ __('Log Out') }} @@ -91,7 +91,7 @@ - {{ __('Log out') }} + {{ __('Log Out') }} diff --git a/stubs/inertia/app/Http/Controllers/Auth/AuthenticatedSessionController.php b/stubs/inertia-common/app/Http/Controllers/Auth/AuthenticatedSessionController.php similarity index 100% rename from stubs/inertia/app/Http/Controllers/Auth/AuthenticatedSessionController.php rename to stubs/inertia-common/app/Http/Controllers/Auth/AuthenticatedSessionController.php diff --git a/stubs/inertia/app/Http/Controllers/Auth/ConfirmablePasswordController.php b/stubs/inertia-common/app/Http/Controllers/Auth/ConfirmablePasswordController.php similarity index 100% rename from stubs/inertia/app/Http/Controllers/Auth/ConfirmablePasswordController.php rename to stubs/inertia-common/app/Http/Controllers/Auth/ConfirmablePasswordController.php diff --git a/stubs/inertia/app/Http/Controllers/Auth/EmailVerificationNotificationController.php b/stubs/inertia-common/app/Http/Controllers/Auth/EmailVerificationNotificationController.php similarity index 100% rename from stubs/inertia/app/Http/Controllers/Auth/EmailVerificationNotificationController.php rename to stubs/inertia-common/app/Http/Controllers/Auth/EmailVerificationNotificationController.php diff --git a/stubs/inertia/app/Http/Controllers/Auth/EmailVerificationPromptController.php b/stubs/inertia-common/app/Http/Controllers/Auth/EmailVerificationPromptController.php similarity index 100% rename from stubs/inertia/app/Http/Controllers/Auth/EmailVerificationPromptController.php rename to stubs/inertia-common/app/Http/Controllers/Auth/EmailVerificationPromptController.php diff --git a/stubs/inertia/app/Http/Controllers/Auth/NewPasswordController.php b/stubs/inertia-common/app/Http/Controllers/Auth/NewPasswordController.php similarity index 100% rename from stubs/inertia/app/Http/Controllers/Auth/NewPasswordController.php rename to stubs/inertia-common/app/Http/Controllers/Auth/NewPasswordController.php diff --git a/stubs/inertia/app/Http/Controllers/Auth/PasswordResetLinkController.php b/stubs/inertia-common/app/Http/Controllers/Auth/PasswordResetLinkController.php similarity index 100% rename from stubs/inertia/app/Http/Controllers/Auth/PasswordResetLinkController.php rename to stubs/inertia-common/app/Http/Controllers/Auth/PasswordResetLinkController.php diff --git a/stubs/inertia/app/Http/Controllers/Auth/RegisteredUserController.php b/stubs/inertia-common/app/Http/Controllers/Auth/RegisteredUserController.php similarity index 100% rename from stubs/inertia/app/Http/Controllers/Auth/RegisteredUserController.php rename to stubs/inertia-common/app/Http/Controllers/Auth/RegisteredUserController.php diff --git a/stubs/inertia/app/Http/Controllers/Auth/VerifyEmailController.php b/stubs/inertia-common/app/Http/Controllers/Auth/VerifyEmailController.php similarity index 100% rename from stubs/inertia/app/Http/Controllers/Auth/VerifyEmailController.php rename to stubs/inertia-common/app/Http/Controllers/Auth/VerifyEmailController.php diff --git a/stubs/inertia/app/Http/Middleware/HandleInertiaRequests.php b/stubs/inertia-common/app/Http/Middleware/HandleInertiaRequests.php similarity index 100% rename from stubs/inertia/app/Http/Middleware/HandleInertiaRequests.php rename to stubs/inertia-common/app/Http/Middleware/HandleInertiaRequests.php diff --git a/stubs/inertia/jsconfig.json b/stubs/inertia-common/jsconfig.json similarity index 100% rename from stubs/inertia/jsconfig.json rename to stubs/inertia-common/jsconfig.json diff --git a/stubs/inertia/resources/css/app.css b/stubs/inertia-common/resources/css/app.css similarity index 100% rename from stubs/inertia/resources/css/app.css rename to stubs/inertia-common/resources/css/app.css diff --git a/stubs/inertia/resources/views/app.blade.php b/stubs/inertia-common/resources/views/app.blade.php similarity index 100% rename from stubs/inertia/resources/views/app.blade.php rename to stubs/inertia-common/resources/views/app.blade.php diff --git a/stubs/inertia/routes/auth.php b/stubs/inertia-common/routes/auth.php similarity index 100% rename from stubs/inertia/routes/auth.php rename to stubs/inertia-common/routes/auth.php diff --git a/stubs/inertia/routes/web.php b/stubs/inertia-common/routes/web.php similarity index 100% rename from stubs/inertia/routes/web.php rename to stubs/inertia-common/routes/web.php diff --git a/stubs/inertia/tailwind.config.js b/stubs/inertia-common/tailwind.config.js similarity index 100% rename from stubs/inertia/tailwind.config.js rename to stubs/inertia-common/tailwind.config.js diff --git a/stubs/inertia/webpack.config.js b/stubs/inertia-common/webpack.config.js similarity index 100% rename from stubs/inertia/webpack.config.js rename to stubs/inertia-common/webpack.config.js diff --git a/stubs/inertia/webpack.mix.js b/stubs/inertia-common/webpack.mix.js similarity index 100% rename from stubs/inertia/webpack.mix.js rename to stubs/inertia-common/webpack.mix.js diff --git a/stubs/inertia-react/resources/js/Components/ApplicationLogo.js b/stubs/inertia-react/resources/js/Components/ApplicationLogo.js new file mode 100644 index 000000000..57bc22233 --- /dev/null +++ b/stubs/inertia-react/resources/js/Components/ApplicationLogo.js @@ -0,0 +1,9 @@ +import React from 'react'; + +export default function ApplicationLogo({ className }) { + return ( + + + + ); +} diff --git a/stubs/inertia-react/resources/js/Components/Button.js b/stubs/inertia-react/resources/js/Components/Button.js new file mode 100644 index 000000000..7675e994c --- /dev/null +++ b/stubs/inertia-react/resources/js/Components/Button.js @@ -0,0 +1,17 @@ +import React from 'react'; + +export default function Button({ type = 'submit', className = '', processing, children }) { + return ( + + ); +} diff --git a/stubs/inertia-react/resources/js/Components/Checkbox.js b/stubs/inertia-react/resources/js/Components/Checkbox.js new file mode 100644 index 000000000..2f6a52876 --- /dev/null +++ b/stubs/inertia-react/resources/js/Components/Checkbox.js @@ -0,0 +1,13 @@ +import React from 'react'; + +export default function Checkbox({ name, value, handleChange }) { + return ( + handleChange(e)} + /> + ); +} diff --git a/stubs/inertia-react/resources/js/Components/Dropdown.js b/stubs/inertia-react/resources/js/Components/Dropdown.js new file mode 100644 index 000000000..e1c24c184 --- /dev/null +++ b/stubs/inertia-react/resources/js/Components/Dropdown.js @@ -0,0 +1,93 @@ +import React, { useState, useContext } from 'react'; +import { InertiaLink } from '@inertiajs/inertia-react'; +import { Transition } from '@headlessui/react'; + +const DropDownContext = React.createContext(); + +const Dropdown = ({ children }) => { + const [open, setOpen] = useState(false); + + const toggleOpen = () => { + setOpen((previousState) => !previousState); + }; + + return ( + +
{children}
+
+ ); +}; + +const Trigger = ({ children }) => { + const { open, setOpen, toggleOpen } = useContext(DropDownContext); + + return ( + <> +
{children}
+ + {open &&
setOpen(false)}>
} + + ); +}; + +const Content = ({ align = 'right', width = '48', contentClasses = 'py-1 bg-white', children }) => { + const { open, setOpen } = useContext(DropDownContext); + + let alignmentClasses = 'origin-top'; + + if (align === 'left') { + alignmentClasses = 'origin-top-left left-0'; + } else if (align === 'right') { + alignmentClasses = 'origin-top-right right-0'; + } + + let widthClasses = ''; + + if (width === '48') { + widthClasses = 'w-48'; + } + + return ( + <> + + {open && ( +
setOpen(false)} + > +
+ {children} +
+
+ )} +
+ + ); +}; + +const Link = ({ href, method = 'post', as = 'a', children }) => { + return ( + + {children} + + ); +}; + +Dropdown.Trigger = Trigger; +Dropdown.Content = Content; +Dropdown.Link = Link; + +export default Dropdown; diff --git a/stubs/inertia-react/resources/js/Components/Label.js b/stubs/inertia-react/resources/js/Components/Label.js new file mode 100644 index 000000000..b55fbb3bc --- /dev/null +++ b/stubs/inertia-react/resources/js/Components/Label.js @@ -0,0 +1,9 @@ +import React from 'react'; + +export default function Label({ forInput, value, className, children }) { + return ( + + ); +} diff --git a/stubs/inertia-react/resources/js/Components/NavLink.js b/stubs/inertia-react/resources/js/Components/NavLink.js new file mode 100644 index 000000000..8fea52514 --- /dev/null +++ b/stubs/inertia-react/resources/js/Components/NavLink.js @@ -0,0 +1,17 @@ +import { InertiaLink } from '@inertiajs/inertia-react'; +import React from 'react'; + +export default function NavLink({ href, active, children }) { + return ( + + {children} + + ); +} diff --git a/stubs/inertia-react/resources/js/Components/ResponsiveNavLink.js b/stubs/inertia-react/resources/js/Components/ResponsiveNavLink.js new file mode 100644 index 000000000..cd9e3b5ad --- /dev/null +++ b/stubs/inertia-react/resources/js/Components/ResponsiveNavLink.js @@ -0,0 +1,19 @@ +import { InertiaLink } from '@inertiajs/inertia-react'; +import React from 'react'; + +export default function ResponsiveNavLink({ method = 'get', as = 'a', href, active = false, children }) { + return ( + + {children} + + ); +} diff --git a/stubs/inertia-react/resources/js/Components/TextInput.js b/stubs/inertia-react/resources/js/Components/TextInput.js new file mode 100644 index 000000000..42c6f18f1 --- /dev/null +++ b/stubs/inertia-react/resources/js/Components/TextInput.js @@ -0,0 +1,39 @@ +import React, { useEffect, useRef } from 'react'; + +export default function TextInput({ + label, + type = 'text', + name, + value, + className, + autoComplete, + required, + isFocused, + handleChange, +}) { + const input = useRef(); + + useEffect(() => { + if (isFocused) { + input.current.focus(); + } + }, []); + + return ( +
+ handleChange(e)} + /> +
+ ); +} diff --git a/stubs/inertia-react/resources/js/Components/ValidationErrors.js b/stubs/inertia-react/resources/js/Components/ValidationErrors.js new file mode 100644 index 000000000..7153aaa43 --- /dev/null +++ b/stubs/inertia-react/resources/js/Components/ValidationErrors.js @@ -0,0 +1,17 @@ +import React from 'react'; + +export default function ValidationErrors({ errors }) { + return ( + Object.keys(errors).length > 0 && ( +
+
Whoops! Something went wrong.
+ + +
+ ) + ); +} diff --git a/stubs/inertia-react/resources/js/Layouts/Authenticated.js b/stubs/inertia-react/resources/js/Layouts/Authenticated.js new file mode 100644 index 000000000..6fd3b66b7 --- /dev/null +++ b/stubs/inertia-react/resources/js/Layouts/Authenticated.js @@ -0,0 +1,128 @@ +import ApplicationLogo from '../Components/ApplicationLogo'; +import Dropdown from '../Components/Dropdown'; +import NavLink from '../Components/NavLink'; +import React, { useEffect, useState } from 'react'; +import ResponsiveNavLink from '../Components/ResponsiveNavLink'; +import { InertiaLink } from '@inertiajs/inertia-react'; + +export default function Authenticated({ auth, header, children }) { + const [showingNavigationDropdown, setShowingNavigationDropdown] = useState(false); + + return ( +
+ + + {header && ( +
+
{header}
+
+ )} + +
{children}
+
+ ); +} diff --git a/stubs/inertia-react/resources/js/Layouts/Guest.js b/stubs/inertia-react/resources/js/Layouts/Guest.js new file mode 100644 index 000000000..bad7e897e --- /dev/null +++ b/stubs/inertia-react/resources/js/Layouts/Guest.js @@ -0,0 +1,19 @@ +import ApplicationLogo from '../Components/ApplicationLogo'; +import React, { useEffect } from 'react'; +import { InertiaLink } from '@inertiajs/inertia-react'; + +export default function Guest({ children }) { + return ( +
+
+ + + +
+ +
+ {children} +
+
+ ); +} diff --git a/stubs/inertia-react/resources/js/Pages/Auth/ConfirmPassword.js b/stubs/inertia-react/resources/js/Pages/Auth/ConfirmPassword.js new file mode 100644 index 000000000..9d28afd51 --- /dev/null +++ b/stubs/inertia-react/resources/js/Pages/Auth/ConfirmPassword.js @@ -0,0 +1,60 @@ +import Button from '@/Components/Button'; +import Guest from '@/Layouts/Guest'; +import Label from '@/Components/Label'; +import React, { useEffect } from 'react'; +import TextInput from '@/Components/TextInput'; +import ValidationErrors from '@/Components/ValidationErrors'; +import { useForm } from '@inertiajs/inertia-react'; + +export default function ConfirmPassword() { + const { data, setData, post, processing, errors, reset } = useForm({ + password: '', + }); + + useEffect(() => { + return () => { + reset('password'); + }; + }, []); + + const onHandleChange = (event) => { + setData(event.target.name, event.target.value); + }; + + const submit = (e) => { + e.preventDefault(); + + post(route('password.confirm')); + }; + + return ( + +
+ This is a secure area of the application. Please confirm your password before continuing. +
+ + + +
+
+
+ +
+ +
+
+
+ ); +} diff --git a/stubs/inertia-react/resources/js/Pages/Auth/ForgotPassword.js b/stubs/inertia-react/resources/js/Pages/Auth/ForgotPassword.js new file mode 100644 index 000000000..9e4687a38 --- /dev/null +++ b/stubs/inertia-react/resources/js/Pages/Auth/ForgotPassword.js @@ -0,0 +1,53 @@ +import Button from '@/Components/Button'; +import Guest from '@/Layouts/Guest'; +import Label from '@/Components/Label'; +import React from 'react'; +import TextInput from '@/Components/TextInput'; +import ValidationErrors from '@/Components/ValidationErrors'; +import { useForm } from '@inertiajs/inertia-react'; + +export default function ForgotPassword({ status }) { + const { data, setData, post, processing, errors } = useForm({ + email: '', + }); + + const onHandleChange = (event) => { + setData(event.target.name, event.target.value); + }; + + const submit = (e) => { + e.preventDefault(); + + post(route('password.email')); + }; + + return ( + +
+ Forgot your password? No problem. Just let us know your email address and we will email you a password + reset link that will allow you to choose a new one. +
+ + {status &&
{status}
} + + + +
+ + +
+ +
+ +
+ ); +} diff --git a/stubs/inertia-react/resources/js/Pages/Auth/Login.js b/stubs/inertia-react/resources/js/Pages/Auth/Login.js new file mode 100644 index 000000000..febe6a771 --- /dev/null +++ b/stubs/inertia-react/resources/js/Pages/Auth/Login.js @@ -0,0 +1,93 @@ +import Button from '@/Components/Button'; +import Checkbox from '@/Components/Checkbox'; +import Guest from '@/Layouts/Guest'; +import Label from '@/Components/Label'; +import React, { useEffect } from 'react'; +import TextInput from '@/Components/TextInput'; +import ValidationErrors from '@/Components/ValidationErrors'; +import { InertiaLink } from '@inertiajs/inertia-react'; +import { useForm } from '@inertiajs/inertia-react'; + +export default function Login({ status, canResetPassword }) { + const { data, setData, post, processing, errors, reset } = useForm({ + email: '', + password: '', + remember: '', + }); + + useEffect(() => { + return () => { + reset('password'); + }; + }, []); + + const onHandleChange = (event) => { + setData(event.target.name, event.target.type === 'checkbox' ? event.target.checked : event.target.value); + }; + + const submit = (e) => { + e.preventDefault(); + + post(route('login')); + }; + + return ( + + {status &&
{status}
} + + + +
+
+
+ +
+
+ +
+ +
+ +
+ {canResetPassword && ( + + Forgot your password? + + )} + + +
+
+
+ ); +} diff --git a/stubs/inertia-react/resources/js/Pages/Auth/Register.js b/stubs/inertia-react/resources/js/Pages/Auth/Register.js new file mode 100644 index 000000000..1e8afe2f9 --- /dev/null +++ b/stubs/inertia-react/resources/js/Pages/Auth/Register.js @@ -0,0 +1,107 @@ +import Button from '@/Components/Button'; +import Guest from '@/Layouts/Guest'; +import React, { useEffect } from 'react'; +import Label from '@/Components/Label'; +import TextInput from '@/Components/TextInput'; +import ValidationErrors from '@/Components/ValidationErrors'; +import { InertiaLink } from '@inertiajs/inertia-react'; +import { useForm } from '@inertiajs/inertia-react'; + +export default function Register() { + const { data, setData, post, processing, errors, reset } = useForm({ + name: '', + email: '', + password: '', + password_confirmation: '', + }); + + useEffect(() => { + return () => { + reset('password', 'password_confirmation'); + }; + }, []); + + const onHandleChange = (event) => { + setData(event.target.name, event.target.type === 'checkbox' ? event.target.checked : event.target.value); + }; + + const submit = (e) => { + e.preventDefault(); + + post(route('register')); + }; + + return ( + + + +
+
+
+ +
+
+ +
+
+ +
+
+ +
+ + Already registered? + + + +
+
+
+ ); +} diff --git a/stubs/inertia-react/resources/js/Pages/Auth/ResetPassword.js b/stubs/inertia-react/resources/js/Pages/Auth/ResetPassword.js new file mode 100644 index 000000000..7ce7245e8 --- /dev/null +++ b/stubs/inertia-react/resources/js/Pages/Auth/ResetPassword.js @@ -0,0 +1,86 @@ +import Button from '@/Components/Button'; +import Guest from '@/Layouts/Guest'; +import Label from '@/Components/Label'; +import React, { useEffect } from 'react'; +import TextInput from '@/Components/TextInput'; +import ValidationErrors from '@/Components/ValidationErrors'; +import { useForm } from '@inertiajs/inertia-react'; + +export default function ResetPassword({ token, email }) { + const { data, setData, post, processing, errors, reset } = useForm({ + token: token, + email: email, + password: '', + password_confirmation: '', + }); + + useEffect(() => { + return () => { + reset('password', 'password_confirmation'); + }; + }, []); + + const onHandleChange = (event) => { + setData(event.target.name, event.target.value); + }; + + const submit = (e) => { + e.preventDefault(); + + post(route('password.update')); + }; + + return ( + + + +
+
+
+ +
+
+ +
+
+ +
+ +
+
+
+ ); +} diff --git a/stubs/inertia-react/resources/js/Pages/Auth/VerifyEmail.js b/stubs/inertia-react/resources/js/Pages/Auth/VerifyEmail.js new file mode 100644 index 000000000..600088d38 --- /dev/null +++ b/stubs/inertia-react/resources/js/Pages/Auth/VerifyEmail.js @@ -0,0 +1,45 @@ +import Button from '@/Components/Button'; +import Guest from '@/Layouts/Guest'; +import React from 'react'; +import { InertiaLink } from '@inertiajs/inertia-react'; +import { useForm } from '@inertiajs/inertia-react'; + +export default function VerifyEmail({ status }) { + const { post, processing } = useForm(); + + const submit = (e) => { + e.preventDefault(); + + post(route('verification.send')); + }; + + return ( + +
+ Thanks for signing up! Before getting started, could you verify your email address by clicking on the + link we just emailed to you? If you didn't receive the email, we will gladly send you another. +
+ + {status === 'verification-link-sent' && ( +
+ A new verification link has been sent to the email address you provided during registration. +
+ )} + +
+
+ + + + Log Out + +
+
+
+ ); +} diff --git a/stubs/inertia-react/resources/js/Pages/Dashboard.js b/stubs/inertia-react/resources/js/Pages/Dashboard.js new file mode 100644 index 000000000..99c875f03 --- /dev/null +++ b/stubs/inertia-react/resources/js/Pages/Dashboard.js @@ -0,0 +1,20 @@ +import Authenticated from '@/Layouts/Authenticated'; +import React from 'react'; + +export default function Dashboard(props) { + return ( + Dashboard} + > +
+
+
+
You're logged in!
+
+
+
+
+ ); +} diff --git a/stubs/inertia-react/resources/js/Pages/Welcome.js b/stubs/inertia-react/resources/js/Pages/Welcome.js new file mode 100644 index 000000000..50f63e068 --- /dev/null +++ b/stubs/inertia-react/resources/js/Pages/Welcome.js @@ -0,0 +1,251 @@ +import React from 'react'; +import { InertiaLink } from '@inertiajs/inertia-react'; + +export default function Welcome(props) { + return ( +
+
+ {props.auth.user ? ( + + Dashboard + + ) : ( + <> + + Log in + + + + Register + + + )} +
+ +
+
+ + + + + +
+ +
+
+
+
+ + + + + +
+ +
+
+ Laravel has wonderful, thorough documentation covering every aspect of the + framework. Whether you are new to the framework or have previous experience with + Laravel, we recommend reading all of the documentation from beginning to end. +
+
+
+ +
+
+ + + + + + +
+ +
+
+ Laracasts offers thousands of video tutorials on Laravel, PHP, and JavaScript + development. Check them out, see for yourself, and massively level up your + development skills in the process. +
+
+
+ +
+
+ + + + + +
+ +
+
+ Laravel News is a community driven portal and newsletter aggregating all of the + latest and most important news in the Laravel ecosystem, including new package + releases and tutorials. +
+
+
+ +
+
+ + + + +
+ Vibrant Ecosystem +
+
+ +
+
+ Laravel's robust library of first-party tools and libraries, such as{' '} + + Forge + + ,{' '} + + Vapor + + ,{' '} + + Nova + + , and{' '} + + Envoyer + {' '} + help you take your projects to the next level. Pair them with powerful open source + libraries like{' '} + + Cashier + + ,{' '} + + Dusk + + ,{' '} + + Echo + + ,{' '} + + Horizon + + ,{' '} + + Sanctum + + ,{' '} + + Telescope + + , and more. +
+
+
+
+
+ +
+
+
+ + + + + + Shop + + + + + + + + Sponsor + +
+
+ +
+ Laravel v{props.laravelVersion} (PHP v{props.phpVersion}) +
+
+
+
+ ); +} diff --git a/stubs/inertia-react/resources/js/app.js b/stubs/inertia-react/resources/js/app.js new file mode 100644 index 000000000..cb900806a --- /dev/null +++ b/stubs/inertia-react/resources/js/app.js @@ -0,0 +1,16 @@ +require('./bootstrap'); + +// Import modules... +import React from 'react'; +import { render } from 'react-dom'; +import { App } from '@inertiajs/inertia-react'; +import { InertiaProgress } from '@inertiajs/progress'; + +const el = document.getElementById('app'); + +render( + require(`./Pages/${name}`).default} />, + el +); + +InertiaProgress.init({ color: '#4B5563' }); diff --git a/stubs/inertia-react/resources/js/bootstrap.js b/stubs/inertia-react/resources/js/bootstrap.js new file mode 100644 index 000000000..692257769 --- /dev/null +++ b/stubs/inertia-react/resources/js/bootstrap.js @@ -0,0 +1,28 @@ +window._ = require('lodash'); + +/** + * We'll load the axios HTTP library which allows us to easily issue requests + * to our Laravel back-end. This library automatically handles sending the + * CSRF token as a header based on the value of the "XSRF" token cookie. + */ + +window.axios = require('axios'); + +window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest'; + +/** + * Echo exposes an expressive API for subscribing to channels and listening + * for events that are broadcast by Laravel. Echo and event broadcasting + * allows your team to easily build robust real-time web applications. + */ + +// import Echo from 'laravel-echo'; + +// window.Pusher = require('pusher-js'); + +// window.Echo = new Echo({ +// broadcaster: 'pusher', +// key: process.env.MIX_PUSHER_APP_KEY, +// cluster: process.env.MIX_PUSHER_APP_CLUSTER, +// forceTLS: true +// }); diff --git a/stubs/inertia/resources/js/Components/ApplicationLogo.vue b/stubs/inertia-vue/resources/js/Components/ApplicationLogo.vue similarity index 100% rename from stubs/inertia/resources/js/Components/ApplicationLogo.vue rename to stubs/inertia-vue/resources/js/Components/ApplicationLogo.vue diff --git a/stubs/inertia/resources/js/Components/Button.vue b/stubs/inertia-vue/resources/js/Components/Button.vue similarity index 100% rename from stubs/inertia/resources/js/Components/Button.vue rename to stubs/inertia-vue/resources/js/Components/Button.vue diff --git a/stubs/inertia/resources/js/Components/Checkbox.vue b/stubs/inertia-vue/resources/js/Components/Checkbox.vue similarity index 100% rename from stubs/inertia/resources/js/Components/Checkbox.vue rename to stubs/inertia-vue/resources/js/Components/Checkbox.vue diff --git a/stubs/inertia/resources/js/Components/Dropdown.vue b/stubs/inertia-vue/resources/js/Components/Dropdown.vue similarity index 100% rename from stubs/inertia/resources/js/Components/Dropdown.vue rename to stubs/inertia-vue/resources/js/Components/Dropdown.vue diff --git a/stubs/inertia/resources/js/Components/DropdownLink.vue b/stubs/inertia-vue/resources/js/Components/DropdownLink.vue similarity index 100% rename from stubs/inertia/resources/js/Components/DropdownLink.vue rename to stubs/inertia-vue/resources/js/Components/DropdownLink.vue diff --git a/stubs/inertia/resources/js/Components/Input.vue b/stubs/inertia-vue/resources/js/Components/Input.vue similarity index 100% rename from stubs/inertia/resources/js/Components/Input.vue rename to stubs/inertia-vue/resources/js/Components/Input.vue diff --git a/stubs/inertia/resources/js/Components/InputError.vue b/stubs/inertia-vue/resources/js/Components/InputError.vue similarity index 100% rename from stubs/inertia/resources/js/Components/InputError.vue rename to stubs/inertia-vue/resources/js/Components/InputError.vue diff --git a/stubs/inertia/resources/js/Components/Label.vue b/stubs/inertia-vue/resources/js/Components/Label.vue similarity index 100% rename from stubs/inertia/resources/js/Components/Label.vue rename to stubs/inertia-vue/resources/js/Components/Label.vue diff --git a/stubs/inertia/resources/js/Components/NavLink.vue b/stubs/inertia-vue/resources/js/Components/NavLink.vue similarity index 100% rename from stubs/inertia/resources/js/Components/NavLink.vue rename to stubs/inertia-vue/resources/js/Components/NavLink.vue diff --git a/stubs/inertia/resources/js/Components/ResponsiveNavLink.vue b/stubs/inertia-vue/resources/js/Components/ResponsiveNavLink.vue similarity index 100% rename from stubs/inertia/resources/js/Components/ResponsiveNavLink.vue rename to stubs/inertia-vue/resources/js/Components/ResponsiveNavLink.vue diff --git a/stubs/inertia/resources/js/Components/ValidationErrors.vue b/stubs/inertia-vue/resources/js/Components/ValidationErrors.vue similarity index 100% rename from stubs/inertia/resources/js/Components/ValidationErrors.vue rename to stubs/inertia-vue/resources/js/Components/ValidationErrors.vue diff --git a/stubs/inertia/resources/js/Layouts/Authenticated.vue b/stubs/inertia-vue/resources/js/Layouts/Authenticated.vue similarity index 100% rename from stubs/inertia/resources/js/Layouts/Authenticated.vue rename to stubs/inertia-vue/resources/js/Layouts/Authenticated.vue diff --git a/stubs/inertia/resources/js/Layouts/Guest.vue b/stubs/inertia-vue/resources/js/Layouts/Guest.vue similarity index 100% rename from stubs/inertia/resources/js/Layouts/Guest.vue rename to stubs/inertia-vue/resources/js/Layouts/Guest.vue diff --git a/stubs/inertia/resources/js/Pages/Auth/ConfirmPassword.vue b/stubs/inertia-vue/resources/js/Pages/Auth/ConfirmPassword.vue similarity index 100% rename from stubs/inertia/resources/js/Pages/Auth/ConfirmPassword.vue rename to stubs/inertia-vue/resources/js/Pages/Auth/ConfirmPassword.vue diff --git a/stubs/inertia/resources/js/Pages/Auth/ForgotPassword.vue b/stubs/inertia-vue/resources/js/Pages/Auth/ForgotPassword.vue similarity index 100% rename from stubs/inertia/resources/js/Pages/Auth/ForgotPassword.vue rename to stubs/inertia-vue/resources/js/Pages/Auth/ForgotPassword.vue diff --git a/stubs/inertia/resources/js/Pages/Auth/Login.vue b/stubs/inertia-vue/resources/js/Pages/Auth/Login.vue similarity index 100% rename from stubs/inertia/resources/js/Pages/Auth/Login.vue rename to stubs/inertia-vue/resources/js/Pages/Auth/Login.vue diff --git a/stubs/inertia/resources/js/Pages/Auth/Register.vue b/stubs/inertia-vue/resources/js/Pages/Auth/Register.vue similarity index 100% rename from stubs/inertia/resources/js/Pages/Auth/Register.vue rename to stubs/inertia-vue/resources/js/Pages/Auth/Register.vue diff --git a/stubs/inertia/resources/js/Pages/Auth/ResetPassword.vue b/stubs/inertia-vue/resources/js/Pages/Auth/ResetPassword.vue similarity index 100% rename from stubs/inertia/resources/js/Pages/Auth/ResetPassword.vue rename to stubs/inertia-vue/resources/js/Pages/Auth/ResetPassword.vue diff --git a/stubs/inertia/resources/js/Pages/Auth/VerifyEmail.vue b/stubs/inertia-vue/resources/js/Pages/Auth/VerifyEmail.vue similarity index 100% rename from stubs/inertia/resources/js/Pages/Auth/VerifyEmail.vue rename to stubs/inertia-vue/resources/js/Pages/Auth/VerifyEmail.vue diff --git a/stubs/inertia/resources/js/Pages/Dashboard.vue b/stubs/inertia-vue/resources/js/Pages/Dashboard.vue similarity index 100% rename from stubs/inertia/resources/js/Pages/Dashboard.vue rename to stubs/inertia-vue/resources/js/Pages/Dashboard.vue diff --git a/stubs/inertia/resources/js/Pages/Welcome.vue b/stubs/inertia-vue/resources/js/Pages/Welcome.vue similarity index 100% rename from stubs/inertia/resources/js/Pages/Welcome.vue rename to stubs/inertia-vue/resources/js/Pages/Welcome.vue diff --git a/stubs/inertia/resources/js/app.js b/stubs/inertia-vue/resources/js/app.js similarity index 100% rename from stubs/inertia/resources/js/app.js rename to stubs/inertia-vue/resources/js/app.js diff --git a/stubs/inertia-vue/resources/js/bootstrap.js b/stubs/inertia-vue/resources/js/bootstrap.js new file mode 100644 index 000000000..692257769 --- /dev/null +++ b/stubs/inertia-vue/resources/js/bootstrap.js @@ -0,0 +1,28 @@ +window._ = require('lodash'); + +/** + * We'll load the axios HTTP library which allows us to easily issue requests + * to our Laravel back-end. This library automatically handles sending the + * CSRF token as a header based on the value of the "XSRF" token cookie. + */ + +window.axios = require('axios'); + +window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest'; + +/** + * Echo exposes an expressive API for subscribing to channels and listening + * for events that are broadcast by Laravel. Echo and event broadcasting + * allows your team to easily build robust real-time web applications. + */ + +// import Echo from 'laravel-echo'; + +// window.Pusher = require('pusher-js'); + +// window.Echo = new Echo({ +// broadcaster: 'pusher', +// key: process.env.MIX_PUSHER_APP_KEY, +// cluster: process.env.MIX_PUSHER_APP_CLUSTER, +// forceTLS: true +// });