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"/>
This commit is contained in:
nathan 2022-08-22 14:05:11 -06:00
parent ffb8354728
commit 0775fd1a4e
2 changed files with 16 additions and 4 deletions

View File

@ -28,11 +28,15 @@ export class Et2ButtonIcon extends ButtonMixin(Et2InputWidget(SlIconButton))
{ {
this.src = this.egw().image(new_image); this.src = this.egw().image(new_image);
} }
if(new_image && !this.src)
{
this.name = new_image;
}
} }
get image() get image()
{ {
return this.src; return this.src || this.name;
} }
} }

View File

@ -4,13 +4,21 @@ import {css} from "lit";
import {registerIconLibrary} from '@shoelace-style/shoelace/dist/utilities/icon-library.js'; import {registerIconLibrary} from '@shoelace-style/shoelace/dist/utilities/icon-library.js';
import {egw} from "../../jsapi/egw_global"; import {egw} from "../../jsapi/egw_global";
/** /**
* This makes sure the built-in icons can be found * Here is the common overrides and customisations for Shoelace
*/ */
registerIconLibrary('default', {
/**
* Register egw images as an icon library
* @example <sl-icon library="egw" name="infolog/navbar"/>
* @example <sl-icon library="egw" name="5_day_view"/>
*/
registerIconLibrary('egw', {
resolver: name => resolver: name =>
{ {
return typeof egw !== "undefined" ? `${egw.webserverUrl}/node_modules/@shoelace-style/shoelace/dist/assets/icons/${name}.svg` : '' return typeof egw !== "undefined" ? (egw.image(name) || '') : ''
}, },
}); });