-
-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: implement IconButton to overcome a rendering bug in Ripple
Signed-off-by: Rong Sen Ng (motss) <wes.ngrongsen@gmail.com>
- Loading branch information
Showing
6 changed files
with
55 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { customElement } from 'lit/decorators.js'; | ||
|
||
import { appIconButtonName } from './constants.js'; | ||
import { IconButton } from './icon-button.js'; | ||
|
||
@customElement(appIconButtonName) | ||
export class AppIconButton extends IconButton {} | ||
|
||
declare global { | ||
interface HTMLElementTagNameMap { | ||
[appIconButtonName]: AppIconButton; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export const appIconButtonName = 'app-icon-button' as const; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { IconButton as BaseIconButton } from '@material/mwc-icon-button'; | ||
import type { RippleBase } from '@material/mwc-ripple/mwc-ripple-base.js'; | ||
|
||
export class IconButton extends BaseIconButton { | ||
public async layout() { | ||
const ripple = await this.ripple; | ||
|
||
/** | ||
* NOTE(motss): Workaround to force the ripple to update its layout. | ||
* See similar issue at https://github.com/material-components/material-web/issues/1054. | ||
*/ | ||
(ripple?.['mdcFoundation'] as RippleBase['mdcFoundation'])?.layout(); | ||
|
||
await ripple?.updateComplete; | ||
await this.updateComplete; | ||
} | ||
} |