Skip to content

Commit 7f82136

Browse files
committed
Additional OUTLINED Type.
Fixed IE11 and Safari Issues (WIP)
1 parent 7bd152a commit 7f82136

File tree

9 files changed

+176
-20
lines changed

9 files changed

+176
-20
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package gwt.material.design.client.base;
2+
3+
public interface HasRawValue {
4+
5+
void setRawValue(String rawValue);
6+
7+
String getRawValue();
8+
}

gwt-material/src/main/java/gwt/material/design/client/constants/ButtonType.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ public enum ButtonType implements CssType {
3131
LINK(""),
3232
RAISED("btn"),
3333
FLAT("btn-flat"),
34+
OUTLINED("btn btn-outlined"),
3435
FLOATING("btn-floating");
3536

3637
private final String cssClass;
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/*
2+
* #%L
3+
* GwtMaterial
4+
* %%
5+
* Copyright (C) 2015 - 2017 GwtMaterialDesign
6+
* %%
7+
* Licensed under the Apache License, Version 2.0 (the "License");
8+
* you may not use this file except in compliance with the License.
9+
* You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS,
15+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* See the License for the specific language governing permissions and
17+
* limitations under the License.
18+
* #L%
19+
*/
20+
package gwt.material.design.client.constants;
21+
22+
import gwt.material.design.client.base.helper.EnumHelper;
23+
24+
/**
25+
* Types of Chip.<br>
26+
*
27+
* @author kevzlou7979
28+
* @author Ben Dol
29+
*/
30+
public enum ChipType implements CssType {
31+
DEFAULT(""),
32+
OUTLINED("outlined");
33+
34+
private final String cssClass;
35+
36+
ChipType(final String cssClass) {
37+
this.cssClass = cssClass;
38+
}
39+
40+
@Override
41+
public String getCssName() {
42+
return cssClass;
43+
}
44+
45+
public static ChipType fromStyleName(final String styleName) {
46+
return EnumHelper.fromStyleName(styleName, ChipType.class, DEFAULT);
47+
}
48+
}

gwt-material/src/main/java/gwt/material/design/client/ui/MaterialChip.java

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,10 @@
2626
import com.google.gwt.event.logical.shared.HasCloseHandlers;
2727
import com.google.gwt.event.shared.HandlerRegistration;
2828
import com.google.gwt.resources.client.ImageResource;
29+
import com.google.gwt.safehtml.shared.SafeHtmlUtils;
2930
import com.google.gwt.user.client.ui.HasValue;
30-
import com.google.gwt.user.client.ui.Image;
31-
import gwt.material.design.client.base.AbstractValueWidget;
32-
import gwt.material.design.client.base.HasIcon;
33-
import gwt.material.design.client.base.HasImage;
34-
import gwt.material.design.client.base.HasLetter;
31+
import gwt.material.design.client.base.*;
32+
import gwt.material.design.client.base.mixin.CssTypeMixin;
3533
import gwt.material.design.client.base.mixin.ImageMixin;
3634
import gwt.material.design.client.base.mixin.LetterMixin;
3735
import gwt.material.design.client.constants.*;
@@ -62,14 +60,16 @@
6260
* @see <a href="https://material.io/guidelines/components/chips.html">Material Design Specification</a>
6361
*/
6462
//@formatter:on
65-
public class MaterialChip extends AbstractValueWidget<String> implements HasImage, HasIcon, HasLetter, HasValue<String>, HasCloseHandlers {
63+
public class MaterialChip extends AbstractTextWidget implements HasImage, HasIcon, HasLetter,
64+
HasValue<String>, HasCloseHandlers, HasType<ChipType> {
6665

6766
private MaterialIcon icon = new MaterialIcon(IconType.CLOSE);
6867
private Span chipLabel = new Span();
6968
private MaterialImage image = new MaterialImage();
7069

7170
private ImageMixin<MaterialImage> imageMixin;
7271
private LetterMixin<MaterialChip> letterMixin;
72+
private CssTypeMixin<ChipType, MaterialChip> typeMixin;
7373

7474
public MaterialChip() {
7575
super(Document.get().createDivElement(), CssName.CHIP);
@@ -132,7 +132,7 @@ public void setValue(String value, boolean fireEvents) {
132132

133133
@Override
134134
public String getValue() {
135-
return chipLabel.getElement().getInnerText();
135+
return SafeHtmlUtils.fromString(chipLabel.getElement().getInnerText()).asString();
136136
}
137137

138138
@Override
@@ -228,6 +228,16 @@ public void setLetterBackgroundColor(Color letterBackgroundColor) {
228228
getLetterMixin().setLetterBackgroundColor(letterBackgroundColor);
229229
}
230230

231+
@Override
232+
public void setType(ChipType type) {
233+
getTypeMixin().setType(type);
234+
}
235+
236+
@Override
237+
public ChipType getType() {
238+
return getTypeMixin().getType();
239+
}
240+
231241
public MaterialImage getImage() {
232242
return image;
233243
}
@@ -258,4 +268,11 @@ protected ImageMixin<MaterialImage> getImageMixin() {
258268
}
259269
return imageMixin;
260270
}
271+
272+
public CssTypeMixin<ChipType, MaterialChip> getTypeMixin() {
273+
if (typeMixin == null) {
274+
typeMixin = new CssTypeMixin<>(this);
275+
}
276+
return typeMixin;
277+
}
261278
}

gwt-material/src/main/java/gwt/material/design/client/ui/html/Code.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,6 @@ public Code(final String text) {
4040

4141
@Override
4242
public void setHTML(String html) {
43-
this.getElement().setInnerHTML(CodeHelper.parseCode(html).asString());
43+
this.getElement().setInnerHTML(html);
4444
}
4545
}

gwt-material/src/main/java/gwt/material/design/client/ui/html/Pre.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,6 @@ public Pre(final String text) {
4141

4242
@Override
4343
public void setHTML(String html) {
44-
getElement().setInnerSafeHtml(SafeHtmlUtils.fromString(html));
44+
getElement().setInnerHTML(html);
4545
}
4646
}

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

Lines changed: 79 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ nav ul a span.badge {
5252

5353
.side-nav .badge {
5454
float: right;
55+
top: 22px;
5556
}
5657

5758
.sideBarBadge {
@@ -231,6 +232,15 @@ i.disabled:hover {
231232
text-align: center;
232233
}
233234

235+
/** Outlined Chips (MD2) **/
236+
.chip.outlined,
237+
.chip.outlined:hover,
238+
.chip.outlined:active,
239+
.chip.outlined:focus {
240+
border: 1px solid #0000001e;
241+
background-color: transparent;
242+
}
243+
234244
/** Collapsible **/
235245
.collapsible-body {
236246
margin: 0;
@@ -361,6 +371,10 @@ table .gwt-CheckBox label {
361371
padding: 0 !important;
362372
}
363373

374+
.picker .picker__select--year.browser-default {
375+
width: 26%;
376+
}
377+
364378
/** Dropdown **/
365379
ul.dropdown-content {
366380
max-height: 70vh !important;
@@ -424,6 +438,21 @@ ul.dropdown-content {
424438
box-shadow: 0 1px 0 0 #4CAF50 !important;
425439
}
426440

441+
/** Outlined Button (MD2) **/
442+
button.btn-outlined,
443+
button.btn-outlined:hover,
444+
button.btn-outlined:focus,
445+
button.btn-outlined:active {
446+
border: 1px solid #0000001e;
447+
box-shadow: none;
448+
background-color: white;
449+
color: #000;
450+
}
451+
452+
button.btn-outlined.disabled {
453+
background-color: transparent !important;
454+
}
455+
427456
/** Floating Action Button **/
428457
.horizontal.fixed-action-btn ul {
429458
left: auto;
@@ -496,6 +525,19 @@ footer.fixed {
496525
left: 0px;
497526
}
498527

528+
.row .col.input-field {
529+
min-height: 72px;
530+
margin-bottom: 0px;
531+
}
532+
533+
.row .col.input-field textarea {
534+
margin-bottom: 4px;
535+
}
536+
537+
.row .col.input-field input {
538+
margin-bottom: 8px;
539+
}
540+
499541
.row > .input-field label {
500542
left: 0.75rem !important;
501543
}
@@ -506,6 +548,11 @@ footer.fixed {
506548
}
507549
}
508550

551+
/** IE Fixed for having the huge clear button **/
552+
.input-field input::-ms-clear {
553+
display: none;
554+
}
555+
509556
/** Autofill fixed layout **/
510557
input:-webkit-autofill + label {
511558
font-size: 0.8rem !important;
@@ -597,8 +644,11 @@ input:-webkit-autofill {
597644
padding-top: 18px;
598645
}
599646

600-
.input-field.filled textarea {
647+
.input-field.filled textarea,
648+
.input-field.outlined textarea {
601649
padding-left: 12px;
650+
width: calc(100% - 24px);
651+
padding-right: 12px;
602652
}
603653

604654
.input-field.filled input:focus {
@@ -639,16 +689,12 @@ input:-webkit-autofill {
639689
border: 1px solid rgba(0, 0, 0, 0.12);
640690
}
641691

642-
.input-field.outlined textarea {
643-
padding-left: 12px;
644-
}
645-
646692
.input-field.outlined input.select-dropdown {
647693
padding-left: 12px;
648694
}
649695

650696
.input-field.outlined .select-wrapper + label {
651-
top: -12px;
697+
top: -10px;
652698
background: white;
653699
padding-left: 4px;
654700
padding-right: 4px;
@@ -692,14 +738,12 @@ input:-webkit-autofill {
692738
.input-field.outlined input.valid.picker__input--active {
693739
border: 2px solid #4caf50;
694740
box-shadow: none;
695-
margin-bottom: 8px;
696741
}
697742

698743
.input-field.outlined .field-error-label,
699744
.input-field.outlined .field-success-label,
700-
.input-field.outlined .field-helper-label{
745+
.input-field.outlined .field-helper-label {
701746
margin-left: 14px;
702-
margin-bottom: 12px;
703747
}
704748

705749
.input-field.field-error.listbox-wrapper.outlined input.select-dropdown {
@@ -723,6 +767,32 @@ input:-webkit-autofill {
723767
transform: translateY(0);
724768
}
725769

770+
.input-field .select-wrapper.gwt-ListBox .caret:before {
771+
content: "";
772+
position: absolute;
773+
right: 8px;
774+
bottom: 12px;
775+
width: 0;
776+
height: 0;
777+
border-style: solid;
778+
border-width: 0 0 12px 12px;
779+
border-color: transparent transparent #9c9c9c transparent;
780+
}
781+
782+
.input-field.aligned-label .select-wrapper.gwt-ListBox .caret:before {
783+
bottom: 26px;
784+
}
785+
786+
.input-field .select-wrapper.gwt-ListBox .caret.disabled:before {
787+
border-color: transparent transparent #c7c7c7 transparent;
788+
}
789+
790+
.input-field .select-wrapper.gwt-ListBox .caret.disabled,
791+
.input-field .select-wrapper .caret {
792+
color: transparent;
793+
bottom: 0;
794+
}
795+
726796
.input-field.listbox-wrapper {
727797
border-bottom: none !important;
728798
box-shadow: none !important;

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

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

gwt-material/src/test/java/gwt/material/design/client/ui/base/AbstractButtonTest.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,12 @@ public void testType() {
7373
widget.setType(ButtonType.FLOATING);
7474
assertEquals(ButtonType.FLOATING, widget.getType());
7575

76+
widget.setType(ButtonType.RAISED);
77+
assertEquals(ButtonType.RAISED, widget.getType());
78+
79+
widget.setType(ButtonType.OUTLINED);
80+
assertEquals(ButtonType.OUTLINED, widget.getType());
81+
7682
// Standard
7783
// given
7884
attachWidget();
@@ -81,9 +87,15 @@ public void testType() {
8187
final Element element = widget.getElement();
8288
widget.setType(ButtonType.FLAT);
8389
assertTrue(element.hasClassName(ButtonType.FLAT.getCssName()));
90+
8491
widget.setType(ButtonType.FLOATING);
8592
assertTrue(element.hasClassName(ButtonType.FLOATING.getCssName()));
86-
assertFalse(element.hasClassName(ButtonType.FLAT.getCssName()));
93+
94+
widget.setType(ButtonType.RAISED);
95+
assertTrue(element.hasClassName(ButtonType.RAISED.getCssName()));
96+
97+
widget.setType(ButtonType.OUTLINED);
98+
assertTrue(element.hasClassName(ButtonType.OUTLINED.getCssName()));
8799
}
88100

89101
public void testActivates() {

0 commit comments

Comments
 (0)