-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* feat(#312): unwrap template injected components * chore(#312): update theming guide * chore(#312): add wrappers example * chore(#312): update wrapper ignore logic
- Loading branch information
Showing
10 changed files
with
206 additions
and
17 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,5 @@ | ||
--- | ||
"druxt": minor | ||
--- | ||
|
||
Changed template injected module components to not use a DruxtWrapper component by default. |
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 @@ | ||
# wrappers | ||
|
||
This directory contains exaples of how to use Wrapper components and the wrapper property. | ||
|
||
|
||
## Setup | ||
|
||
``` | ||
yarn && yarn dev | ||
``` |
16 changes: 16 additions & 0 deletions
16
examples/nuxt/wrappers/components/druxt/entity/node/Page.vue
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,16 @@ | ||
<template> | ||
<div> | ||
<h3>This is a theme component: DruxtEntityNodePage.vue</h3> | ||
<slot /> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
export default { | ||
druxt: { | ||
query: { | ||
schema: true | ||
} | ||
} | ||
} | ||
</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,3 @@ | ||
export default { | ||
buildModules: [['druxt-entity', { baseUrl: 'https://demo-api.druxtjs.org' }]] | ||
} |
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,11 @@ | ||
{ | ||
"name": "wrappers", | ||
"scripts": { | ||
"dev": "nuxt dev" | ||
}, | ||
"packageManager": "[email protected]", | ||
"dependencies": { | ||
"druxt-entity": "link:../../../packages/druxt-entity", | ||
"nuxt": "latest" | ||
} | ||
} |
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,93 @@ | ||
<template> | ||
<div v-if="!$fetchState.pending"> | ||
<h1>DruxtWrapper examples</h1> | ||
<blockquote> | ||
The DruxtWrapper is a theming component that wraps the DruxtModule output. | ||
<br /> | ||
The following examples demonstrate different ways it can be used. | ||
</blockquote> | ||
|
||
<hr /> | ||
|
||
<h2>DruxtEntity default</h2> | ||
<p>This is the default behaviour, renders a theme component.</p> | ||
<pre><code><DruxtEntity :type="type" :uuid="uuid" /></code></pre> | ||
<details> | ||
<summary><strong>Output</strong></summary> | ||
<DruxtEntity :type="type" :uuid="uuid" /> | ||
</details> | ||
|
||
<hr /> | ||
|
||
<h2>DruxtEntity with wrapper disabled</h2> | ||
<p> | ||
This will ignore any available wrapper components and renders the default | ||
output of the DruxtEntity module. | ||
</p> | ||
<pre><code><DruxtEntity :type="type" :uuid="uuid" :wrapper="false" /></code></pre> | ||
<details> | ||
<summary><strong>Output</strong></summary> | ||
<DruxtEntity :type="type" :uuid="uuid" :wrapper="false" /> | ||
</details> | ||
|
||
<hr /> | ||
|
||
<h2>DruxtEntity using template injection, default wrapper</h2> | ||
<p> | ||
The value of the template will be the output of the component, wrapper | ||
component is ignored. | ||
</p> | ||
<pre><code><DruxtEntity :type="type" :uuid="uuid"> | ||
<template #default="{ entity }"> | ||
... | ||
</template> | ||
</DruxtEntity></code></pre> | ||
<details> | ||
<summary><strong>Output</strong></summary> | ||
<DruxtEntity :type="type" :uuid="uuid"> | ||
<template #default="{ entity }"> | ||
<pre><code>{{ JSON.stringify(entity, null, ' ') }}</code></pre> | ||
</template> | ||
</DruxtEntity> | ||
</details> | ||
|
||
<hr /> | ||
|
||
<h2>DruxtEntity using template injection with wrapper enabled</h2> | ||
<p> | ||
The value of the template will be the output of the default slot in a | ||
wrapper component. | ||
</p> | ||
<pre><code><DruxtEntity :type="type" :uuid="uuid" :wrapper="true"> | ||
<template #default="{ entity }"> | ||
... | ||
</template> | ||
</DruxtEntity></code></pre> | ||
<details> | ||
<summary><strong>Output</strong></summary> | ||
<DruxtEntity :type="type" :uuid="uuid" :wrapper="true"> | ||
<template #default="{ entity }"> | ||
<pre><code>{{ JSON.stringify(entity, null, ' ') }}</code></pre> | ||
</template> | ||
</DruxtEntity> | ||
</details> | ||
</div> | ||
|
||
<div v-else>Loading...</div> | ||
</template> | ||
|
||
<script> | ||
import { DrupalJsonApiParams } from 'drupal-jsonapi-params' | ||
export default { | ||
async fetch() { | ||
const query = new DrupalJsonApiParams().addPageLimit(1).addFields(this.type, ['id']) | ||
this.uuid = (await this.$store.dispatch('druxt/getCollection', { type: this.type, query })).data[0].id | ||
}, | ||
data: () => ({ | ||
uuid: null, | ||
type: 'node--page' | ||
}) | ||
} | ||
</script> |
Empty file.
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