Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed dependecies and props user #12

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions src/Console/ReplaceCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ public function replaceInertia()
$extraPackages = [
'@heroicons/vue' => '^1.0.4',
// '@headlessui/vue' => '^1.4.3',
"@inertiajs/inertia" => "^0.11.1",
"@inertiajs/inertia-vue3" => "^0.6.0",
"@inertiajs/progress" => "^0.2.7",
'@vueuse/core' => '^6.5.3',
'perfect-scrollbar' => '^1.5.5',
'vue-toastification' => '^2.0.0-rc.1'
Expand Down Expand Up @@ -99,7 +102,7 @@ public function replaceInertia()
copy(__DIR__ . '/../../stubs/inertia/tailwind.config.js', base_path('tailwind.config.js'));
copy(__DIR__ . '/../../stubs/inertia/css/app.css', resource_path('css/app.css'));

if(!$this->isVite) {
if (!$this->isVite) {
copy(__DIR__ . '/../../stubs/inertia/views/app.mix.blade.php', resource_path('views/app.blade.php'));
copy(__DIR__ . '/../../stubs/inertia/.babelrc', base_path('.babelrc'));
copy(__DIR__ . '/../../stubs/inertia/webpack.config.js', base_path('webpack.config.js'));
Expand All @@ -112,11 +115,11 @@ public function replaceInertia()
copy(__DIR__ . '/../../stubs/common/postcss.config.js', base_path('postcss.config.js'));
}

if($this->option('teams')) {
if ($this->option('teams')) {
(new Filesystem)->ensureDirectoryExists(resource_path('js/Pages/Teams'));
(new Filesystem)->copyDirectory(__DIR__ . '/../../stubs/inertia/js/Teams', resource_path('js/Pages/Teams'));
}

$this->info('Jetstream ui scaffolding replaced successfully.');
$this->comment('Please execute the "npm install && npm run dev" command to build your assets.');
}
Expand Down Expand Up @@ -151,8 +154,8 @@ public function replaceLivewire()
// Assets
copy(__DIR__ . '/../../stubs/livewire/tailwind.config.js', base_path('tailwind.config.js'));
copy(__DIR__ . '/../../stubs/livewire/css/app.css', resource_path('css/app.css'));
if(!$this->isVite) {

if (!$this->isVite) {
copy(__DIR__ . '/../../stubs/livewire/views/layouts/app.mix.blade.php', resource_path('views/layouts/app.blade.php'));
copy(__DIR__ . '/../../stubs/livewire/views/layouts/guest.mix.blade.php', resource_path('views/layouts/guest.blade.php'));
copy(__DIR__ . '/../../stubs/livewire/views/welcome.mix.blade.php', resource_path('views/welcome.blade.php'));
Expand All @@ -167,7 +170,7 @@ public function replaceLivewire()
copy(__DIR__ . '/../../stubs/common/postcss.config.js', base_path('postcss.config.js'));
}

if($this->option('teams')) {
if ($this->option('teams')) {
(new Filesystem)->ensureDirectoryExists(resource_path('views/teams'));
(new Filesystem)->copyDirectory(__DIR__ . '/../../stubs/livewire/views/teams', resource_path('views/teams'));
}
Expand Down
182 changes: 134 additions & 48 deletions stubs/inertia/js/Components/Navbar.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<nav
<nav
aria-label="secondary"
:class="[
'sticky top-0 z-10 px-4 py-2 sm:px-6 sm:py-4 bg-white flex items-center justify-between transition-transform duration-500 dark:bg-dark-eval-1',
Expand Down Expand Up @@ -75,14 +75,30 @@
</Button>

<div class="relative" v-if="$page.props.jetstream.hasTeamFeatures">
<Dropdown align="right" width="60" v-if="$page.props.jetstream.hasTeamFeatures">
<Dropdown
align="right"
width="60"
v-if="$page.props.jetstream.hasTeamFeatures"
>
<template #trigger>
<span class="inline-flex rounded-md">
<button type="button" class="inline-flex items-center px-3 py-2 border border-transparent text-sm leading-4 font-medium rounded-md text-gray-500 bg-white transition hover:bg-gray-50 hover:text-gray-700 dark:bg-dark-eval-1 dark:text-gray-400 dark:hover:text-gray-300 dark:hover:bg-dark-eval-2 focus:outline-none focus:ring focus:ring-purple-500 focus:ring-offset-1 focus:ring-offset-white dark:focus:ring-offset-dark-eval-1">
{{ $page.props.user.current_team.name }}
<button
type="button"
class="inline-flex items-center px-3 py-2 border border-transparent text-sm leading-4 font-medium rounded-md text-gray-500 bg-white transition hover:bg-gray-50 hover:text-gray-700 dark:bg-dark-eval-1 dark:text-gray-400 dark:hover:text-gray-300 dark:hover:bg-dark-eval-2 focus:outline-none focus:ring focus:ring-purple-500 focus:ring-offset-1 focus:ring-offset-white dark:focus:ring-offset-dark-eval-1"
>
{{ $page.props.auth.user.current_team.name }}

<svg class="ml-2 -mr-0.5 h-4 w-4" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor">
<path fill-rule="evenodd" d="M10 3a1 1 0 01.707.293l3 3a1 1 0 01-1.414 1.414L10 5.414 7.707 7.707a1 1 0 01-1.414-1.414l3-3A1 1 0 0110 3zm-3.707 9.293a1 1 0 011.414 0L10 14.586l2.293-2.293a1 1 0 011.414 1.414l-3 3a1 1 0 01-1.414 0l-3-3a1 1 0 010-1.414z" clip-rule="evenodd" />
<svg
class="ml-2 -mr-0.5 h-4 w-4"
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 20 20"
fill="currentColor"
>
<path
fill-rule="evenodd"
d="M10 3a1 1 0 01.707.293l3 3a1 1 0 01-1.414 1.414L10 5.414 7.707 7.707a1 1 0 01-1.414-1.414l3-3A1 1 0 0110 3zm-3.707 9.293a1 1 0 011.414 0L10 14.586l2.293-2.293a1 1 0 011.414 1.414l-3 3a1 1 0 01-1.414 0l-3-3a1 1 0 010-1.414z"
clip-rule="evenodd"
/>
</svg>
</button>
</span>
Expand All @@ -91,32 +107,74 @@
<template #content>
<div class="w-60">
<!-- Team Management -->
<template v-if="$page.props.jetstream.hasTeamFeatures">
<div class="block px-4 py-2 text-xs text-gray-400">
<template
v-if="$page.props.jetstream.hasTeamFeatures"
>
<div
class="block px-4 py-2 text-xs text-gray-400"
>
Manage Team
</div>

<!-- Team Settings -->
<DropdownLink :href="route('teams.show', $page.props.user.current_team)">
<DropdownLink
:href="
route(
'teams.show',
$page.props.auth.user.current_team
)
"
>
Team Settings
</DropdownLink>

<DropdownLink :href="route('teams.create')" v-if="$page.props.jetstream.canCreateTeams">
<DropdownLink
:href="route('teams.create')"
v-if="$page.props.jetstream.canCreateTeams"
>
Create New Team
</DropdownLink>

<div class="border-t border-gray-100 dark:border-gray-700"></div>
<div
class="border-t border-gray-100 dark:border-gray-700"
></div>

<!-- Team Switcher -->
<div class="block px-4 py-2 text-xs text-gray-400">
<div
class="block px-4 py-2 text-xs text-gray-400"
>
Switch Teams
</div>

<template v-for="team in $page.props.user.all_teams" :key="team.id">
<template
v-for="team in $page.props.auth.user
.all_teams"
:key="team.id"
>
<form @submit.prevent="switchToTeam(team)">
<DropdownLink tag="button" type="submit">
<DropdownLink
tag="button"
type="submit"
>
<div class="flex items-center">
<svg v-if="team.id == $page.props.user.current_team_id" class="mr-2 h-5 w-5 text-green-400" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" stroke="currentColor" viewBox="0 0 24 24"><path d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"></path></svg>
<svg
v-if="
team.id ==
$page.props.auth.user
.current_team_id
"
class="mr-2 h-5 w-5 text-green-400"
fill="none"
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="2"
stroke="currentColor"
viewBox="0 0 24 24"
>
<path
d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"
></path>
</svg>
<div>{{ team.name }}</div>
</div>
</DropdownLink>
Expand All @@ -131,16 +189,35 @@
<div class="relative">
<Dropdown align="right" width="48">
<template #trigger>
<button v-if="$page.props.jetstream.managesProfilePhotos" class="flex text-sm border-2 border-transparent rounded-md transition focus:outline-none focus:ring focus:ring-purple-500 focus:ring-offset-1 focus:ring-offset-white dark:focus:ring-offset-dark-eval-1">
<img class="h-8 w-8 rounded-md object-cover" :src="$page.props.user.profile_photo_url" :alt="$page.props.user.name" />
<button
v-if="$page.props.jetstream.managesProfilePhotos"
class="flex text-sm border-2 border-transparent rounded-md transition focus:outline-none focus:ring focus:ring-purple-500 focus:ring-offset-1 focus:ring-offset-white dark:focus:ring-offset-dark-eval-1"
>
<img
class="h-8 w-8 rounded-md object-cover"
:src="$page.props.auth.user.profile_photo_url"
:alt="$page.props.auth.user.name"
/>
</button>

<span v-else class="inline-flex rounded-md">
<button type="button" class="inline-flex items-center px-3 py-2 border border-transparent text-sm leading-4 font-medium rounded-md text-gray-500 bg-white transition hover:bg-gray-50 hover:text-gray-700 dark:bg-dark-eval-1 dark:text-gray-400 dark:hover:text-gray-300 dark:hover:bg-dark-eval-2 focus:outline-none focus:ring focus:ring-purple-500 focus:ring-offset-1 focus:ring-offset-white dark:focus:ring-offset-dark-eval-1">
{{ $page.props.user.name }}
<button
type="button"
class="inline-flex items-center px-3 py-2 border border-transparent text-sm leading-4 font-medium rounded-md text-gray-500 bg-white transition hover:bg-gray-50 hover:text-gray-700 dark:bg-dark-eval-1 dark:text-gray-400 dark:hover:text-gray-300 dark:hover:bg-dark-eval-2 focus:outline-none focus:ring focus:ring-purple-500 focus:ring-offset-1 focus:ring-offset-white dark:focus:ring-offset-dark-eval-1"
>
{{ $page.props.auth.user.name }}

<svg class="ml-2 -mr-0.5 h-4 w-4" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor">
<path fill-rule="evenodd" d="M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z" clip-rule="evenodd" />
<svg
class="ml-2 -mr-0.5 h-4 w-4"
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 20 20"
fill="currentColor"
>
<path
fill-rule="evenodd"
d="M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z"
clip-rule="evenodd"
/>
</svg>
</button>
</span>
Expand All @@ -156,11 +233,16 @@
Profile
</DropdownLink>

<DropdownLink :href="route('api-tokens.index')" v-if="$page.props.jetstream.hasApiFeatures">
<DropdownLink
:href="route('api-tokens.index')"
v-if="$page.props.jetstream.hasApiFeatures"
>
API Tokens
</DropdownLink>

<div class="border-t border-gray-100 dark:border-gray-700"></div>
<div
class="border-t border-gray-100 dark:border-gray-700"
></div>

<!-- Authentication -->
<form @submit.prevent="logout">
Expand All @@ -172,7 +254,7 @@
</Dropdown>
</div>
</div>
</nav>
</nav>

<!-- Mobile bottom bar -->
<div
Expand Down Expand Up @@ -222,49 +304,53 @@
</template>

<script setup>
import { onMounted, onUnmounted } from 'vue'
import { Link } from '@inertiajs/inertia-vue3'
import { Inertia } from '@inertiajs/inertia'
import { useFullscreen } from '@vueuse/core'
import { onMounted, onUnmounted } from 'vue';
import { Link } from '@inertiajs/inertia-vue3';
import { Inertia } from '@inertiajs/inertia';
import { useFullscreen } from '@vueuse/core';
import {
SunIcon,
MoonIcon,
SearchIcon,
MenuIcon,
XIcon,
ArrowsExpandIcon
} from '@heroicons/vue/outline'
import { ArrowsInnerIcon } from '@/Components/Icons/Outline'
ArrowsExpandIcon,
} from '@heroicons/vue/outline';
import { ArrowsInnerIcon } from '@/Components/Icons/Outline';
import {
handleScroll,
isDark,
scrolling,
toggleDarkMode,
sidebarState,
} from '@/Composables'
import ApplicationLogo from '@/Components/ApplicationLogo.vue'
import Button from '@/Components/Button.vue'
import Dropdown from '@/Components/Dropdown.vue'
import DropdownLink from '@/Components/DropdownLink.vue'
} from '@/Composables';
import ApplicationLogo from '@/Components/ApplicationLogo.vue';
import Button from '@/Components/Button.vue';
import Dropdown from '@/Components/Dropdown.vue';
import DropdownLink from '@/Components/DropdownLink.vue';

const { isFullscreen, toggle: toggleFullScreen } = useFullscreen()
const { isFullscreen, toggle: toggleFullScreen } = useFullscreen();

onMounted(() => {
document.addEventListener('scroll', handleScroll)
})
document.addEventListener('scroll', handleScroll);
});
onUnmounted(() => {
document.removeEventListener('scroll', handleScroll)
})
document.removeEventListener('scroll', handleScroll);
});

const logout = () => {
Inertia.post(route('logout'));
}
};

const switchToTeam = (team) => {
Inertia.put(route('current-team.update'), {
'team_id': team.id
}, {
preserveState: false
})
}
Inertia.put(
route('current-team.update'),
{
team_id: team.id,
},
{
preserveState: false,
}
);
};
</script>
Loading