From 6e91f1034c744eb8af517a583729a917d20befa2 Mon Sep 17 00:00:00 2001 From: milan Date: Fri, 8 Nov 2024 16:43:25 +0100 Subject: [PATCH] changed et2-image to inline svg located inside /egroupware/* so they inherit color just like bootstrap icons -- added bi-card-list.svg to be the same size as other toolbar icons Regarding Ticket #100401 --- api/js/etemplate/Et2Image/Et2Image.ts | 17 +++++++++++++++++ api/src/Image.php | 2 +- .../templates/default/images/bi-12-square.svg | 6 ------ .../templates/default/images/bi-31-square.svg | 2 +- .../templates/default/images/bi-card-list.svg | 5 +++++ 5 files changed, 24 insertions(+), 8 deletions(-) create mode 100644 calendar/templates/default/images/bi-card-list.svg diff --git a/api/js/etemplate/Et2Image/Et2Image.ts b/api/js/etemplate/Et2Image/Et2Image.ts index f2bb363984..542dcf9825 100644 --- a/api/js/etemplate/Et2Image/Et2Image.ts +++ b/api/js/etemplate/Et2Image/Et2Image.ts @@ -13,6 +13,8 @@ import {Et2Widget} from "../Et2Widget/Et2Widget"; import {et2_IDetachedDOM} from "../et2_core_interfaces"; import {property} from "lit/decorators/property.js"; import {customElement} from "lit/decorators/custom-element.js"; +import {until} from "lit/directives/until.js"; +import {unsafeHTML} from "lit/directives/unsafe-html.js"; @customElement("et2-image") export class Et2Image extends Et2Widget(LitElement) implements et2_IDetachedDOM @@ -180,6 +182,21 @@ export class Et2Image extends Et2Widget(LitElement) implements et2_IDetachedDOM this.classList.add('bi-'+bootstrap[1]); return html``; } + + // our own svg images + //only call unsafeHtml when we are inside /egroupware/ + const ourSvg = url.match(/\/egroupware\/([^.]+)\.svg/); + if (ourSvg) + { + const svg = fetch(url) + .then(res => res.text() + .then(text => unsafeHTML(text))); + return html` + ${until(svg, html`...`)} + ` + } + + // fallback case (no svg, web source) return html` '1-square', 'calendar/list_view' => 'list', 'calendar/month_view' => 'calendar/bi-31-square', - 'calendar/multiweek_view' => 'card-list', + 'calendar/multiweek_view' => 'calendar/bi-card-list', 'calendar/needs-action' => 'question-circle', 'calendar/next' => 'arrow-bar-right', 'calendar/nonblocking' => 'ban', diff --git a/calendar/templates/default/images/bi-12-square.svg b/calendar/templates/default/images/bi-12-square.svg index 3ed32e22a5..3a310581cd 100644 --- a/calendar/templates/default/images/bi-12-square.svg +++ b/calendar/templates/default/images/bi-12-square.svg @@ -1,16 +1,10 @@ - diff --git a/calendar/templates/default/images/bi-31-square.svg b/calendar/templates/default/images/bi-31-square.svg index 92b1f77606..8bff231e5d 100644 --- a/calendar/templates/default/images/bi-31-square.svg +++ b/calendar/templates/default/images/bi-31-square.svg @@ -1,5 +1,5 @@ - + diff --git a/calendar/templates/default/images/bi-card-list.svg b/calendar/templates/default/images/bi-card-list.svg new file mode 100644 index 0000000000..28d14832dc --- /dev/null +++ b/calendar/templates/default/images/bi-card-list.svg @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file