]> source.dussan.org Git - vaadin-framework.git/commitdiff
New Tree component theme
authorIlia Motornyi <elmot@vaadin.com>
Tue, 23 May 2017 12:10:45 +0000 (15:10 +0300)
committerGitHub <noreply@github.com>
Tue, 23 May 2017 12:10:45 +0000 (15:10 +0300)
Fixes #9310

client/src/main/java/com/vaadin/client/connectors/grid/TreeRendererConnector.java
server/src/main/java/com/vaadin/ui/Tree.java
themes/src/main/themes/VAADIN/themes/valo/components/_tree8.scss
uitest/src/test/java/com/vaadin/tests/components/tree/TreeBasicFeaturesTest.java

index 4540ce5d630a381dfc670bdb64078c5102d62c83..df0da24e99c08117da5064372aa5293b4c06895b 100644 (file)
@@ -42,7 +42,9 @@ public class TreeRendererConnector
 
             @Override
             public void render(RendererCellReference cell, String htmlString) {
-                String content = SafeHtmlUtils.htmlEscape(htmlString);
+                String content = "<span class=\"v-captiontext\">" +
+                        SafeHtmlUtils.htmlEscape(htmlString)
+                        + "</span>";
 
                 JsonObject row = getParent().getParent().getDataSource()
                         .getRow(cell.getRowIndex());
@@ -50,7 +52,7 @@ public class TreeRendererConnector
                     String resourceId = row.getString("itemIcon");
                     Element element = getConnection()
                             .getIcon(getResourceUrl(resourceId)).getElement();
-                    content = element.getString() + " " + content;
+                    content = element.getString() + content;
                 }
                 super.render(cell, content);
             }
index 998c61cf188308abbe589cd0c706c674d4fd5c7c..aaff872c95874d6798f9cd002aec847d892ab9c4 100644 (file)
@@ -233,6 +233,7 @@ public class Tree<T> extends Composite
             treeGrid.removeHeaderRow(0);
         }
         treeGrid.setPrimaryStyleName("v-tree8");
+        treeGrid.setRowHeight(28);
 
         setWidth("100%");
         treeGrid.setHeightUndefined();
index 8838e7b4e261019f274ef0920b6fc92e6dd91be8..1b4405cdbd3bce26dc5b31e0faa4830be95d39e0 100644 (file)
@@ -1,18 +1,22 @@
 @import "treegrid";
 
-$v-tree8-border-radius: 3px;
-
-@mixin valo-tree8 ($primary-stylename: v-tree8) {
+@mixin valo-tree8($primary-stylename: v-tree8) {
 
   @include valo-treegrid($primary-stylename);
 
+  $tree-sel-bg: $v-grid-row-selected-background-color;
+
   .#{$primary-stylename} {
     background-color: transparent;
   }
 
   .#{$primary-stylename}-row > td {
     background-color: transparent;
-    border: none;
+    border: 0;
+    line-height: 28px;
+    > * {
+      vertical-align: baseline;
+    }
   }
 
   .#{$primary-stylename}-tablewrapper {
@@ -20,43 +24,41 @@ $v-tree8-border-radius: 3px;
     border: none;
   }
 
-  .#{$primary-stylename}-row-selected  > .#{$primary-stylename}-cell {
-    background-color: transparent;
-    background-image: none;
-    color: inherit;
-    text-shadow: none;
-    border: none;
-  }
-
-  .#{$primary-stylename}-cell-content {
-    border: $v-grid-cell-focused-border;
-    border-color: transparent;
-    border-radius: $v-tree8-border-radius;
-    padding: $v-grid-cell-padding;
-  }
-
-  .#{$primary-stylename}:focus .#{$primary-stylename}-row-focused:before {
-    display: none;
+  .#{$primary-stylename}-row {
+    &::before {
+      content: "";
+      display: none;
+      position: absolute;
+      top: 0;
+      left: 0;
+      box-sizing: border-box;
+      width: 100%;
+      height: 100%;
+      border-radius: $v-border-radius;
+      pointer-events: none;
+      border-width: 1px;
+    }
   }
 
-  .#{$primary-stylename}:focus .#{$primary-stylename}-cell-focused
-    > .#{$primary-stylename}-node > .#{$primary-stylename}-cell-content {
-    border: $v-grid-cell-focused-border;
+  .#{$primary-stylename}-cell {
+    position: relative;
   }
 
   // Selected
   .#{$primary-stylename}-row-selected {
-    $grid-sel-bg: $v-grid-row-selected-background-color;
 
-    > .#{$primary-stylename}-cell > .#{$primary-stylename}-node > .#{$primary-stylename}-cell-content {
-      @include valo-gradient($grid-sel-bg);
-      color: valo-font-color($grid-sel-bg);
-      text-shadow: valo-text-shadow($font-color: valo-font-color($grid-sel-bg), $background-color: $grid-sel-bg);
-      border-color: adjust-color($grid-sel-bg, $lightness: -8%, $saturation: -8%);
+    > .#{$primary-stylename}-cell {
+      background: transparent;
     }
 
-    > .#{$primary-stylename}-cell-focused > .#{$primary-stylename}-node > .#{$primary-stylename}-cell-content {
-      border-color: adjust-color($grid-sel-bg, $lightness: 20%);
+    &::before {
+      display: block;
+      @include valo-gradient($tree-sel-bg);
     }
   }
+
+  .#{$primary-stylename}:focus .#{$primary-stylename}-row-selected.#{$primary-stylename}-row-focused::before {
+    border-color: transparent;
+    box-shadow: inset 0 0 0 1px valo-font-color($tree-sel-bg);
+  }
 }
index bde38a963a70ce935a016e31f444ebd98306d231..d65523d6eccb656473cb71fffe7cfcc288600648 100644 (file)
@@ -92,7 +92,7 @@ public class TreeBasicFeaturesTest extends MultiBrowserTest {
 
             for (int j = 0; j < 3; ++j) {
                 item = tree.getItem(n++);
-                Assert.assertEquals((shouldHaveIcon ? "юдн " : "") + "1 | " + j,
+                Assert.assertEquals((shouldHaveIcon ? "\ue92d" : "") + "1 | " + j,
                         item.getText());
 
                 Assert.assertEquals("Unexpected icon state", shouldHaveIcon,