-
Notifications
You must be signed in to change notification settings - Fork 3
/
boatTile.js
28 lines (26 loc) · 961 Bytes
/
boatTile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import { LightningElement, api } from 'lwc';
const TILE_WRAPPER_SELECTED_CLASS = "tile-wrapper selected";
const TILE_WRAPPER_UNSELECTED_CLASS = "tile-wrapper";
export default class BoatTile extends LightningElement {
@api boat;
@api selectedBoatId;
// Getter for dynamically setting the background image for the picture
get backgroundStyle() {
return "background-image:url(${this.boat.Picture__c})";
}
// Getter for dynamically setting the tile class based on whether the
// current boat is selected
get tileClass() {
return this.selectedBoatId ? TILE_WRAPPER_SELECTED_CLASS : TILE_WRAPPER_UNSELECTED_CLASS;
}
// Fires event with the Id of the boat that has been selected.
selectBoat() {
this.selectedBoatId = !this.selectedBoatId;
const boatselect = new CustomEvent("boatselect", {
detail: {
boatId: this.boat.Id
}
});
this.dispatchEvent(boatselect);
}
}