Skip to content

Commit

Permalink
feat(ui-kit/image-box): selected style
Browse files Browse the repository at this point in the history
  • Loading branch information
njfamirm authored and AliMD committed Feb 8, 2023
1 parent e8dc738 commit 78d3976
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions ui/ui-kit/src/card/image-box.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ export class AlwatrImageBox extends AlwatrSurface {
@property({type: Object})
content?: ImageBoxContent;

@property({type: Boolean})
selected = false;

protected override update(changedProperties: PropertyValues<this>): void {
super.update(changedProperties);
if (changedProperties.has('content') && this.content != null) {
Expand All @@ -108,6 +111,29 @@ export class AlwatrImageBox extends AlwatrSurface {
}
}

override connectedCallback(): void {
super.connectedCallback();
this.renderRoot.addEventListener('click', this._toggleSelect.bind(this));
}

protected _toggleSelect(): void {
this.selected = !this.selected;

if (this.selected) {
this.setAttribute('selected', '');
this.setAttribute('outlined', '');
this.removeAttribute('highlight');
this.removeAttribute('elevated');
navigator.vibrate(30);
}
else {
this.removeAttribute('selected');
this.setAttribute('highlight', '');
this.removeAttribute('outlined');
this.setAttribute('elevated', '2');
}
}

override render(): unknown {
this._logger.logMethod('render');
const content = this.content;
Expand Down

0 comments on commit 78d3976

Please sign in to comment.