Skip to content

Commit

Permalink
Merge pull request #79 from UCDavisLibrary/sp-collection-card
Browse files Browse the repository at this point in the history
Sp collection card
  • Loading branch information
jrmerz authored Mar 11, 2021
2 parents eb3e195 + 2bfa626 commit e2aedae
Show file tree
Hide file tree
Showing 9 changed files with 206 additions and 44 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import { LitElement } from 'lit-element';
import render from "./dams-collection-card.tpl.js";

/**
* @class DamsCollectionCard
* @description UI component class for displaying a collection preview card
*
* @prop {Object} collection - An object describing a DAMS collection.
* If used, element will set all subsequent properties with data from collections object.
* @prop {String} imgSrc - The collection thumbnail src.
* @prop {String} cardTitle - The title of the collection.
* @prop {Number} itemCt - The total number of items in the collections.
* @prop {String} href - Link to the collection landing page.
*/
export default class DamsCollectionCard extends LitElement {

static get properties() {
return {
collection: {type: Object},
imgSrc: {type: String, attribute: 'img-src'},
cardTitle: {type: String, attribute: 'card-title'},
itemCt: {type: Number, attribute: 'item-ct'},
href: {type: String}
};
}

constructor() {
super();
this.render = render.bind(this);
this.imgSrc = "";
this.cardTitle = "";
this.itemCt = 0;
this.href = "";

}

/**
* @method updated
* @description Lit lifecycle method called when element is updated.
* @param {Map} props - Properties that have changed.
*/
updated(props) {
if ( props.has('collection') && this.collection['_id'] ) {
this.imgSrc = this.collection.thumbnailUrl;
this.cardTitle = this.collection.name;
this.itemCt = this.collection.recordCount;
this.href = this.collection['_id'];
}
}
}

customElements.define('dams-collection-card', DamsCollectionCard);
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
import { html } from 'lit-element';
import { styleMap } from 'lit-html/directives/style-map';

export default function render() {
return html`
<style>
:host {
display: block;
}
.container {
cursor: pointer;
}
a {
text-decoration: none;
}
.img-container {
width: 100%;
position: relative;
padding-top: 75%;
background-image: url(/images/logos/logo-white-512.png);
background-color: var(--color-black-20);
background-size: contain;
background-repeat: no-repeat;
background-position: center center;
}
.img-container img {
position: absolute;
top: 0;
width: 100%;
height: 100%;
object-fit: cover;
}
.head {
border: 3px solid transparent;
transition: .3s;
}
.container:hover .head, .container:focus .head {
border: 3px solid var(--color-dams-secondary);
}
h5 {
margin: 10px 0 5px 0;
color: var(--color-h5);
font-size: var(--fs-h5);
font-weight: var(--fw-h5);
}
.subtitle {
font-size: var(--fs-p);
font-weight: var(--fw-extra-bold);
color: var(--color-aggie-blue-70);
margin-bottom: 20px;
}
.gold-dots {
width: 0;
transition: .4s;
border-bottom: 5px dotted var(--color-dams-secondary);
}
.container:hover .gold-dots, .container:focus .gold-dots {
width: 100%;
}
</style>
<div class="container"><a href="${this.href}">
<div class="head">
<div class="img-container">
${this.imgSrc ? html`
<img src="${this.imgSrc}">
` : html``}
</div>
</div>
<div class="body">
<h5>${this.cardTitle}</h5>
<div class="subtitle">${this.itemCt} item${this.itemCt === 1 ? "" : "s"}</div>
</div>
<div class="footer">
<div class="gold-dots"></div>
</div></a>
</div>
`;}
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ import render from "./dams-watercolor-overlay.tpl.js";
* @class DamsWatercolorOverlay
* @description UI component class that overlays an image or icon over watercolor artwork
*
* @prop wcPattern - Watercolor pattern to use
* @prop wcColor - Color of background watercolor
* @prop wcRotation - Rotation (in degrees) of background watercolor
* @prop imgSrc - Path to the overlay image
* @prop icon - Iron Icon to overlay over watercolor (use this OR imgSrc)
* @prop overlayWidth - The width of the overlayed asset in pixels
* @prop overlayHeight - The height of the overlayed asset in pixels
* @prop overlayTop - Where the overlayed asset should be placed on the Y axis
* @prop overlayLeft - Where the overlayed asset should be placed on the X axis
* @prop {String} wcPattern - Watercolor pattern to use
* @prop {String} wcColor - Color of background watercolor
* @prop {Number} wcRotation - Rotation (in degrees) of background watercolor
* @prop {String} imgSrc - Path to the overlay image
* @prop {String} icon - Iron Icon to overlay over watercolor (use this OR imgSrc)
* @prop {Number} overlayWidth - The width of the overlayed asset in pixels
* @prop {Number} overlayHeight - The height of the overlayed asset in pixels
* @prop {String} overlayTop - Where the overlayed asset should be placed on the Y axis
* @prop {String} overlayLeft - Where the overlayed asset should be placed on the X axis
*/
export default class DamsWatercolorOverlay extends LitElement {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import render from "./dams-watercolor.tpl.js";
/**
* @class DamsWatercolor
* @description UI component class for displaying decorative watercolor images
* @prop srcDir - Server directory containing watercolor assets
* @prop srcFilePrefix - The requested watercolor pattern
* @prop srcExt - The watercolor image extension type
* @prop color - The watercolor image. See CSS custom variables for accepted values
* @prop rotate - Degree to rotate watercolor
* @prop width - Watercolor width
* @prop height - Watercolor height
* @prop {String} srcDir - Server directory containing watercolor assets
* @prop {String} srcFilePrefix - The requested watercolor pattern
* @prop {String} srcExt - The watercolor image extension type
* @prop {String} color - The watercolor image. See CSS custom variables for accepted values
* @prop {Number} rotate - Degree to rotate watercolor
* @prop {String} width - Watercolor width
* @prop {String} height - Watercolor height
*
*/
export default class DamsWatercolor extends LitElement {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import render from "./app-components.tpl.js";

import "../../components/graphics/dams-watercolor";
import "../../components/graphics/dams-watercolor-overlay";
import "../../components/cards/dams-collection-card";
import "../../components/filterButton";
import "../../components/icon";
import "../../components/nav-bar";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ return html`
color: var(--color-dams-primary);
background-color: var(--color-black-10);
}
.collection-cards {
display: grid;
grid-template-columns: repeat(3, minmax(0, 1fr));
grid-gap: var(--spacing-default);
}
</style>
<h1 style="text-align:center;">Dams Site Components</h1>
Expand Down Expand Up @@ -66,6 +71,31 @@ return html`
icon="star"></dams-watercolor-overlay>
</section>
<section>
<h2>Collections Preview Card</h2>
${ SharedHtml.headerDots() }
<div class="collection-cards">
<dams-collection-card
href="https://google.com"
item-ct="1"
card-title="A Collection">
</dams-collection-card>
<dams-collection-card
href="#"
item-ct="45"
card-title="Pioneering Punjabis"
img-src="/images/dev/everest.jpg">
</dams-collection-card>
<dams-collection-card
href="#"
item-ct="809"
card-title="Sherry Lehmann"
img-src="/images/dev/lehmann.jpg">
</dams-collection-card>
</div>
</section>
<section>
<h2>Filter Button</h2>
<p>Attach a listener to activate filter button appearence and can be exited out once attached.</p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import "../../components/icon";
import "../../components/search-box";
import "../../components/nav-bar";
import "../../components/filterButton";
import "../../components/cards/dams-collection-card";

import render from './app-home.tpl.js';
//import "../../styles/shared-styles";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { html } from 'lit-element';
import sharedStylesCss from "../../styles/shared-styles";
import { styles } from "../../styles/shared-styles";
import { classMap } from 'lit-html/directives/class-map';
import { styleMap } from 'lit-html/directives/style-map';

export default function render() {
return html`
<style>
${styles()}
:host {
display: block;
position: relative;
Expand Down Expand Up @@ -107,27 +108,29 @@ return html`
color: var(--default-secondary-color);
}
.collection-outer {
display: flex;
justify-content: center;
.featured-collections {
background-color: var(--color-aggie-blue-20);
padding: var(--spacing-md) 0;
}
.collections {
display: flex;
flex-flow: row wrap;
justify-content: center;
align-items: center;
padding: 50px 0;
max-width: var(--max-width);
border-bottom: 1px solid var(--light-background-color);
.featured-collections h1 {
text-align: center;
color: var(--color-aggie-blue);
}
.collections > div:hover {
cursor: pointer;
margin: 13px;
border: 2px solid var(--default-primary-color);
.featured-collections .card-grid {
margin: 0 auto;
padding: 20px 0;
}
.card-grid {
max-width: var(--max-width);
display: grid;
grid-template-columns: repeat(3, minmax(0, 1fr));
grid-gap: var(--spacing-default);
}
iron-icon.search-icon {
color: var(--default-primary-color);
}
Expand Down Expand Up @@ -197,9 +200,6 @@ return html`
}
${sharedStylesCss}
</style>
<div id="sample">
Expand Down Expand Up @@ -268,16 +268,13 @@ return html`
</div>
<div class="collection-outer">
<div class="collections" id="collections-home">
${this.highlightedCollections.map((item) =>
<div class="featured-collections">
<h1>Featured Collections</h1>
<div class="card-grid">
${this.highlightedCollections.map((collection) =>
html`
<app-collection-card
data-id="${item._id}"
.collection="${item}"
@keyup="${this._onCollectionClicked}"
@click="${this._onCollectionClicked}">
</app-collection-card>
<dams-collection-card .collection="${collection}"></dams-collection-card>
`
)}
</div>
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit e2aedae

Please sign in to comment.