Skip to content

Commit 06b516b

Browse files
joyzhongcopybara-github
authored andcommitted
refactor(iconbutton): Refactor static styles into shared file, in preparation for adding icon button variants, which will share the static-styles mixin.
PiperOrigin-RevId: 447538482
1 parent 87e4f81 commit 06b516b

File tree

8 files changed

+37
-17
lines changed

8 files changed

+37
-17
lines changed

components/icon-button/icon-button-toggle.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@ import '../icon/icon.js';
99
import {html, TemplateResult} from 'lit';
1010
import {customElement} from 'lit/decorators.js';
1111

12-
import {styles} from './lib/icon-button-styles.css.js';
12+
import {styles as sharedStyles} from './lib/icon-button-styles.css.js';
1313
import {IconButtonToggle} from './lib/icon-button-toggle.js';
14+
import {styles} from './lib/standard-styles.css.js';
1415

1516
declare global {
1617
interface HTMLElementTagNameMap {
@@ -20,7 +21,7 @@ declare global {
2021

2122
@customElement('md-icon-button-toggle')
2223
export class MdIconButtonToggle extends IconButtonToggle {
23-
static override styles = [styles];
24+
static override styles = [sharedStyles, styles];
2425

2526
/** @soyTemplate */
2627
protected override renderIcon(icon: string): TemplateResult|string {

components/icon-button/icon-button.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ import {html, TemplateResult} from 'lit';
1010
import {customElement} from 'lit/decorators.js';
1111

1212
import {IconButton} from './lib/icon-button.js';
13-
import {styles} from './lib/icon-button-styles.css.js';
13+
import {styles as sharedStyles} from './lib/icon-button-styles.css.js';
14+
import {styles} from './lib/standard-styles.css.js';
1415

1516
declare global {
1617
interface HTMLElementTagNameMap {
@@ -20,7 +21,7 @@ declare global {
2021

2122
@customElement('md-icon-button')
2223
export class MdIconButton extends IconButton {
23-
static override styles = [styles];
24+
static override styles = [sharedStyles, styles];
2425

2526
/** @soyTemplate */
2627
protected override renderIcon(icon: string): TemplateResult|string {

components/icon-button/lib/_icon-button.scss

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//
2-
// Copyright 2021 Google LLC
2+
// Copyright 2022 Google LLC
33
// SPDX-License-Identifier: Apache-2.0
44
//
55

@@ -27,7 +27,6 @@
2727
background-color: transparent;
2828
border: none;
2929
box-sizing: border-box;
30-
color: inherit;
3130
cursor: pointer;
3231
display: flex;
3332
fill: currentColor;

components/icon-button/lib/_icon-button-theme.scss renamed to components/icon-button/lib/_standard-icon-button-theme.scss

File renamed without changes.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
//
2+
// Copyright 2021 Google LLC
3+
// SPDX-License-Identifier: Apache-2.0
4+
//
5+
6+
@mixin static-styles() {
7+
// Intentionally blank for future-proofing.
8+
}

components/icon-button/lib/icon-button-styles.scss

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,6 @@
33
// SPDX-License-Identifier: Apache-2.0
44
//
55

6-
// stylelint-disable selector-class-pattern --
7-
// Selector '.md3-*' should only be used in this project.
8-
96
@use './icon-button';
10-
@use './icon-button-theme';
11-
12-
@include icon-button.static-styles();
137

14-
.md3-icon-button {
15-
@include icon-button-theme.theme-styles(icon-button-theme.$light-theme);
16-
}
8+
@include icon-button.static-styles;
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
//
2+
// Copyright 2022 Google LLC
3+
// SPDX-License-Identifier: Apache-2.0
4+
//
5+
6+
// stylelint-disable selector-class-pattern --
7+
// Selector '.md3-*' should only be used in this project.
8+
9+
@use './standard-icon-button';
10+
@use './standard-icon-button-theme';
11+
12+
@include standard-icon-button.static-styles();
13+
14+
.md3-icon-button {
15+
@include standard-icon-button-theme.theme-styles(
16+
standard-icon-button-theme.$light-theme
17+
);
18+
}

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@ import '../icon/icon.js';
99
import {html, TemplateResult} from 'lit';
1010
import {customElement} from 'lit/decorators.js';
1111

12-
import {styles} from './lib/icon-button-styles.css.js';
12+
import {styles as sharedStyles} from './lib/icon-button-styles.css.js';
1313
import {LinkIconButton} from './lib/link-icon-button.js';
14+
import {styles} from './lib/standard-styles.css.js';
1415

1516
declare global {
1617
interface HTMLElementTagNameMap {
@@ -20,7 +21,7 @@ declare global {
2021

2122
@customElement('md-link-icon-button')
2223
export class MdLinkIconButton extends LinkIconButton {
23-
static override styles = [styles];
24+
static override styles = [sharedStyles, styles];
2425

2526
/** @soyTemplate */
2627
protected override renderIcon(icon: string): TemplateResult|string {

0 commit comments

Comments
 (0)