egroupware/api/js/etemplate/Et2Button/Et2ButtonIcon.ts
nathan 0775fd1a4e Icon improvements:
- If Et2ButtonIcon image does not resolve to a egw image, treat it as a Shoelace icon name
- Add egw images as an icon library for Shoelace
eg: <sl-icon library="egw" name="5_day_view"/>
2022-08-22 14:06:23 -06:00

43 lines
953 B
TypeScript

/**
* EGroupware eTemplate2 - Button that's just an image
*
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package etemplate
* @subpackage api
* @link https://www.egroupware.org
* @author Nathan Gray
*/
import {Et2InputWidget} from "../Et2InputWidget/Et2InputWidget";
import '../Et2Image/Et2Image';
import {SlIconButton} from "@shoelace-style/shoelace";
import {ButtonMixin} from "./ButtonMixin";
export class Et2ButtonIcon extends ButtonMixin(Et2InputWidget(SlIconButton))
{
set image(new_image : string)
{
let oldValue = this.__src;
if(new_image.indexOf("http") >= 0 || new_image.indexOf(this.egw().webserverUrl) >= 0)
{
this.src = new_image
}
else
{
this.src = this.egw().image(new_image);
}
if(new_image && !this.src)
{
this.name = new_image;
}
}
get image()
{
return this.src || this.name;
}
}
customElements.define("et2-button-icon", Et2ButtonIcon);