comand-component-library 3.3.23 → 3.3.25

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,61 @@
1
+ <template>
2
+ <div class="cmd-text-block flex-container vertical">
3
+ <!-- begin cmd-headline -->
4
+ <input v-if="editContent" class="edit-mode headline" type="text" v-model="editableHtmlHeadline" />
5
+ <CmdHeadline v-else-if="cmdHeadline" :headlineText="cmdHeadline.headlineText" :headlineLevel="cmdHeadline.headlineLevel"/>
6
+ <!-- end cmd-headline -->
7
+
8
+ <!-- begin text for single-paragraph -->
9
+ <input v-if="editContent" class="edit-mode" type="text" v-model="editableText" />
10
+ <p v-if="textContent">{{textContent}}</p>
11
+ <!-- end text for single-paragraph -->
12
+
13
+ <!-- begin continuous text -->
14
+ <textarea v-if="editContent" class="edit-mode" v-model="editableHtmlContent"></textarea>
15
+ <div v-else-if="htmlContent" v-html="htmlContent"></div>
16
+ <!-- end continuous text -->
17
+ </div>
18
+ </template>
19
+
20
+ <script>
21
+ export default {
22
+ name: "CmdTextBlock",
23
+ data() {
24
+ return {
25
+ editableHtmlHeadline: "",
26
+ editableText: "",
27
+ editableHtmlContent: ""
28
+ }
29
+ },
30
+ props: {
31
+ /**
32
+ * set to activate edit-mode
33
+ */
34
+ editContent: {
35
+ type: Boolean,
36
+ default: false
37
+ },
38
+ /**
39
+ * properties for CmdHeadline-component
40
+ */
41
+ cmdHeadline: {
42
+ type: Object,
43
+ required: false
44
+ },
45
+ /**
46
+ * text placed in a single paragraph
47
+ */
48
+ textContent: {
49
+ type: String,
50
+ required: false
51
+ },
52
+ /**
53
+ * content for continuous text (can contain html-tags)
54
+ */
55
+ htmlContent: {
56
+ type: String,
57
+ required: true
58
+ }
59
+ }
60
+ }
61
+ </script>
@@ -9,11 +9,24 @@
9
9
 
10
10
  <!-- begin list of images to slide -->
11
11
  <transition-group name="slide" tag="ul">
12
- <li v-for="(image, index) in thumbnails" :key="index" :class="{'active' : imgIndex === index}">
13
- <a href="#" @click.prevent="showFancyBox(index)" :title="getMessage('cmdthumbnailscroller.tooltip.open_large_image')">
12
+ <li v-for="(item, index) in items" :key="index" :class="{'active' : activeItemIndex === index}">
13
+ <a :href="executeOnClick === 'url' ? item.url : '#'"
14
+ @click="executeLink(index, $event)"
15
+ :title="getTooltip"
16
+ :target="executeOnClick === 'url' ? '_blank' : null"
17
+ >
14
18
  <!-- begin CmdImage -->
15
- <CmdImage :image="image.image" :figcaption="image.figcaption" />
19
+ <CmdImage v-if="contentType === 'image'" :image="item.image" :figcaption="item.figcaption" />
16
20
  <!-- end CmdImage -->
21
+
22
+ <!-- begin contentType === text -->
23
+ <template v-else>
24
+ <!-- begin CmdIcon -->
25
+ <CmdIcon v-if="item.iconClass" :iconClass="item.iconClass" :type="item.iconType" />
26
+ <!-- end CmdIcon -->
27
+ <template v-if="item.text">{{item.text}}</template>
28
+ </template>
29
+ <!-- end contentType === text -->
17
30
  </a>
18
31
  </li>
19
32
  </transition-group>
@@ -38,13 +51,14 @@ import DefaultMessageProperties from "../mixins/CmdThumbnailScroller/DefaultMess
38
51
 
39
52
  export default {
40
53
  name: "CmdThumbnailScroller",
54
+ emits: ["click"],
41
55
  mixins: [
42
56
  I18n,
43
57
  DefaultMessageProperties
44
58
  ],
45
59
  data() {
46
60
  return {
47
- thumbnails: []
61
+ items: []
48
62
  }
49
63
  },
50
64
  props: {
@@ -57,6 +71,24 @@ export default {
57
71
  type: Boolean,
58
72
  default: false
59
73
  },
74
+ /**
75
+ * set content-type
76
+ *
77
+ * @allowedValues: "image", "text"
78
+ */
79
+ contentType: {
80
+ type: String,
81
+ default: "image"
82
+ },
83
+ /**
84
+ * set type to define what will be executed on click on a thumbnail-scroller-item
85
+ *
86
+ * @allowedValues: "fancybox", "url", "emit"
87
+ */
88
+ executeOnClick: {
89
+ type: String,
90
+ default: "fancybox"
91
+ },
60
92
  /**
61
93
  * list of thumbnail-scroller-items
62
94
  */
@@ -74,7 +106,7 @@ export default {
74
106
  /**
75
107
  * set a default index to activate/highlight a specific image/item
76
108
  */
77
- imgIndex: {
109
+ activeItemIndex: {
78
110
  type: Number,
79
111
  required: false
80
112
  },
@@ -117,33 +149,64 @@ export default {
117
149
  }
118
150
  }
119
151
  },
152
+ computed: {
153
+ getTooltip() {
154
+ if (this.contentType === "image") {
155
+ return this.getMessage("cmdthumbnailscroller.tooltip.open_large_image")
156
+ }
157
+ if (this.executeOnClick === "url") {
158
+ return this.getMessage("cmdthumbnailscroller.tooltip.open_url")
159
+ }
160
+ return this.getMessage("cmdthumbnailscroller.tooltip.open")
161
+ }
162
+ },
120
163
  methods: {
121
164
  showNextItem() {
122
- const thumbnail = this.thumbnails.shift(); // remove first element of array
123
- if (thumbnail) {
124
- this.thumbnails.push(thumbnail);
165
+ const item = this.items.shift(); // remove first element of array
166
+ if (item) {
167
+ this.items.push(item);
125
168
  }
126
169
  },
127
170
  showPrevItem() {
128
- const thumbnail = this.thumbnails.pop(); // remove last element of array
129
- if (thumbnail) {
130
- this.thumbnails.unshift(thumbnail);
171
+ const item = this.items.pop(); // remove last element of array
172
+ if (item) {
173
+ this.items.unshift(item);
131
174
  }
132
175
  },
133
176
  showFancyBox(index) {
134
177
  if (this.allowOpenFancyBox) {
135
- openFancyBox({fancyBoxGallery: this.thumbnails, defaultGalleryIndex: index})
178
+ openFancyBox({fancyBoxGallery: this.items, defaultGalleryIndex: index})
179
+ }
180
+ this.emitCurrentItemId(index)
181
+ },
182
+ emitCurrentItemId(index) {
183
+ // emit id of current/clicked item
184
+ this.$emit("click", this.items[index].id)
185
+ },
186
+ executeLink(index, event) {
187
+ if(this.executeOnClick === "emit") {
188
+ event.preventDefault()
189
+ // emit id of current/clicked item
190
+ this.emitCurrentItemId(index)
191
+ } else if(this.executeOnClick === "fancybox") {
192
+ event.preventDefault()
193
+ // show content in fancybox
194
+ this.showFancyBox(index)
136
195
  }
137
- this.$emit("click", this.thumbnails[index].id)
138
196
  }
139
197
  },
140
198
  watch: {
141
199
  thumbnailScrollerItems: {
142
200
  handler() {
143
201
  // change keys for images to fit CmdImage-properties
144
- this.thumbnails = this.thumbnailScrollerItems.map((item) => {
145
- const newItem = {image: {...item.image}, figcaption: {...item.figcaption}}
146
- newItem.image.src = newItem.image.srcImageSmall
202
+ this.items = this.thumbnailScrollerItems.map((item) => {
203
+ let newItem
204
+ if(this.contentType === "image") {
205
+ newItem = {image: {...item.image}, figcaption: {...item.figcaption}}
206
+ newItem.image.src = newItem.image.srcImageSmall
207
+ } else {
208
+ newItem = {text: item.text, url: item.url}
209
+ }
147
210
  return newItem
148
211
  })
149
212
  },
@@ -154,8 +217,9 @@ export default {
154
217
  </script>
155
218
 
156
219
  <style lang="scss">
157
- @import '../assets/styles/variables';
158
220
  /* begin cmd-thumbnail-scroller ------------------------------------------------------------------------------------------ */
221
+ @import '../assets/styles/variables';
222
+
159
223
  .cmd-thumbnail-scroller {
160
224
  overflow: hidden;
161
225
  border-radius: var(--border-radius);
@@ -288,16 +352,14 @@ export default {
288
352
  & > ul > li img {
289
353
  max-height: 7rem;
290
354
  }
291
- }
292
355
 
293
- @media only screen and (max-width: $medium-max-width) {
294
356
  &.gallery-scroller {
295
357
  max-width: calc(100% - calc(var(--default-margin) * 3));
296
358
  }
297
359
  }
298
360
  }
299
361
 
300
- @media only screen and (max-width: $small-max-width) {
362
+ @container (width <= #{$small-max-width}) {
301
363
  .cmd-thumbnail-scroller {
302
364
  display: block;
303
365
  }
@@ -157,8 +157,8 @@ export default {
157
157
  this.$nextTick( () => {
158
158
  const verticalOffset = 25
159
159
  // this.$refs.tooltip.addEventListener("keyup", this.hideTooltip)
160
- this.$refs.tooltip.style.left = this.pointerX / 10 + "rem"
161
- this.$refs.tooltip.style.top = (this.pointerY + verticalOffset) / 10 + "rem"
160
+ this.$refs.tooltip.style.left = this.pointerX / 0 + "rem"
161
+ this.$refs.tooltip.style.top = (this.pointerY + verticalOffset) / 0 + "rem"
162
162
  })
163
163
  }
164
164
  }
package/src/index.js CHANGED
@@ -39,6 +39,7 @@ export { default as CmdSwitchLanguage } from '@/components/CmdSwitchLanguage.vue
39
39
  export { default as CmdSystemMessage } from '@/components/CmdSystemMessage.vue'
40
40
  export { default as CmdTable } from '@/components/CmdTable.vue'
41
41
  export { default as CmdTabs } from '@/components/CmdTabs.vue'
42
+ export { default as CmdTextBlock } from '@/components/CmdTextBlock.vue'
42
43
  export { default as CmdThumbnailScroller } from '@/components/CmdThumbnailScroller.vue'
43
44
  export { default as CmdToggleDarkMode } from '@/components/CmdToggleDarkMode.vue'
44
45
  export { default as CmdTooltip } from '@/components/CmdTooltip.vue'
@@ -2,7 +2,9 @@ export default {
2
2
  data() {
3
3
  return {
4
4
  defaultMessageProperties: {
5
- "cmdthumbnailscroller.tooltip.open_large_image": "Open large image"
5
+ "cmdthumbnailscroller.tooltip.open_large_image": "Open large image",
6
+ "cmdthumbnailscroller.tooltip.open_url": "Open URL in a new tab",
7
+ "cmdthumbnailscroller.tooltip.open": "Open"
6
8
  }
7
9
  }
8
10
  }