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

feat(#112): add DruxtBlocksRegionMixin #428

Merged
merged 1 commit into from
Feb 3, 2022
Merged
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
12 changes: 12 additions & 0 deletions .changeset/slow-singers-act.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
"druxt-blocks": minor
---

feat(#112): Added DruxtBlocksRegionMixin

```js
import { DruxtBlocksRegionMixin } from 'druxt-blocks'
export default {
mixins: [DruxtBlocksRegionMixin]
}
```
28 changes: 25 additions & 3 deletions packages/blocks/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { DruxtBlocksNuxtModule } from './nuxtModule'
* @type {Function}
* @exports default
* @name DruxtBlocksModule
* @see {@link ./nuxtModule|DruxtBlocksModule}
* @see {@link /api/packages/blocks/nuxtModule|DruxtBlocksModule}
*
* @example <caption>nuxt.config.js</caption> @lang js
* module.exports = {
Expand All @@ -23,10 +23,32 @@ import { DruxtBlocksNuxtModule } from './nuxtModule'
export default DruxtBlocksNuxtModule

/**
* Vue.js Mixin.
* The DruxtBlocksBlockMixin adds props and computed props to your DruxtBlock
* wrapper component.
*
* @type {object}
* @exports DruxtBlocksBlockMixin
* @see {@link ./mixins/block|DruxtBlocksBlockMixin}
* @see {@link /api/packages/blocks/mixins/block|DruxtBlocksBlockMixin}
*
* @example @lang js
* import { DruxtBlocksBlockMixin } from 'druxt-blocks'
* export default {
* mixins: [DruxtBlocksBlockMixin]
* }
*/
export { DruxtBlocksBlockMixin } from './mixins/block'

/**
* The DruxtBlocksRegionMixin adds props to your DruxtBlock wrapper component.
*
* @type {object}
* @exports DruxtBlocksRegionMixin
* @see {@link /api/packages/blocks/mixins/region|DruxtBlocksRegionMixin}
*
* @example @lang js
* import { DruxtBlocksRegionMixin } from 'druxt-blocks'
* export default {
* mixins: [DruxtBlocksRegionMixin]
* }
*/
export { DruxtBlocksRegionMixin } from './mixins/region'
20 changes: 8 additions & 12 deletions packages/blocks/src/mixins/block.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,24 @@
/**
* Provides Vue.js properties to render Drupal Block components.
*
* This Mixin is intended for use by `block` type Component Suggestions for
* targetted theming of Drupal Blocks.
* Provides props and computed values for use with a DruxtBlock Wrapper
* component.
*
* @mixin
*
* @example @lang vue
* <template>
* <DruxtDebug :json="block" />
* </template>
*
* <script>
* // Import mixin.
* import { DruxtBlocksBlockMixin } from 'druxt-blocks'
*
* export default {
* // Register mixin.
* mixins: [DruxtBlocksBlockMixin],
* }
* </script>
*/
const DruxtBlocksBlockMixin = {
/**
* Vue.js Properties.
*/
/** */
props: {
/**
* The Block JSON:API resource.
Expand All @@ -33,9 +31,7 @@ const DruxtBlocksBlockMixin = {
},
},

/**
* Vue.js Computed properties.
*/
/** */
computed: {
/**
* Block settings.
Expand Down
29 changes: 29 additions & 0 deletions packages/blocks/src/mixins/index.js
Original file line number Diff line number Diff line change
@@ -1 +1,30 @@
/**
* The DruxtBlocksBlockMixin adds props and computed props to your DruxtBlock
* wrapper component.
*
* @type {object}
* @exports DruxtBlocksBlockMixin
* @see {@link /api/packages/blocks/mixins/block|DruxtBlocksBlockMixin}
*
* @example @lang js
* import { DruxtBlocksBlockMixin } from 'druxt-blocks'
* export default {
* mixins: [DruxtBlocksBlockMixin]
* }
*/
export { DruxtBlocksBlockMixin } from './block'

/**
* The DruxtBlocksRegionMixin adds props to your DruxtBlock wrapper component.
*
* @type {object}
* @exports DruxtBlocksRegionMixin
* @see {@link /api/packages/blocks/mixins/region|DruxtBlocksRegionMixin}
*
* @example @lang js
* import { DruxtBlocksRegionMixin } from 'druxt-blocks'
* export default {
* mixins: [DruxtBlocksRegionMixin]
* }
*/
export { DruxtBlocksRegionMixin } from './region'
58 changes: 58 additions & 0 deletions packages/blocks/src/mixins/region.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/**
* Provides props and computed values for use with a DruxtBlockRegion Wrapper
* component.
*
* @mixin
*
* @example @lang vue
* <template>
* <DruxtDebug :json="blocks" />
* </template>
*
* <script>
* import { DruxtBlocksRegionMixin } from 'druxt-blocks'
*
* export default {
* mixins: [DruxtBlocksRegionMixin],
* }
* </script>
*/
const DruxtBlocksRegionMixin = {
/** */
props: {
/**
* The Block JSON:API resources.
*
* @type {objects[]}
* @required
*/
blocks: {
type: Array,
required: true,
},

/**
* The Block regions machine name.
*
* @type {string}
* @default content
*/
name: {
type: String,
default: 'content'
},

/**
* A Drupal theme machine name.
*
* @type {string}
* @required
*/
theme: {
type: String,
required: true
},
},
}

export { DruxtBlocksRegionMixin }