Skip to content

Commit 99e161e

Browse files
committed
Material Badge Update on Links
1 parent a779c48 commit 99e161e

File tree

5 files changed

+48
-0
lines changed

5 files changed

+48
-0
lines changed

src/main/java/gwt/material/design/client/ui/MaterialBadge.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,18 @@ public MaterialBadge() {
4141
this.addStyleName("badge");
4242
this.addStyleName(MaterialResources.INSTANCE.materialcss().badge());
4343
}
44+
45+
46+
47+
public MaterialBadge(String text, String color) {
48+
setElement(DOM.createElement("SPAN"));
49+
setText(text);
50+
setColor(color);
51+
this.addStyleName("badge");
52+
this.addStyleName(MaterialResources.INSTANCE.materialcss().badge());
53+
}
54+
55+
4456

4557
@UiChild(tagname = "child")
4658
public void addWidget(final Widget item) {

src/main/java/gwt/material/design/client/ui/MaterialLink.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
import com.google.gwt.dom.client.Style.Cursor;
2626
import com.google.gwt.dom.client.Style.Unit;
27+
import com.google.gwt.uibinder.client.UiChild;
2728
import com.google.gwt.user.client.ui.Anchor;
2829
import com.google.gwt.user.client.ui.FocusPanel;
2930
import com.google.gwt.user.client.ui.HTMLPanel;
@@ -46,6 +47,7 @@ public class MaterialLink extends FocusPanel {
4647
private Widget container;
4748
private Anchor anchorElem;
4849
private CustomIcon iconElem;
50+
private MaterialBadge badge;
4951

5052
private boolean separator = false;
5153
private boolean active = false;
@@ -146,11 +148,19 @@ public void generateLink() {
146148
anchorElem.getElement().appendChild(iconElem.getElement());
147149
iconElem.addStyleName(icon);
148150
}
151+
if(getBadge()!=null) anchorElem.getElement().appendChild(getBadge().getElement());
149152
panel.add(anchorElem);
150153
panel.getElement().getStyle().setCursor(Cursor.POINTER);
151154
this.add(panel);
152155
}
153156

157+
@UiChild(tagname = "badge")
158+
public void addBadge(Widget w){
159+
MaterialBadge badge = ((MaterialBadge)w) ;
160+
badge.addStyleName("sideBarBadge");
161+
setBadge(badge);
162+
}
163+
154164
public String getWave() {
155165
return wave;
156166
}
@@ -248,4 +258,13 @@ public void setIconElem(CustomIcon iconElem) {
248258
this.iconElem = iconElem;
249259
}
250260

261+
public MaterialBadge getBadge() {
262+
return badge;
263+
}
264+
265+
public void setBadge(MaterialBadge badge) {
266+
this.badge = badge;
267+
}
268+
269+
251270
}

src/main/java/gwt/material/design/client/ui/MaterialNavBar.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626

2727
import com.google.gwt.core.client.GWT;
2828
import com.google.gwt.dom.client.Style.Display;
29+
import com.google.gwt.dom.client.Style.Unit;
2930
import com.google.gwt.resources.client.ImageResource;
3031
import com.google.gwt.uibinder.client.UiBinder;
3132
import com.google.gwt.uibinder.client.UiChild;
@@ -239,6 +240,7 @@ public String getSideBarWidth() {
239240
public void setSideBarWidth(String sideBarWidth) {
240241
this.sideBarWidth = sideBarWidth;
241242
mobileNav.setWidth(sideBarWidth + "px");
243+
navBar.getElement().getStyle().setPaddingLeft(Double.parseDouble(sideBarWidth), Unit.PX);
242244
}
243245

244246
public CustomHeader getNavBar() {

src/main/resources/gwt/material/design/client/resources/materialcss.gss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
}
1818

1919

20+
2021
.sideBarProfile{
2122
padding: 1%;
2223
margin-left: -20px;

src/main/resources/gwt/material/design/public/css/overridecss.css

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
color: rgba(0, 0, 0, 0.87);
1616
}
1717

18+
1819
/**SCROLLSPY**/
1920
.table-of-contents a.active{
2021
border-left: 2px solid #2196f3 !important;
@@ -89,6 +90,19 @@ ul.side-nav.fixed li:hover, ul.side-nav.fixed li.active {
8990
}
9091
}
9192

93+
.sideBarBadge{
94+
height: 20px !important;
95+
line-height: 0 !important;
96+
padding: 10px !important;
97+
color: #fff !important;
98+
border-radius: 3px !important;
99+
font-size: 0.7em !important;
100+
}
101+
ul.side-nav .sideBarBadge{
102+
margin-top: 20px !important;
103+
}
104+
/** DROPDOWN **/
105+
92106
.dropdown-content {
93107
max-height: 70vh !important;
94108
}

0 commit comments

Comments
 (0)