glib-web 0.8.2 → 0.9.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.
@@ -104,6 +104,7 @@ import ColumnPanel from "./panels/column";
104
104
  import ResponsivePanel from "./panels/responsive";
105
105
  import UlPanel from "./panels/ul";
106
106
  import WebPanel from "./panels/web";
107
+ import GridPanel from "./panels/grid";
107
108
 
108
109
  import MultimediaVideo from "./multimedia/video";
109
110
 
@@ -189,6 +190,7 @@ export default {
189
190
  "panels-column": ColumnPanel,
190
191
  "panels-ul": UlPanel,
191
192
  "panels-web": WebPanel,
193
+ "panels-grid": GridPanel,
192
194
 
193
195
  "multimedia-video": MultimediaVideo,
194
196
 
@@ -9,13 +9,13 @@ export default {
9
9
  infiniteScroll: null
10
10
  };
11
11
  },
12
- computed: {
13
- bottomAnchorStyles() {
14
- return {
15
- display: this.infiniteScroll && this.nextPageUrl ? "block" : "none"
16
- };
17
- }
18
- },
12
+ // computed: {
13
+ // bottomAnchorStyles() {
14
+ // return {
15
+ // display: this.infiniteScroll && this.nextPageUrl ? "block" : "none"
16
+ // };
17
+ // }
18
+ // },
19
19
  methods: {
20
20
  enableInfiniteScrollIfApplicable: function() {
21
21
  this.$removeViewportChangeListeners(this.topScrollHandler);
@@ -24,23 +24,8 @@ export default {
24
24
  const prevPage = this.spec.prevPage || {};
25
25
  const nextPage = this.spec.nextPage || {};
26
26
 
27
- // const infiniteScroll = nextPage.autoload == "asNeeded";
28
- // // const infiniteScroll = nextPage.autoLoad;
29
- // if (infiniteScroll) {
30
- // const nextPageUrl = nextPage.url;
31
- // const onScrollToBottom = this.spec.onScrollToBottom;
32
- // if (nextPageUrl || onScrollToBottom) {
33
- // this._registerBottomScroll(nextPageUrl, onScrollToBottom);
34
- // }
35
-
36
- // const prevPageUrl = prevPage.url;
37
- // const onScrollToTop = this.spec.onScrollToTop;
38
- // if (prevPageUrl || onScrollToTop) {
39
- // this._registerTopScroll(prevPageUrl, onScrollToTop);
40
- // }
41
- // }
42
-
43
- this.infiniteScroll = nextPage.autoload == "asNeeded";
27
+ this.infiniteScroll =
28
+ nextPage.autoload == "asNeeded" || prevPage.autoload == "asNeeded";
44
29
  const onScrollToBottom = this.spec.onScrollToBottom;
45
30
  const onScrollToTop = this.spec.onScrollToTop;
46
31
 
@@ -49,16 +34,18 @@ export default {
49
34
  this.prevPageUrl = prevPage.url;
50
35
  }
51
36
 
52
- if (this.nextPageUrl || onScrollToBottom) {
53
- this._registerBottomScroll(onScrollToBottom);
54
- }
37
+ // Avoid executing the scroll actions on page load.
38
+ setTimeout(() => {
39
+ if (this.nextPageUrl || onScrollToBottom) {
40
+ this._registerBottomScroll(onScrollToBottom);
41
+ }
55
42
 
56
- if (this.prevPageUrl || onScrollToTop) {
57
- this._registerTopScroll(onScrollToTop);
58
- }
43
+ if (this.prevPageUrl || onScrollToTop) {
44
+ this._registerTopScroll(onScrollToTop);
45
+ }
46
+ }, 1000);
59
47
  },
60
48
  _registerTopScroll(onScrollToTop) {
61
- // TODO: Consider adding support for prevPageUrl
62
49
  this.topScrollHandler = this.$onVisibilityChange(
63
50
  this.$refs.topAnchor,
64
51
  (el, visible) => {
@@ -71,6 +58,39 @@ export default {
71
58
  this.$addViewportChangeListeners(this.topScrollHandler);
72
59
  },
73
60
  _handleTopScroll(onScrollToTop) {
61
+ if (this.prevPageUrl) {
62
+ this.request = Utils.http.execute(
63
+ { url: this.prevPageUrl },
64
+ "GET",
65
+ this,
66
+ response => {
67
+ const prevPage = response.prevPage;
68
+ if (this.$type.isObject(prevPage)) {
69
+ this.prevPageUrl = response.prevPage.url;
70
+ } else {
71
+ this.prevPageUrl = null;
72
+ }
73
+
74
+ for (const [
75
+ index,
76
+ prependedSection
77
+ ] of response.sections.entries()) {
78
+ const section = this.sections[index];
79
+
80
+ Utils.type.ifArray(prependedSection.rows, rows => {
81
+ for (const row of rows) {
82
+ section.rows.unshift(row);
83
+ }
84
+ });
85
+
86
+ // TODO: scroll back to where the position was before the prepending.
87
+ // https://stackoverflow.com/questions/54765451/preserve-scroll-position-on-dom-update-in-vue-js
88
+ }
89
+ Utils.history.updatePage();
90
+ }
91
+ );
92
+ }
93
+
74
94
  GLib.action.execute(onScrollToTop, this);
75
95
  },
76
96
  _registerBottomScroll(onScrollToBottom) {
@@ -0,0 +1,43 @@
1
+ <template>
2
+ <div :class="$classes()" :style="cssStyles">
3
+ <template v-for="(item, index) in spec.childViews">
4
+ <div :key="index">
5
+ <ui-component :spec="item" />
6
+ </div>
7
+ </template>
8
+ </div>
9
+ </template>
10
+
11
+ <script>
12
+ export default {
13
+ props: {
14
+ spec: { type: Object, required: true }
15
+ },
16
+ computed: {
17
+ cssStyles: function() {
18
+ const styles = this.$styles();
19
+
20
+ styles["display"] = "grid";
21
+ Utils.type.ifNumber(
22
+ this.spec.columnGap,
23
+ columnGap => (styles["columnGap"] = `${columnGap}px`)
24
+ );
25
+ Utils.type.ifNumber(
26
+ this.spec.rowGap,
27
+ rowGap => (styles["rowGap"] = `${rowGap}px`)
28
+ );
29
+ const boxMaxWidth = this.spec.boxMaxWidth
30
+ ? `${this.spec.boxMaxWidth}px`
31
+ : "1fr";
32
+
33
+ styles[
34
+ "gridTemplateColumns"
35
+ ] = `repeat(auto-fit, minmax(${this.spec.boxMinWidth}px, ${boxMaxWidth}))`;
36
+
37
+ return styles;
38
+ }
39
+ }
40
+ };
41
+ </script>
42
+
43
+ <style scoped></style>
@@ -5,7 +5,11 @@
5
5
  class="py-0"
6
6
  :style="genericStyles()"
7
7
  >
8
- <div ref="topAnchor"></div>
8
+ <div ref="topAnchor">
9
+ <div v-if="prevPageUrl" class="py-3 px-4">
10
+ Loading...
11
+ </div>
12
+ </div>
9
13
 
10
14
  <template v-for="(section, sectionIndex) in sections">
11
15
  <div :key="`section${sectionIndex}`">
@@ -46,8 +50,10 @@
46
50
  </div>
47
51
  </template>
48
52
 
49
- <div ref="bottomAnchor" class="py-3 px-4" :style="bottomAnchorStyles">
50
- Loading...
53
+ <div ref="bottomAnchor">
54
+ <div v-if="nextPageUrl" class="py-3 px-4">
55
+ Loading...
56
+ </div>
51
57
  </div>
52
58
  </v-list>
53
59
  </template>
@@ -7,6 +7,10 @@ Array.prototype.remove = function(element) {
7
7
  return false;
8
8
  };
9
9
 
10
+ Array.prototype.prepend = function(element) {
11
+ this.unshift(element);
12
+ };
13
+
10
14
  Array.prototype.clear = function() {
11
15
  this.length = 0;
12
16
  };
package/nav/drawer.vue CHANGED
@@ -13,7 +13,7 @@
13
13
  :mini-variant.sync="mini"
14
14
  @input="updateState"
15
15
  >
16
- <template v-slot:prepend>
16
+ <template v-if="mini" v-slot:prepend>
17
17
  <v-list-item>
18
18
  <v-list-item-icon>
19
19
  <v-icon v-if="!mini">mdi-chevron-left</v-icon>
@@ -167,6 +167,7 @@ export default {
167
167
  },
168
168
  methods: {
169
169
  $ready() {
170
+ this.mini = !this.cssClasses.includes("maxi");
170
171
  this.updateNavigationStyle(window.location);
171
172
 
172
173
  // this.$el.addEventListener('drawers/clickButton', () => { this.updateState(false) }, false)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "glib-web",
3
- "version": "0.8.2",
3
+ "version": "0.9.0",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -13,9 +13,15 @@
13
13
  class="font-weight-bold body-2 subtitle"
14
14
  >{{ spec.title }}</v-card-title
15
15
  >
16
- <div v-if="mode !== 'system'" class="comment-bubble pa-2">
16
+ <!-- eslint-disable vue/no-v-html -->
17
+ <div
18
+ v-if="mode !== 'system'"
19
+ class="comment-bubble pa-2"
20
+ v-html="compiledText"
21
+ >
17
22
  {{ spec.subtitle }}
18
23
  </div>
24
+ <!--eslint-enable-->
19
25
  <img
20
26
  v-if="spec.image"
21
27
  :src="spec.image"
@@ -51,6 +57,11 @@ export default {
51
57
  chips: []
52
58
  };
53
59
  },
60
+ computed: {
61
+ compiledText() {
62
+ return Utils.format.markdown(this.spec.subtitle);
63
+ }
64
+ },
54
65
  methods: {
55
66
  $ready() {
56
67
  const template = this.spec.template;