Skip to content

Commit

Permalink
feat(chips): add link chips
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 516873837
  • Loading branch information
asyncLiz authored and copybara-github committed Mar 15, 2023
1 parent 193b220 commit 06bdb86
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
1 change: 1 addition & 0 deletions chips/lib/_shared.scss
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
height: 100%;
padding: 0 16px;
position: relative;
text-decoration: none;
width: 100%;
}

Expand Down
16 changes: 11 additions & 5 deletions chips/lib/chip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,36 @@

import '../../elevation/elevation.js';

import {html, LitElement} from 'lit';
import {LitElement, nothing} from 'lit';
import {property} from 'lit/decorators.js';
import {classMap} from 'lit/directives/class-map.js';
import {html as staticHtml, literal} from 'lit/static-html.js';

/**
* A chip component.
*/
export class Chip extends LitElement {
@property({type: Boolean}) disabled = false;
@property({type: Boolean}) elevated = false;
@property({type: String}) href = '';
@property({type: String}) label = '';
@property({type: String}) target = '';

override render() {
const classes = {
elevated: this.elevated,
flat: !this.elevated,
};

return html`
<button class="container ${classMap(classes)}"
?disabled=${this.disabled}>
const button = this.href ? literal`a` : literal`button`;
return staticHtml`
<${button} class="container ${classMap(classes)}"
?disabled=${this.disabled}
href=${this.href || nothing}
target=${this.href ? this.target : nothing}>
<md-elevation shadow=${this.elevated} surface></md-elevation>
<div class="label">${this.label}</div>
</button>
</${button}>
`;
}
}

0 comments on commit 06bdb86

Please sign in to comment.