-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Use material web ripple component * Improve button style * Use css animation instead of ripple for action * Use ha ripple in all components * Remove unused label
- Loading branch information
Showing
14 changed files
with
145 additions
and
409 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
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,63 @@ | ||
import { AttachableController } from "@material/web/internal/controller/attachable-controller"; | ||
import { MdRipple } from "@material/web/ripple/ripple"; | ||
import "element-internals-polyfill"; | ||
import { css } from "lit"; | ||
import { customElement } from "lit/decorators"; | ||
|
||
@customElement("ha-ripple") | ||
export class HaRipple extends MdRipple { | ||
private readonly attachableTouchController = new AttachableController( | ||
this, | ||
this.onTouchControlChange.bind(this) | ||
); | ||
|
||
attach(control: HTMLElement) { | ||
super.attach(control); | ||
this.attachableTouchController.attach(control); | ||
} | ||
|
||
detach() { | ||
super.detach(); | ||
this.attachableTouchController.detach(); | ||
} | ||
|
||
private _handleTouchEnd = () => { | ||
if (!this.disabled) { | ||
// @ts-ignore | ||
super.endPressAnimation(); | ||
} | ||
}; | ||
|
||
private onTouchControlChange( | ||
prev: HTMLElement | null, | ||
next: HTMLElement | null | ||
) { | ||
// Add touchend event to clean ripple on touch devices using action handler | ||
prev?.removeEventListener("touchend", this._handleTouchEnd); | ||
next?.addEventListener("touchend", this._handleTouchEnd); | ||
} | ||
|
||
static override styles = [ | ||
...super.styles, | ||
css` | ||
:host { | ||
--md-ripple-hover-opacity: var(--ha-ripple-hover-opacity, 0.08); | ||
--md-ripple-pressed-opacity: var(--ha-ripple-pressed-opacity, 0.12); | ||
--md-ripple-hover-color: var( | ||
--ha-ripple-hover-color, | ||
var(--ha-ripple-color, var(--secondary-text-color)) | ||
); | ||
--md-ripple-pressed-color: var( | ||
--ha-ripple-pressed-color, | ||
var(--ha-ripple-color, var(--secondary-text-color)) | ||
); | ||
} | ||
`, | ||
]; | ||
} | ||
|
||
declare global { | ||
interface HTMLElementTagNameMap { | ||
"ha-ripple": HaRipple; | ||
} | ||
} |
Oops, something went wrong.