Skip to content

Commit

Permalink
refactor(iconbutton): Refactor static styles into shared file, in pre…
Browse files Browse the repository at this point in the history
…paration for adding icon button variants, which will share the `static-styles` mixin.

PiperOrigin-RevId: 447538482
  • Loading branch information
joyzhong authored and copybara-github committed May 9, 2022
1 parent 87e4f81 commit 06b516b
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 17 deletions.
5 changes: 3 additions & 2 deletions components/icon-button/icon-button-toggle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ import '../icon/icon.js';
import {html, TemplateResult} from 'lit';
import {customElement} from 'lit/decorators.js';

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

declare global {
interface HTMLElementTagNameMap {
Expand All @@ -20,7 +21,7 @@ declare global {

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

/** @soyTemplate */
protected override renderIcon(icon: string): TemplateResult|string {
Expand Down
5 changes: 3 additions & 2 deletions components/icon-button/icon-button.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ import {html, TemplateResult} from 'lit';
import {customElement} from 'lit/decorators.js';

import {IconButton} from './lib/icon-button.js';
import {styles} from './lib/icon-button-styles.css.js';
import {styles as sharedStyles} from './lib/icon-button-styles.css.js';
import {styles} from './lib/standard-styles.css.js';

declare global {
interface HTMLElementTagNameMap {
Expand All @@ -20,7 +21,7 @@ declare global {

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

/** @soyTemplate */
protected override renderIcon(icon: string): TemplateResult|string {
Expand Down
3 changes: 1 addition & 2 deletions components/icon-button/lib/_icon-button.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Copyright 2021 Google LLC
// Copyright 2022 Google LLC
// SPDX-License-Identifier: Apache-2.0
//

Expand Down Expand Up @@ -27,7 +27,6 @@
background-color: transparent;
border: none;
box-sizing: border-box;
color: inherit;
cursor: pointer;
display: flex;
fill: currentColor;
Expand Down
8 changes: 8 additions & 0 deletions components/icon-button/lib/_standard-icon-button.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
//
// Copyright 2021 Google LLC
// SPDX-License-Identifier: Apache-2.0
//

@mixin static-styles() {
// Intentionally blank for future-proofing.
}
10 changes: 1 addition & 9 deletions components/icon-button/lib/icon-button-styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,6 @@
// SPDX-License-Identifier: Apache-2.0
//

// stylelint-disable selector-class-pattern --
// Selector '.md3-*' should only be used in this project.

@use './icon-button';
@use './icon-button-theme';

@include icon-button.static-styles();

.md3-icon-button {
@include icon-button-theme.theme-styles(icon-button-theme.$light-theme);
}
@include icon-button.static-styles;
18 changes: 18 additions & 0 deletions components/icon-button/lib/standard-styles.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//
// Copyright 2022 Google LLC
// SPDX-License-Identifier: Apache-2.0
//

// stylelint-disable selector-class-pattern --
// Selector '.md3-*' should only be used in this project.

@use './standard-icon-button';
@use './standard-icon-button-theme';

@include standard-icon-button.static-styles();

.md3-icon-button {
@include standard-icon-button-theme.theme-styles(
standard-icon-button-theme.$light-theme
);
}
5 changes: 3 additions & 2 deletions components/icon-button/link-icon-button.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ import '../icon/icon.js';
import {html, TemplateResult} from 'lit';
import {customElement} from 'lit/decorators.js';

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

declare global {
interface HTMLElementTagNameMap {
Expand All @@ -20,7 +21,7 @@ declare global {

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

/** @soyTemplate */
protected override renderIcon(icon: string): TemplateResult|string {
Expand Down

0 comments on commit 06b516b

Please sign in to comment.