@ucd-lib/theme-elements 1.2.7 → 1.2.9

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.
@@ -39,51 +39,18 @@ export default class UcdThemePagination extends LitElement {
39
39
 
40
40
  static get properties() {
41
41
  return {
42
- basePath : {
43
- type: String,
44
- attribute: 'base-path'
45
- },
46
- queryParams: {
47
- type: String,
48
- attribute: 'query-params'
49
- },
50
- useHash : {
51
- type: Boolean,
52
- attribute: 'use-hash'
53
- },
54
- currentPage : {
55
- type : Number,
56
- attribute: 'current-page',
57
- reflect: true
58
- },
59
- maxPages : {
60
- type : Number,
61
- attribute : 'max-pages'
62
- },
63
- visibleLinkCount : {
64
- type : Number,
65
- attribute : 'visible-link-count'
66
- },
67
- disableLabel : {
68
- type: Boolean,
69
- attribute : 'disable-label'
70
- },
71
- _pages : {
72
- type: Array
73
- },
74
- ellipses : {
75
- type: Boolean,
76
- attribute : 'ellipses'
77
- },
78
- xs_screen : {
79
- type: Boolean,
80
- attribute : 'xs-screen'
81
- },
82
- size : {
83
- type: String,
84
- attribute : 'size'
85
- }
86
-
42
+ basePath : { type: String, attribute: 'base-path' },
43
+ queryParams: { type: String, attribute: 'query-params' },
44
+ useHash : { type: Boolean, attribute: 'use-hash' },
45
+ currentPage : { type : Number, attribute: 'current-page', reflect: true },
46
+ maxPages : { type : Number, attribute : 'max-pages' },
47
+ visibleLinkCount : { type : Number, attribute : 'visible-link-count' },
48
+ disableLabel : { type: Boolean, attribute : 'disable-label' },
49
+ _pages : { type: Array },
50
+ ellipses : { type: Boolean, attribute : 'ellipses' },
51
+ xs_screen : { type: Boolean, attribute : 'xs-screen' },
52
+ size : { type: String, attribute : 'size' },
53
+ darkmode : { type: Boolean, attribute : 'darkmode' },
87
54
  };
88
55
  }
89
56
 
@@ -108,10 +75,11 @@ export default class UcdThemePagination extends LitElement {
108
75
  this.ellipses = false;
109
76
  this.xs_screen = false;
110
77
  this.size = '';
78
+ this.darkmode = false;
111
79
 
112
80
  this.screen_check = (window.innerWidth <= this.breakPoints.mobileBreakPoint) ? true : false;
113
81
 
114
- this.render = render.bind(this);
82
+ this.render = render.bind(this);
115
83
  }
116
84
 
117
85
  /**
@@ -120,37 +88,31 @@ export default class UcdThemePagination extends LitElement {
120
88
  */
121
89
  willUpdate(props) {
122
90
  if( props.has('currentPage') || props.has('maxPages') ) {
123
-
124
- if( this.xs_screen && this.screen_check ) {
125
- let pages = [this.currentPage];
126
- this._pages = pages; // Mobile Pagination
91
+ if( this.ellipses && this.maxPages >= 8 ) {
92
+ this._pages = this._renderEllipse();
93
+ } else if ( this.ellipses && this.maxPages < 8 ) {
94
+ this._pages = this._renderOriginal();
127
95
  } else {
128
- if( this.ellipses && this.maxPages >= 8 ) {
129
- this._pages = this._renderEllipse();
130
- } else if ( this.ellipses && this.maxPages < 8 ) {
131
- this._pages = this._renderOriginal();
132
- } else {
133
- let startIndex = Math.floor(this.currentPage - (this.visibleLinkCount/2));
134
-
135
- if( startIndex < 0 ) {
136
- startIndex = 0;
137
- } else if ( (this.currentPage + (this.visibleLinkCount/2)) > this.maxPages ) {
138
- startIndex -= Math.ceil(this.currentPage + (this.visibleLinkCount/2)) - this.maxPages - 1;
139
- }
140
- if( startIndex < 0 ) {
141
- startIndex = 0;
142
- }
143
-
144
- let endIndex = startIndex + this.visibleLinkCount;
145
- if( endIndex > this.maxPages ) endIndex = this.maxPages;
146
-
147
- let pages = [];
148
- for( let i = startIndex; i < endIndex; i++ ) {
149
- pages.push(i+1);
150
- }
151
- this._pages = pages;
152
- }
153
- } // Desktop Pagination
96
+ let startIndex = Math.floor(this.currentPage - (this.visibleLinkCount/2));
97
+
98
+ if( startIndex < 0 ) {
99
+ startIndex = 0;
100
+ } else if ( (this.currentPage + (this.visibleLinkCount/2)) > this.maxPages ) {
101
+ startIndex -= Math.ceil(this.currentPage + (this.visibleLinkCount/2)) - this.maxPages - 1;
102
+ }
103
+ if( startIndex < 0 ) {
104
+ startIndex = 0;
105
+ }
106
+
107
+ let endIndex = startIndex + this.visibleLinkCount;
108
+ if( endIndex > this.maxPages ) endIndex = this.maxPages;
109
+
110
+ let pages = [];
111
+ for( let i = startIndex; i < endIndex; i++ ) {
112
+ pages.push(i+1);
113
+ }
114
+ this._pages = pages;
115
+ }
154
116
  }
155
117
  }
156
118
 
@@ -186,10 +148,14 @@ export default class UcdThemePagination extends LitElement {
186
148
  args.class += ' pager__item--current';
187
149
  }
188
150
 
151
+ if( this.darkmode ) {
152
+ args.class += ' darkmode';
153
+ }
154
+
189
155
  if( !this.basePath && !this.useHash ) {
190
- return html `<li class="pager__item ${args.class || ''}">
156
+ return html `<li class="pager__item ${args.class || ''}">
191
157
  ${((this.currentPage == 1 && args.label == "Prev") || (this.currentPage == this.maxPages && args.label == "Next") ) ?
192
- html`<a style="pointer-events: none; cursor: default; color:#999999; background: white" tabindex="1" @click="${this._onPageClicked}" page="${page}">${args.label || page}</a>`:
158
+ html`<a style="pointer-events: none; cursor: default; color: ${this.darkmode ? '#cccccc' : '#999999'}; background: ${this.darkmode ? 'transparent' : 'white'}" tabindex="1" @click="${this._onPageClicked}" page="${page}">${args.label || page}</a>`:
193
159
  html`<a style="cursor:pointer;" tabindex="1" @click="${this._onPageClicked}" page="${page}">${args.label || page}</a>`
194
160
  }
195
161
  </li>`;
@@ -198,7 +164,7 @@ export default class UcdThemePagination extends LitElement {
198
164
  let href = (this.useHash ? '#' : '') + (this.basePath || '/') + page + (this.queryParams ? '?' + this.queryParams : '');
199
165
  return html`<li class="pager__item ${args.class || ''}">
200
166
  ${((this.currentPage == 1 && args.label == "Prev") || (this.currentPage == this.maxPages && args.label == "Next") ) ?
201
- html` <a style="pointer-events: none; cursor: default; color:#999999; background:white;" href="${href}">${args.label || page}</a>`:
167
+ html` <a style="pointer-events: none; cursor: default; color: ${this.darkmode ? '#cccccc' : '#999999'}; background: ${this.darkmode ? 'transparent' : 'white'};" href="${href}">${args.label || page}</a>`:
202
168
  html` <a href="${href}">${args.label || page}</a>`
203
169
  }
204
170
  </li>`;
@@ -33,6 +33,35 @@ export function styles() {
33
33
  align-items: center;
34
34
  }
35
35
  }
36
+
37
+ .pager__item.darkmode a {
38
+ color: white;
39
+ }
40
+
41
+ .pager .darkmode span {
42
+ color: white;
43
+ }
44
+
45
+ .pager__item--current.darkmode a {
46
+ background-color: #FFBF00;
47
+ color: #002851;
48
+ }
49
+
50
+ .pager__item.darkmode:hover a {
51
+ color: #002851 !important;
52
+ }
53
+
54
+ .pager__item--previous.pager__item--current.darkmode,
55
+ .pager__item--previous.pager__item--current.darkmode:hover,
56
+ .pager__item--next.pager__item--current.darkmode,
57
+ .pager__item--next.pager__item--current.darkmode:hover {
58
+ background-color: transparent;
59
+ }
60
+
61
+ .pager__item--previous.pager__item--current.darkmode:hover a,
62
+ .pager__item--next.pager__item--current.darkmode:hover a {
63
+ color: #cccccc !important;
64
+ }
36
65
  `;
37
66
 
38
67
  return [normalizeCss, resetCss, paginationCss, elementStyles];
@@ -44,7 +73,7 @@ return html`
44
73
  <ul class="pager">
45
74
  ${this.xs_screen ?
46
75
  html`
47
- <div class="xs-screen">
76
+ <div class="xs-screen${this.darkmode ? ' darkmode' : ''}">
48
77
  ${this._renderLink(
49
78
  this.currentPage-1,
50
79
  {label: 'Prev', class: 'pager__item--previous', noHighlight: false}
@@ -58,7 +87,7 @@ return html`
58
87
  )}
59
88
  </div>
60
89
 
61
- <div class="default">
90
+ <div class="default${this.darkmode ? ' darkmode' : ''}">
62
91
  ${this._renderLink(
63
92
  this.currentPage-1,
64
93
  {label: 'Prev', class: 'pager__item--previous', noHighlight: false}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ucd-lib/theme-elements",
3
- "version": "1.2.7",
3
+ "version": "1.2.9",
4
4
  "description": "Custom elements for the UCD brand theme",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -9,12 +9,13 @@ import bookLogo from "./book.js";
9
9
  /**
10
10
  * @class UcdlibBrandingBar
11
11
  * @classdesc Component class for displaying a Library branding bar in a header
12
- *
13
- * @property {String} figure - Figure to display: 'book' or 'logo'
12
+ *
13
+ * @property {String} figure - Figure to display: 'book', 'logo', or 'custom'
14
+ * @property {String} figureSrc - Url of image to use for custom figure
14
15
  * @property {String} siteName - Name of website to display
15
16
  * @property {String} slogan - Optional text to display below site name
16
17
  * @property {String} siteUrl - Url to use for links around site name and figure
17
- *
18
+ *
18
19
  * @examples
19
20
  * <ucdlib-branding-bar>
20
21
  * <a href="#">My Account</a>
@@ -28,7 +29,8 @@ export default class UcdlibBrandingBar extends Mixin(LitElement)
28
29
  static get properties() {
29
30
  return {
30
31
  figure: {type: String},
31
- figureUrl: {type: String, attribute: "figure-url"},
32
+ figureSrc: {type: String, attribute: "figure-src"},
33
+ figureCustomWidth: {type: String, attribute: "figure-custom-width"},
32
34
  siteName: {type: String, attribute: "site-name"},
33
35
  slogan: {type: String},
34
36
  siteUrl: {type: String, attribute: "site-url"},
@@ -49,6 +51,8 @@ export default class UcdlibBrandingBar extends Mixin(LitElement)
49
51
  );
50
52
 
51
53
  this.figure = "book";
54
+ this.figureSrc = '';
55
+ this.figureCustomWidth = '150px';
52
56
  this.siteName = "UC Davis Library";
53
57
  this.slogan = "";
54
58
  this.siteUrl = "/";
@@ -81,7 +85,7 @@ export default class UcdlibBrandingBar extends Mixin(LitElement)
81
85
  */
82
86
  _renderFigure(){
83
87
  if( this.figure === 'custom' ) {
84
- return html`<img src="${this.figureUrl}" />`;
88
+ return html`<img src="${this.figureSrc}" />`;
85
89
  }
86
90
  if ( this.figure === 'logo') return logo;
87
91
  if ( this.figure === 'book' ) return bookLogo;
@@ -106,4 +110,4 @@ export default class UcdlibBrandingBar extends Mixin(LitElement)
106
110
 
107
111
  }
108
112
 
109
- customElements.define('ucdlib-branding-bar', UcdlibBrandingBar);
113
+ customElements.define('ucdlib-branding-bar', UcdlibBrandingBar);
@@ -27,10 +27,6 @@ export function styles() {
27
27
  width: 70px;
28
28
  min-width: 70px;
29
29
  }
30
- .figure--custom img {
31
- width: 150px;
32
- min-width: 150px;
33
- }
34
30
  .figure--logo svg {
35
31
  width: 375px;
36
32
  min-width: 375px;
@@ -66,7 +62,7 @@ export function styles() {
66
62
  display: none;
67
63
  }
68
64
  }
69
-
65
+
70
66
  `;
71
67
 
72
68
  return [
@@ -76,8 +72,14 @@ export function styles() {
76
72
  elementStyles];
77
73
  }
78
74
 
79
- export function render() {
75
+ export function render() {
80
76
  return html`
77
+ <style>
78
+ .figure--custom img {
79
+ width: ${this.figureCustomWidth};
80
+ min-width: ${this.figureCustomWidth};
81
+ }
82
+ </style>
81
83
  <div class="container figure--${this.figure}">
82
84
  <div class="site-branding">
83
85
  <div class="site-branding__figure">
@@ -93,7 +95,7 @@ return html`
93
95
  ${this.navItems.length ? html`
94
96
  <nav class="menu">
95
97
  ${this.navItems.map(link => html`
96
- <a
98
+ <a
97
99
  href=${ifDefined(link.href ? link.href : null)}
98
100
  target=${ifDefined(link.newTab ? "_blank": null)}
99
101
  >${link.linkText}</a>
@@ -103,4 +105,4 @@ return html`
103
105
 
104
106
  </div>
105
107
 
106
- `;}
108
+ `;}
@@ -208,6 +208,14 @@ ${this.isDemo ? html`
208
208
  }
209
209
  }
210
210
  @media (min-width: ${this.mobileWidth}px) {
211
+ .menu--closed .off-canvas--left {
212
+ transform: none !important;
213
+ }
214
+ .off-canvas {
215
+ position: initial !important;
216
+ width: auto !important;
217
+ background-color: transparent !important;
218
+ }
211
219
  .l-header .l-navbar {
212
220
  width: 100%;
213
221
  height: auto;
@@ -221,7 +229,7 @@ ${this.isDemo ? html`
221
229
  width: 100%;
222
230
  }
223
231
  .menu--hidden .off-canvas__container {
224
- display: grid;
232
+ display: grid !important;
225
233
  grid-template-areas: "nav quick search logo";
226
234
  }
227
235
  .l-nav-horizontal {
@@ -361,6 +361,10 @@ return html`
361
361
  }
362
362
  }
363
363
 
364
+ .primary-nav a:hover, .primary-nav__nolink:hover {
365
+ background-color: #ffbf00 !important;
366
+ }
367
+
364
368
  </style>
365
369
  <nav
366
370
  id=${this._classPrefix}