myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hno...@apache.org
Subject [myfaces-tobago] branch master updated: TOBAGO-1939 Markups for text
Date Tue, 25 Sep 2018 17:51:35 GMT
This is an automated email from the ASF dual-hosted git repository.

hnoeth 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 0aed00d  TOBAGO-1939 Markups for text
0aed00d is described below

commit 0aed00dd9be1c65a212a0056665e20e6e587d30f
Author: Henning Noeth <hnoeth@apache.org>
AuthorDate: Tue Sep 25 19:51:27 2018 +0200

    TOBAGO-1939 Markups for text
    
    * add markups and bootstrap CSS classes
    * markups are available for tc:link and tc:out
    * add example to demo
---
 .../org/apache/myfaces/tobago/context/Markup.java  |  6 +++
 .../internal/renderkit/renderer/LinkRenderer.java  | 16 +++++++
 .../internal/renderkit/renderer/OutRenderer.java   |  2 +
 .../tobago/renderkit/css/BootstrapClass.java       | 50 ++++++++++++++++++++++
 .../20-component/020-output/10-out/out.xhtml       | 19 ++++++++
 .../040-command/00-button+link/button+link.xhtml   | 42 ++++++++++++------
 6 files changed, 123 insertions(+), 12 deletions(-)

diff --git a/tobago-core/src/main/java/org/apache/myfaces/tobago/context/Markup.java b/tobago-core/src/main/java/org/apache/myfaces/tobago/context/Markup.java
index 6889e77..089b567 100644
--- a/tobago-core/src/main/java/org/apache/myfaces/tobago/context/Markup.java
+++ b/tobago-core/src/main/java/org/apache/myfaces/tobago/context/Markup.java
@@ -63,6 +63,7 @@ public final class Markup implements Serializable, Iterable<String>
{
   public static final Markup ASCENDING = valueOf("ascending");
   public static final Markup BADGE = valueOf("badge");
   public static final Markup BIG = valueOf("big");
+  public static final Markup BOLD = valueOf("bold");
   public static final Markup BORDERED = valueOf("bordered");
   public static final Markup BOTTOM = valueOf("bottom");
   public static final Markup CENTER = valueOf("center");
@@ -88,6 +89,7 @@ public final class Markup implements Serializable, Iterable<String>
{
   public static final Markup HOVER = valueOf("hover");
   public static final Markup INFO = valueOf("info");
   public static final Markup INLINE = valueOf("inline");
+  public static final Markup ITALIC = valueOf("italic");
   public static final Markup JUSTIFY = valueOf("justify");
   /**
    * @deprecated since 4.0.0, please use {@link #DARK}
@@ -136,6 +138,7 @@ public final class Markup implements Serializable, Iterable<String>
{
   public static final Markup STRIPED = valueOf("striped");
   public static final Markup STRONG = valueOf("strong");
   public static final Markup SUCCESS = valueOf("success");
+  public static final Markup THIN = valueOf("thin");
   public static final Markup TOGGLER_LEFT = valueOf("togglerLeft");
   public static final Markup TOP = valueOf("top");
   public static final Markup VERTICALLY = valueOf("vertically");
@@ -145,6 +148,7 @@ public final class Markup implements Serializable, Iterable<String>
{
   public static final String STRING_ASCENDING = "ascending";
   public static final String STRING_BADGE = "badge";
   public static final String STRING_BIG = "big";
+  public static final String STRING_BOLD = "bold";
   public static final String STRING_BORDERED = "bordered";
   public static final String STRING_BOTTOM = "bottom";
   public static final String STRING_CENTER = "center";
@@ -170,6 +174,7 @@ public final class Markup implements Serializable, Iterable<String>
{
   public static final String STRING_HOVER = "hover";
   public static final String STRING_INFO = "info";
   public static final String STRING_INLINE = "inline";
+  public static final String STRING_ITALIC = "italic";
   public static final String STRING_JUSTIFY = "justify";
   /**
    * @deprecated since 4.0.0, please use {@link #DARK}
@@ -218,6 +223,7 @@ public final class Markup implements Serializable, Iterable<String>
{
   public static final String STRING_STRIPED = "striped";
   public static final String STRING_STRONG = "strong";
   public static final String STRING_SUCCESS = "success";
+  public static final String STRING_THIN = "thin";
   public static final String STRING_TOGGLER_LEFT = "togglerLeft";
   public static final String STRING_TOP = "top";
   public static final String STRING_VERTICALLY = "vertically";
diff --git a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/LinkRenderer.java
b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/LinkRenderer.java
index 1b87610..ab09aea 100644
--- a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/LinkRenderer.java
+++ b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/LinkRenderer.java
@@ -19,12 +19,28 @@
 
 package org.apache.myfaces.tobago.internal.renderkit.renderer;
 
+import org.apache.myfaces.tobago.context.Markup;
+import org.apache.myfaces.tobago.internal.component.AbstractUICommand;
+import org.apache.myfaces.tobago.renderkit.css.BootstrapClass;
+import org.apache.myfaces.tobago.renderkit.css.CssItem;
 import org.apache.myfaces.tobago.renderkit.css.TobagoClass;
 
+import javax.faces.context.FacesContext;
+
 public class LinkRenderer extends CommandRendererBase {
 
   @Override
   protected TobagoClass getRendererCssClass() {
     return TobagoClass.LINK;
   }
+
+  @Override
+  protected CssItem[] getCssItems(final FacesContext facesContext, final AbstractUICommand
command) {
+    final Markup markup = command.getMarkup() != null ? command.getMarkup() : Markup.NULL;
+
+    return new CssItem[]{
+        BootstrapClass.textColor(markup),
+        BootstrapClass.fontStyle(markup)
+    };
+  }
 }
diff --git a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/OutRenderer.java
b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/OutRenderer.java
index 719ff99..c1c912a 100644
--- a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/OutRenderer.java
+++ b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/OutRenderer.java
@@ -72,6 +72,8 @@ public class OutRenderer extends MessageLayoutRendererBase {
           TobagoClass.OUT,
           TobagoClass.OUT.createMarkup(markup),
           getCssItems(facesContext, out),
+          BootstrapClass.textColor(markup),
+          BootstrapClass.fontStyle(markup),
           out.getCustomClass());
       final String title = HtmlRendererUtils.getTitleFromTipAndMessages(facesContext, out);
       if (title != null) {
diff --git a/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/css/BootstrapClass.java
b/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/css/BootstrapClass.java
index cc2d869..d7ebbff 100644
--- a/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/css/BootstrapClass.java
+++ b/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/css/BootstrapClass.java
@@ -20,6 +20,7 @@
 package org.apache.myfaces.tobago.renderkit.css;
 
 import org.apache.myfaces.tobago.component.Attributes;
+import org.apache.myfaces.tobago.context.Markup;
 import org.apache.myfaces.tobago.layout.AlignItems;
 import org.apache.myfaces.tobago.layout.JustifyContent;
 import org.apache.myfaces.tobago.layout.Margin;
@@ -258,6 +259,9 @@ public enum BootstrapClass implements CssItem {
   FLEX_COLUMN_REVERSE("flex-column-reverse"),
   FLEX_ROW("flex-row"),
   FLEX_ROW_REVERSE("flex-row-reverse"),
+  FONT_ITALIC("font-italic"),
+  FONT_WEIGHT_BOLD("font-weight-bold"),
+  FONT_WEIGHT_LIGHT("font-weight-light"),
   FORM_CHECK("form-check"),
   FORM_CHECK_INLINE("form-check-inline"),
   FORM_CHECK_INPUT("form-check-input"),
@@ -462,6 +466,14 @@ public enum BootstrapClass implements CssItem {
   ROW("row"),
   SHOW("show"),
   SR_ONLY("sr-only"),
+  TEXT_DANGER("text-danger"),
+  TEXT_DARK("text-dark"),
+  TEXT_INFO("text-info"),
+  TEXT_LIGHT("text-light"),
+  TEXT_PRIMARY("text-primary"),
+  TEXT_SECONDARY("text-secondary"),
+  TEXT_SUCCESS("text-success"),
+  TEXT_WARNING("text-warning"),
   TEXT_CENTER("text-center"),
   TEXT_JUSTIFY("text-justify"),
   TEXT_LEFT("text-left"),
@@ -586,6 +598,44 @@ public enum BootstrapClass implements CssItem {
     }
   }
 
+  public static CssItem textColor(final Markup markup) {
+    if (markup == null || markup.contains(Markup.NONE)) {
+      return null;
+    } else if (markup.contains(Markup.PRIMARY)) {
+      return BootstrapClass.TEXT_PRIMARY;
+    } else if (markup.contains(Markup.SECONDARY)) {
+      return BootstrapClass.TEXT_SECONDARY;
+    } else if (markup.contains(Markup.SUCCESS)) {
+      return BootstrapClass.TEXT_SUCCESS;
+    } else if (markup.contains(Markup.DANGER)) {
+      return BootstrapClass.TEXT_DANGER;
+    } else if (markup.contains(Markup.WARNING)) {
+      return BootstrapClass.TEXT_WARNING;
+    } else if (markup.contains(Markup.INFO)) {
+      return BootstrapClass.TEXT_INFO;
+    } else if (markup.contains(Markup.LIGHT)) {
+      return BootstrapClass.TEXT_LIGHT;
+    } else if (markup.contains(Markup.DARK)) {
+      return BootstrapClass.TEXT_DARK;
+    } else {
+      return null;
+    }
+  }
+
+  public static CssItem fontStyle(final Markup markup) {
+    if (markup == null || markup.contains(Markup.NONE)) {
+      return null;
+    } else if (markup.contains(Markup.BOLD)) {
+      return BootstrapClass.FONT_WEIGHT_BOLD;
+    } else if (markup.contains(Markup.THIN)) {
+      return BootstrapClass.FONT_WEIGHT_LIGHT;
+    } else if (markup.contains(Markup.ITALIC)) {
+      return BootstrapClass.FONT_ITALIC;
+    } else {
+      return null;
+    }
+  }
+
   public static class Generator {
 
     private static final BootstrapClass[] OFFSET_EXTRA_SMALL = new BootstrapClass[]{
diff --git a/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/020-output/10-out/out.xhtml
b/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/020-output/10-out/out.xhtml
index 601b90c..90a47de 100644
--- a/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/020-output/10-out/out.xhtml
+++ b/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/020-output/10-out/out.xhtml
@@ -38,6 +38,25 @@
               labelLayout="skip" plain="true"/>
     </tc:section>
   </tc:section>
+  <tc:section label="Markups">
+    <tc:segmentLayout extraSmall="4seg">
+      <tc:out value="thin" markup="thin"/>
+      <tc:out value="normal"/>
+      <tc:out value="bold" markup="bold"/>
+      <tc:out value="italic" markup="italic"/>
+    </tc:segmentLayout>
+    <tc:segmentLayout extraSmall="4seg">
+      <tc:out value="primary" markup="primary"/>
+      <tc:out value="secondary" markup="secondary"/>
+      <tc:out value="success" markup="success"/>
+      <tc:out value="danger" markup="danger"/>
+      <tc:out value="warning" markup="warning"/>
+      <tc:out value="info" markup="info"/>
+      <tc:out value="light" markup="light"/>
+      <tc:out value="dark" markup="dark"/>
+      <tc:out value="muted" markup="muted"/>
+    </tc:segmentLayout>
+  </tc:section>
   <tc:section label="Escape">
     <p>If the given string to the outputfield is HTML/XML code, it will be escaped
by default.
       But you can turn it off with the <code>escape</code> attribute.</p>
diff --git a/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/040-command/00-button+link/button+link.xhtml
b/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/040-command/00-button+link/button+link.xhtml
index b5834e8..e116863 100644
--- a/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/040-command/00-button+link/button+link.xhtml
+++ b/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/040-command/00-button+link/button+link.xhtml
@@ -20,7 +20,6 @@
                 xmlns:tc="http://myfaces.apache.org/tobago/component"
                 xmlns:ui="http://java.sun.com/jsf/facelets"
                 xmlns:f="http://java.sun.com/jsf/core"
-                xmlns:h="http://java.sun.com/jsf/html"
                 xmlns:demo="http://myfaces.apache.org/tobago/example/demo">
   <ui:param name="title" value="#{demoBundle.button_link} &lt;tc:link> &lt;tc:button>"/>
   <p>A classic link can be set with the <code class="language-markup">&lt;tc:link/></code>
tag.
@@ -141,8 +140,10 @@
   </tc:section>
 
   <tc:section id="markup" label="Markups">
-    <p>Colors can be set with markups. Markup <code>none</code> unset the
color.</p>
-    <pre><code class="language-markup">&lt;tc:button label="Primary" markup="primary"/>
+    <tc:segmentLayout medium="6seg">
+      <tc:box label="Buttons">
+        <p>Colors can be set with markups. Markup <code>none</code> unset
the color.</p>
+        <pre><code class="language-markup">&lt;tc:button label="Primary"
markup="primary"/>
 &lt;tc:button label="Secondary" markup="secondary"/>
 &lt;tc:button label="Success" markup="success"/>
 &lt;tc:button label="Danger" markup="danger"/>
@@ -151,15 +152,32 @@
 &lt;tc:button label="Light" markup="light"/>
 &lt;tc:button label="Dark" markup="dark"/>
 &lt;tc:button label="None" markup="none"/></code></pre>
-    <tc:button label="Primary" markup="primary"/>
-    <tc:button label="Secondary" markup="secondary"/>
-    <tc:button label="Success" markup="success"/>
-    <tc:button label="Danger" markup="danger"/>
-    <tc:button label="Warning" markup="warning"/>
-    <tc:button label="Info" markup="info"/>
-    <tc:button label="Light" markup="light"/>
-    <tc:button label="Dark" markup="dark"/>
-    <tc:button label="None" markup="none"/>
+        <tc:button label="Primary" markup="primary"/>
+        <tc:button label="Secondary" markup="secondary"/>
+        <tc:button label="Success" markup="success"/>
+        <tc:button label="Danger" markup="danger"/>
+        <tc:button label="Warning" markup="warning"/>
+        <tc:button label="Info" markup="info"/>
+        <tc:button label="Light" markup="light"/>
+        <tc:button label="Dark" markup="dark"/>
+        <tc:button label="None" markup="none"/>
+      </tc:box>
+      <tc:box label="Links">
+        <tc:link label="thin" markup="thin"/>
+        <tc:link label="normal"/>
+        <tc:link label="bold" markup="bold"/>
+        <tc:link label="italic" markup="italic"/>
+        <tc:separator/>
+        <tc:link label="Primary" markup="primary"/>
+        <tc:link label="Secondary" markup="secondary"/>
+        <tc:link label="Success" markup="success"/>
+        <tc:link label="Danger" markup="danger"/>
+        <tc:link label="Warning" markup="warning"/>
+        <tc:link label="Info" markup="info"/>
+        <tc:link label="Light" markup="light"/>
+        <tc:link label="Dark" markup="dark"/>
+      </tc:box>
+    </tc:segmentLayout>
   </tc:section>
 
   <tc:section label="Confirmation">


Mime
View raw message