-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Vue layout/pages bootstrap, wp.menus and other props #minor
- Loading branch information
1 parent
b3f3301
commit dd22b8b
Showing
16 changed files
with
300 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
- **Feature**: Menus by location now available on the `wp.menus` page prop | ||
- **Feature**: Filter hooks added, more information coming soon | ||
- **Improvement**: Added default layout and pages to bootstrapped Vue theme | ||
- **Improvement**: `logo`, `name` and `homeUrl` also now available on `wp` page prop |
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,10 @@ | ||
<?php | ||
|
||
namespace EvoMark\InertiaWordpress\Helpers; | ||
|
||
class HookFilters | ||
{ | ||
public const SHARE_MENU = "inertia_wordpress_share_menu"; | ||
public const SHARE_MENU_ITEMS_ARGS = "inertia_wordpress_share_menu_items_args"; | ||
public const MENU_ITEM = "inertia_wordpress_menu_item"; | ||
} |
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
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,35 @@ | ||
<?php | ||
|
||
namespace EvoMark\InertiaWordpress\Resources; | ||
|
||
use EvoMark\InertiaWordpress\Contracts\InertiaResource; | ||
use stdClass; | ||
|
||
class MenuItemResource implements InertiaResource | ||
{ | ||
public static function collection(?array $menus): array | ||
{ | ||
if (empty($menus) || !$menus) return []; | ||
else return array_map(fn($m) => self::single($m), $menus); | ||
} | ||
|
||
public static function single($menu): stdClass | ||
{ | ||
if (is_integer($menu)) { | ||
$menu = get_post($menu); | ||
} | ||
|
||
return (object) [ | ||
'id' => $menu->ID, | ||
'parent' => $menu->menu_item_parent, | ||
'label' => $menu->title, | ||
'slug' => $menu->post_name, | ||
'type' => $menu->type, | ||
'typeLabel' => $menu->type_label, | ||
'url' => $menu->url, | ||
'target' => $menu->target, | ||
'rel' => $menu->xfn, | ||
'classes' => esc_attr($menu->classes ? implode(' ', $menu->classes) : '') | ||
]; | ||
} | ||
} |
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,9 @@ | ||
#app { | ||
display: flex; | ||
flex-direction: column; | ||
min-height: calc(100vh - var(--wp-admin--admin-bar--height)); | ||
} | ||
|
||
main { | ||
flex-grow: 1; | ||
} |
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,72 @@ | ||
<template> | ||
<header> | ||
<div> | ||
<Link :href="homeUrl"> | ||
<img | ||
v-if="logo" | ||
:src="logo.sizes.large.url" | ||
:alt="logo.metadata.alt" | ||
/> | ||
<p v-else>{{ siteName }}</p> | ||
</Link> | ||
</div> | ||
<nav> | ||
<ul v-if="headerMenu" id="header-menu"> | ||
<li v-for="item in headerMenu.items"> | ||
<a | ||
v-if="item.type === 'custom'" | ||
:href="item.url" | ||
target="_blank" | ||
>{{ item.label }}</a | ||
> | ||
<Link v-else :href="item.url">{{ item.label }}</Link> | ||
</li> | ||
</ul> | ||
</nav> | ||
</header> | ||
<slot></slot> | ||
<footer> | ||
<div>© 2024 {{ siteName }}</div> | ||
</footer> | ||
</template> | ||
|
||
<script setup> | ||
import { usePage, Link } from "@inertiajs/vue3"; | ||
import { computed } from "vue"; | ||
|
||
const logo = computed(() => usePage().props.wp.logo); | ||
const homeUrl = computed(() => usePage().props.wp.homeUrl); | ||
const siteName = computed(() => usePage().props.wp.name); | ||
const headerMenu = computed( | ||
() => usePage().props.wp.menus["header-menu"] ?? null | ||
); | ||
</script> | ||
|
||
<style lang="postcss" scoped> | ||
header, | ||
footer { | ||
display: flex; | ||
justify-content: space-between; | ||
align-items: center; | ||
background-color: hsl(204, 15%, 13%); | ||
color: #ffffff; | ||
padding: 1rem 2rem; | ||
} | ||
|
||
footer { | ||
margin-top: 2rem; | ||
} | ||
|
||
#header-menu { | ||
display: flex; | ||
gap: 1rem; | ||
|
||
a { | ||
padding: 0.5rem 1rem; | ||
|
||
&:hover { | ||
color: steelblue; | ||
} | ||
} | ||
} | ||
</style> |
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,5 @@ | ||
<template> | ||
<div>Archive Page</div> | ||
</template> | ||
|
||
<script setup></script> |
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,5 @@ | ||
<template> | ||
<div>Home Page</div> | ||
</template> | ||
|
||
<script setup></script> |
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,5 @@ | ||
<template> | ||
<div>Post Page</div> | ||
</template> | ||
|
||
<script setup></script> |
Oops, something went wrong.