druxt-breadcrumb 0.13.1 → 0.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -13,3 +13,54 @@ const Template = (args, { argTypes }) => ({
13
13
 
14
14
  export const Default = Template.bind({})
15
15
  Default.storyName = 'DruxtBreadcrumb'
16
+
17
+ let code
18
+
19
+ // Wrapper story.
20
+ code = `<template>
21
+ <DruxtDebug :json="crumbs" />
22
+ </template>
23
+
24
+ <script>
25
+ import { DruxtBreadcrumbMixin } from 'druxt-breadcrumb'
26
+ export default {
27
+ mixins: [DruxtBreadcrumbMixin]
28
+ }
29
+ </script>`
30
+ export const Wrapper = (args, { argTypes }) => ({
31
+ components: { DruxtBreadcrumb },
32
+ props: Object.keys(argTypes),
33
+ template: `<DruxtBreadcrumb v-bind="$props" ref="module">
34
+ <template #default>
35
+ Component options:
36
+ <ul>
37
+ <li v-for="option of $refs.module.getModuleComponents()" :key="option.name">{{ option.name }}</li>
38
+ </ul>
39
+ </template>
40
+ </DruxtBreadcrumb>`
41
+ })
42
+ Wrapper.parameters = {
43
+ docs: {
44
+ storyDescription: 'The DruxtBreadcrumb component can be themed by using a Druxt Wrapper component.\n\nCreate an appropriately named component, using the relevant component option, with the following boilerplate:\n\n```jsx\n' + code + '\n```',
45
+ source: { code }
46
+ }
47
+ }
48
+
49
+ // Template injection story.
50
+ code = `<DruxtBreadcrumb>
51
+ <template #default="{ crumbs }">
52
+ <!-- Do whatever you want here -->
53
+ <DruxtDebug :json="crumbs" open />
54
+ </template>
55
+ </DruxtBreadcrumb>`
56
+ export const TemplateInjection = (args, { argTypes }) => ({
57
+ components: { DruxtBreadcrumb },
58
+ props: Object.keys(argTypes),
59
+ template: code.replace('<DruxtBreadcrumb>', '<DruxtBreadcrumb v-bind="$props">')
60
+ })
61
+ TemplateInjection.parameters = {
62
+ docs: {
63
+ storyDescription: 'The DruxtBreadcrumb component can be themed by injecting the default template into the compomnent.\n\n```jsx\n' + code + '\n```',
64
+ source: { code }
65
+ }
66
+ }
@@ -4,10 +4,33 @@ import DruxtModule from 'druxt/dist/components/DruxtModule.vue'
4
4
  import { mapActions, mapState } from 'vuex'
5
5
 
6
6
  /**
7
- * Renders a list of breacrumbs based on the active route.
7
+ * The DruxtBreadcrumb component renders a list of breadcrumbs based on the
8
+ * active route.
8
9
  *
9
10
  * @example @lang vue
10
11
  * <DruxtBreadcrumb />
12
+ *
13
+ * @example @lang vue
14
+ * <DruxtBreadcrumb path="/node/1" />
15
+ *
16
+ * @example <caption>DruxtBreadcrumb Wrapper component boilerplate</caption> @lang vue
17
+ * <template>
18
+ * <DruxtDebug :json="crumbs" />
19
+ * </template>
20
+ *
21
+ * <script>
22
+ * import { DruxtBreadcrumbMixin } from 'druxt-breadcrumb'
23
+ * export default {
24
+ * mixins: [DruxtBreadcrumbMixin]
25
+ * }
26
+ *
27
+ * @example <caption>DruxtBreadcrumb with template injection</caption> @lang vue
28
+ * <DruxtBreadcrumb>
29
+ * <template #default="{ crumbs }">
30
+ * <!-- Do whatever you want here -->
31
+ * <DruxtDebug :json="crumbs" />
32
+ * </template>
33
+ * </DruxtBreadcrumb>
11
34
  */
12
35
  export default {
13
36
  name: 'DruxtBreadcrumb',
@@ -27,6 +50,21 @@ export default {
27
50
  home: {
28
51
  type: Boolean,
29
52
  default: true
53
+ },
54
+
55
+ /**
56
+ * The Decoupled router path.
57
+ *
58
+ * If not set, the Vue router value will be used instead.
59
+ *
60
+ * @type {string}
61
+ *
62
+ * @example @lang vue
63
+ * <DruxtBreacrumb path="/node/1" />
64
+ */
65
+ path: {
66
+ type: String,
67
+ default: ''
30
68
  }
31
69
  },
32
70
 
@@ -50,6 +88,14 @@ export default {
50
88
  */
51
89
  $route: async function() {
52
90
  await this.$fetch()
91
+ },
92
+
93
+ home() {
94
+ this.$fetch()
95
+ },
96
+
97
+ path() {
98
+ this.$fetch()
53
99
  }
54
100
  },
55
101
 
@@ -58,26 +104,34 @@ export default {
58
104
  * Fetch Crumbs
59
105
  */
60
106
  async fetchCrumbs() {
61
- // If there is no route, stop here.
62
- if (!this.route || !Object.keys(this.route).length) return
107
+ const path = this.path || this.$route.path
108
+ let route = this.route
109
+ if (this.path && path !== this.$route.path) {
110
+ route = await this.getRoute(path)
111
+ }
112
+
113
+ // If there is no route, throw an error.
114
+ if (!route || !Object.keys(route).length) {
115
+ throw new Error('No route data available.')
116
+ }
63
117
 
64
118
  // If we are at the root and don't want a home crumb, stop here.
65
- if (this.$route.path === '/' && !this.home) return
119
+ if (path === '/' && !this.home) return
66
120
 
67
121
  // Current route crumb.
68
122
  const crumbs = []
69
- if (this.route.label) {
70
- crumbs.push({ text: this.route.label })
123
+ if (route.label) {
124
+ crumbs.push({ text: route.label })
71
125
  }
72
126
 
73
127
  // If we are at the root of the site, stop here.
74
- if (this.$route.path === '/') {
128
+ if (path === '/') {
75
129
  this.model = crumbs
76
130
  return
77
131
  }
78
132
 
79
133
  // Add crumbs for route parents.
80
- const paths = this.$route.path.split('/').filter(String)
134
+ const paths = path.split('/').filter(String)
81
135
  paths.pop()
82
136
  while (paths.length > 0) {
83
137
  const to = '/' + paths.join('/')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "druxt-breadcrumb",
3
- "version": "0.13.1",
3
+ "version": "0.14.0",
4
4
  "description": "Decoupled Router based Breadcrumb Druxt component.",
5
5
  "keywords": [
6
6
  "breadcrumb",
@@ -41,9 +41,9 @@
41
41
  "dist"
42
42
  ],
43
43
  "dependencies": {
44
- "druxt": "^0.13.0",
45
- "druxt-blocks": "^0.14.1",
46
- "druxt-router": "^0.24.0"
44
+ "druxt": "^0.17.0",
45
+ "druxt-blocks": "^0.15.0",
46
+ "druxt-router": "^0.26.0"
47
47
  },
48
48
  "optionalDependencies": {
49
49
  "vue": "^2.6.14",
package/CHANGELOG.md DELETED
@@ -1,165 +0,0 @@
1
- # druxt-breadcrumb
2
-
3
- ## 0.13.1
4
-
5
- ### Patch Changes
6
-
7
- - Updated dependencies [9161b38]
8
- - druxt-router@0.24.0
9
- - druxt-blocks@0.14.1
10
-
11
- ## 0.13.0
12
-
13
- ### Minor Changes
14
-
15
- - e7b1533: Refactored DruxtModule fetch hooks
16
-
17
- ### Patch Changes
18
-
19
- - Updated dependencies [77ab204]
20
- - druxt-blocks@0.14.0
21
- - druxt@0.13.0
22
- - druxt-router@0.23.0
23
-
24
- ## 0.12.1
25
-
26
- ### Patch Changes
27
-
28
- - Updated dependencies [4504a2f]
29
- - druxt@0.12.0
30
- - druxt-router@0.22.0
31
- - druxt-blocks@0.13.1
32
-
33
- ## 0.12.0
34
-
35
- ### Minor Changes
36
-
37
- - 8d28c18: Updated storybook integration
38
-
39
- ### Patch Changes
40
-
41
- - 9a1d720: Fixed error when no crumbs are present
42
- - dae345e: Removed unused `$druxtBreadcrumb` plugin
43
- - Updated dependencies [9d905e8]
44
- - druxt-router@0.21.0
45
- - druxt-blocks@0.13.0
46
- - druxt@0.11.0
47
-
48
- ## 0.11.0
49
-
50
- ### Minor Changes
51
-
52
- - 715e5ef: Updated component registration method to use the Nuxt `components:dirs` hook
53
-
54
- ### Patch Changes
55
-
56
- - Updated dependencies [1ab762c]
57
- - druxt-router@0.20.0
58
- - druxt-blocks@0.12.0
59
- - druxt@0.10.0
60
-
61
- ## 0.10.1
62
-
63
- ### Patch Changes
64
-
65
- - c4616df: Fixed dependencies
66
- - Updated dependencies [c4616df]
67
- - druxt-blocks@0.11.1
68
- - druxt-router@0.19.1
69
-
70
- ## 0.10.0
71
-
72
- ### Minor Changes
73
-
74
- - 21170fb: Moved Vue components out of bundle
75
-
76
- ⚠ Potential breaking change
77
-
78
- _**Note:** This only effects custom Druxt modules and implementations._
79
-
80
- ```diff
81
- -import { DruxtBreadcrumb } from 'druxt-breadcrumb'
82
- +import DruxtBreadcrumb from 'druxt-breadcrumb/dist/components/DruxtBreadcrumb.vue'
83
- ```
84
-
85
- ### Patch Changes
86
-
87
- - Updated dependencies [21170fb]
88
- - druxt-blocks@0.11.0
89
- - druxt@0.9.0
90
- - druxt-router@0.19.0
91
-
92
- ## 0.9.0
93
-
94
- ### Minor Changes
95
-
96
- - Added support for default template injection
97
- - For details, see the [Druxt 0.8.0 release notes](/api/packages/druxt/CHANGELOG#080)
98
-
99
- ## 0.8.0
100
-
101
- ### Minor Changes
102
-
103
- - Updated component to use DruxtModule
104
-
105
- ## 0.7.2
106
-
107
- ### Patch Changes
108
-
109
- - Updated dependencies
110
-
111
- ## 0.7.1
112
-
113
- ### Patch Changes
114
-
115
- - Updated dependencies
116
-
117
- ## 0.7.0
118
-
119
- ### Minor Changes
120
-
121
- - Added support for the Druxt component
122
-
123
- ## 0.6.1
124
-
125
- ### Patch Changes
126
-
127
- - Updated dependencies
128
-
129
- ## 0.6.0
130
-
131
- ### Minor Changes
132
-
133
- - Refactored module
134
-
135
- ## 0.5.0
136
-
137
- ### Minor Changes
138
-
139
- ## 0.4.0
140
-
141
- ### Minor Changes
142
-
143
- ## 0.3.2
144
-
145
- ### Patch Changes
146
-
147
- ## 0.3.1
148
-
149
- ### Patch Changes
150
-
151
- ## 0.3.0
152
-
153
- ### Minor Changes
154
-
155
- ## 0.2.0
156
-
157
- ### Minor Changes
158
-
159
- ## 0.1.1
160
-
161
- ### Patch Changes
162
-
163
- ## 0.1.0
164
-
165
- ### Minor Changes