@itfin/components 1.0.96 → 1.0.99

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@itfin/components",
3
- "version": "1.0.96",
3
+ "version": "1.0.99",
4
4
  "main": "dist/itfin-components.umd.js",
5
5
  "unpkg": "dist/itfin-components.common.js",
6
6
  "author": "Vitalii Savchuk <esvit666@gmail.com>",
@@ -29,6 +29,7 @@
29
29
  <div class="itf-spinner" :class="{'itf-spinner__white': primary}" v-if="loading"></div>
30
30
  <div v-if="loading && loadingText">{{loadingText}}</div>
31
31
  <slot v-else></slot>
32
+ {{toLink}}
32
33
  </nuxt-link>
33
34
 
34
35
  </template>
@@ -167,7 +168,7 @@ class itfButton extends Vue {
167
168
 
168
169
  get toLink() {
169
170
  if (this.to) {
170
- return this.to;
171
+ return this.to || {};
171
172
  } else if (this.href) {
172
173
  return { path: this.href };
173
174
  }
@@ -0,0 +1,42 @@
1
+ <template>
2
+ <span>
3
+ <span v-html="formattedString" />
4
+ <span v-show="(text || '').length > maxChars">
5
+ <a v-show="!isReadMore" id="readmore" :href="link" @click="triggerReadMore($event, true)">{{ moreStr }}</a>
6
+ <a v-show="isReadMore" id="readless" :href="link" @click="triggerReadMore($event, false)">{{ lessStr }}</a>
7
+ </span>
8
+ </span>
9
+ </template>
10
+ <script>
11
+ import { Vue, Component, Prop } from 'vue-property-decorator';
12
+
13
+ export default @Component()
14
+ class ReadMore extends Vue {
15
+ @Prop({ type: String, default: 'more' }) moreStr;
16
+
17
+ @Prop({ type: String, default: 'less' }) lessStr;
18
+
19
+ @Prop({ type: String, default: '#' }) link;
20
+
21
+ @Prop({ type: Number, default: 200 }) maxChars;
22
+
23
+ @Prop({ type: String }) text;
24
+
25
+ isReadMore = false;
26
+
27
+ get formattedString() {
28
+ let text = this.text || '';
29
+ if (!this.isReadMore && text.length > this.maxChars) {
30
+ text = `${text.substring(0, this.maxChars)}...`;
31
+ }
32
+ return text;
33
+ }
34
+
35
+ triggerReadMore(e, b) {
36
+ if (this.link === '#') {
37
+ e.preventDefault();
38
+ }
39
+ if (this.lessStr !== null || this.lessStr !== '') { this.isReadMore = b; }
40
+ }
41
+ }
42
+ </script>