Skip to content

Commit f6bfffc

Browse files
joyzhongcopybara-github
authored andcommitted
feat(iconbutton): Add filled link icon button variant.
PiperOrigin-RevId: 448264328
1 parent 11b6485 commit f6bfffc

File tree

3 files changed

+48
-1
lines changed

3 files changed

+48
-1
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
//
2+
// Copyright 2022 Google LLC
3+
// SPDX-License-Identifier: Apache-2.0
4+
//
5+
6+
@forward './lib/filled-icon-button-theme' show
7+
theme;
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/**
2+
* @license
3+
* Copyright 2022 Google LLC
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
import '../icon/icon.js';
8+
9+
import {html, TemplateResult} from 'lit';
10+
import {customElement} from 'lit/decorators.js';
11+
import {ClassInfo} from 'lit/directives/class-map.js';
12+
13+
import {styles} from './lib/filled-styles.css.js';
14+
import {LinkIconButton} from './lib/link-icon-button.js';
15+
import {styles as sharedStyles} from './lib/icon-button-styles.css.js';
16+
17+
declare global {
18+
interface HTMLElementTagNameMap {
19+
'md-filled-link-icon-button': MdFilledLinkIconButton;
20+
}
21+
}
22+
23+
@customElement('md-filled-link-icon-button')
24+
export class MdFilledLinkIconButton extends LinkIconButton {
25+
static override styles = [sharedStyles, styles];
26+
27+
/** @soyTemplate */
28+
protected override renderIcon(icon: string): TemplateResult|string {
29+
return icon ? html`<md-icon>${icon}</md-icon>` : '';
30+
}
31+
32+
/** @soyTemplate */
33+
protected override getRenderClasses(): ClassInfo {
34+
return {
35+
...super.getRenderClasses(),
36+
'md3-icon-button--filled': true,
37+
};
38+
}
39+
}

components/icon-button/lib/link-icon-button.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
import {html, TemplateResult} from 'lit';
88
import {property} from 'lit/decorators.js';
9+
import {classMap} from 'lit/directives/class-map.js';
910
import {ifDefined} from 'lit/directives/if-defined.js';
1011

1112
import {IconButton} from './icon-button.js';
@@ -25,7 +26,7 @@ export class LinkIconButton extends IconButton {
2526
/** @soyTemplate */
2627
protected override render(): TemplateResult {
2728
return html`<div
28-
class="md3-icon-button"
29+
class="md3-icon-button ${classMap(this.getRenderClasses())}"
2930
@focus="${this.handleFocus}"
3031
@blur="${this.handleBlur}"
3132
@pointerdown="${this.handlePointerDown}"

0 commit comments

Comments
 (0)