mirror of
				https://github.com/home-assistant/frontend.git
				synced 2025-10-30 22:19:55 +00:00 
			
		
		
		
	Add target selector (#7864)
Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
This commit is contained in:
		| @@ -11,6 +11,7 @@ import { | ||||
| import { fireEvent } from "../common/dom/fire_event"; | ||||
| import type { ToggleButton } from "../types"; | ||||
| import "./ha-svg-icon"; | ||||
| import "@material/mwc-button/mwc-button"; | ||||
|  | ||||
| @customElement("ha-button-toggle-group") | ||||
| export class HaButtonToggleGroup extends LitElement { | ||||
| @@ -21,17 +22,22 @@ export class HaButtonToggleGroup extends LitElement { | ||||
|   protected render(): TemplateResult { | ||||
|     return html` | ||||
|       <div> | ||||
|         ${this.buttons.map( | ||||
|           (button) => html` | ||||
|             <mwc-icon-button | ||||
|               .label=${button.label} | ||||
|               .value=${button.value} | ||||
|               ?active=${this.active === button.value} | ||||
|               @click=${this._handleClick} | ||||
|             > | ||||
|               <ha-svg-icon .path=${button.iconPath}></ha-svg-icon> | ||||
|             </mwc-icon-button> | ||||
|           ` | ||||
|         ${this.buttons.map((button) => | ||||
|           button.iconPath | ||||
|             ? html`<mwc-icon-button | ||||
|                 .label=${button.label} | ||||
|                 .value=${button.value} | ||||
|                 ?active=${this.active === button.value} | ||||
|                 @click=${this._handleClick} | ||||
|               > | ||||
|                 <ha-svg-icon .path=${button.iconPath}></ha-svg-icon> | ||||
|               </mwc-icon-button>` | ||||
|             : html`<mwc-button | ||||
|                 .value=${button.value} | ||||
|                 ?active=${this.active === button.value} | ||||
|                 @click=${this._handleClick} | ||||
|                 >${button.label}</mwc-button | ||||
|               >` | ||||
|         )} | ||||
|       </div> | ||||
|     `; | ||||
| @@ -49,13 +55,15 @@ export class HaButtonToggleGroup extends LitElement { | ||||
|         --mdc-icon-button-size: var(--button-toggle-size, 36px); | ||||
|         --mdc-icon-size: var(--button-toggle-icon-size, 20px); | ||||
|       } | ||||
|       mwc-icon-button { | ||||
|       mwc-icon-button, | ||||
|       mwc-button { | ||||
|         border: 1px solid var(--primary-color); | ||||
|         border-right-width: 0px; | ||||
|         position: relative; | ||||
|         cursor: pointer; | ||||
|       } | ||||
|       mwc-icon-button::before { | ||||
|       mwc-icon-button::before, | ||||
|       mwc-button::before { | ||||
|         top: 0; | ||||
|         left: 0; | ||||
|         width: 100%; | ||||
| @@ -67,17 +75,21 @@ export class HaButtonToggleGroup extends LitElement { | ||||
|         content: ""; | ||||
|         transition: opacity 15ms linear, background-color 15ms linear; | ||||
|       } | ||||
|       mwc-icon-button[active]::before { | ||||
|       mwc-icon-button[active]::before, | ||||
|       mwc-button[active]::before { | ||||
|         opacity: var(--mdc-icon-button-ripple-opacity, 0.12); | ||||
|       } | ||||
|       mwc-icon-button:first-child { | ||||
|       mwc-icon-button:first-child, | ||||
|       mwc-button:first-child { | ||||
|         border-radius: 4px 0 0 4px; | ||||
|       } | ||||
|       mwc-icon-button:last-child { | ||||
|       mwc-icon-button:last-child, | ||||
|       mwc-button:last-child { | ||||
|         border-radius: 0 4px 4px 0; | ||||
|         border-right-width: 1px; | ||||
|       } | ||||
|       mwc-icon-button:only-child { | ||||
|       mwc-icon-button:only-child, | ||||
|       mwc-button:only-child { | ||||
|         border-radius: 4px; | ||||
|         border-right-width: 1px; | ||||
|       } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Bram Kragten
					Bram Kragten