You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lo...@apache.org on 2021/06/01 11:24:35 UTC

[myfaces-tobago] branch master updated: feat: icon for label of tab

This is an automated email from the ASF dual-hosted git repository.

lofwyr pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/myfaces-tobago.git


The following commit(s) were added to refs/heads/master by this push:
     new 4d8179f  feat: icon for label of tab
4d8179f is described below

commit 4d8179f190b36257fe2d5fd405c1d93dc539e544
Author: Udo Schnurpfeil <ud...@irian.eu>
AuthorDate: Tue Jun 1 12:54:19 2021 +0200

    feat: icon for label of tab
    
    fix: TOBAGO-2085
---
 .../tobago/internal/renderkit/renderer/TabGroupRenderer.java   |  8 ++------
 .../content/20-component/070-tab/00-client/Tab_Client.xhtml    | 10 +++++++++-
 2 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/TabGroupRenderer.java b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/TabGroupRenderer.java
index 00f9059..68ece80 100644
--- a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/TabGroupRenderer.java
+++ b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/TabGroupRenderer.java
@@ -285,12 +285,8 @@ public class TabGroupRenderer<T extends AbstractUITabGroup> extends RendererBase
 
           boolean labelEmpty = true;
           final String image = tab.getImage();
-          // tab.getImage() resolves to empty string if el-expression resolves to null
-          if (image != null && !image.isEmpty()) {
-            writer.startElement(HtmlElements.IMG);
-            writer.writeAttribute(HtmlAttributes.SRC, image, true);
-// TBD      writer.writeClassAttribute(Classes.create(tab, (label.getLabel() != null? "image-right-margin" : "image")));
-            writer.endElement(HtmlElements.IMG);
+          if (image != null) {
+            HtmlRendererUtils.encodeIconOrImage(writer, image);
             labelEmpty = false;
           }
           if (label.getLabel() != null) {
diff --git a/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/070-tab/00-client/Tab_Client.xhtml b/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/070-tab/00-client/Tab_Client.xhtml
index 247980b..0d7ac01 100644
--- a/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/070-tab/00-client/Tab_Client.xhtml
+++ b/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/070-tab/00-client/Tab_Client.xhtml
@@ -58,13 +58,21 @@
         <demo-highlight language="markup">&lt;tc:tab label="Only label"/></demo-highlight>
       </tc:tab>
       <tc:tab id="t22" label="Label with image" image="#{request.contextPath}/image/feather-leaf.png">
-        <p>A label and an image are set.</p>
+        <p>A label and an image is set.</p>
         <demo-highlight language="markup">&lt;tc:tab label="Label with image" image="\#{request.contextPath}/image/feather-leaf.png"></demo-highlight>
       </tc:tab>
+      <tc:tab id="t22bi" label="Label with icon" image="bi-gender-female">
+        <p>A label and an image is set to an bootstrap icon.</p>
+        <demo-highlight language="markup">&lt;tc:tab label="Label with icon" image="bi-gender-female"></demo-highlight>
+      </tc:tab>
       <tc:tab id="t23" image="#{request.contextPath}/image/feather-leaf.png">
         <p>Only an image is set.</p>
         <demo-highlight language="markup">&lt;tc:tab image="\#{request.contextPath}/image/feather-leaf.png"></demo-highlight>
       </tc:tab>
+      <tc:tab id="t23bi" image="bi-gender-male">
+        <p>Only an image is set to an bootstrap icon.</p>
+        <demo-highlight language="markup">&lt;tc:tab image="bi-gender-male"></demo-highlight>
+      </tc:tab>
       <tc:tab id="t24">
         <p>Neither a label or an image are set. In this case the header gets a label with the indexnumber of the tab in
           the tabgroup.</p>