bug4338 Adjusted styles of language selection widget for better

reusability
This commit is contained in:
Benjamin Barth
2017-10-13 14:52:43 +02:00
parent e17e1dd121
commit 249bb6f54a
4 changed files with 23 additions and 14 deletions
@@ -43,6 +43,9 @@
.sitefooter_language {
text-align: left;
}
.sitefooter_language select {
background-color: #333;
}
@media (min-width: 45em) {
.sitefooter_language {
text-align: right;
@@ -16,6 +16,7 @@
}
.sitefooter_language select {
font-size: 110%;
background-color: #333;
}
.sitefooter_links {
font-weight: 600;
@@ -4,6 +4,7 @@ import java.util.List;
import java.util.Optional;
import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.Style.Display;
import com.google.gwt.http.client.UrlBuilder;
import com.google.gwt.i18n.client.LocaleInfo;
import com.google.gwt.text.shared.AbstractRenderer;
@@ -44,17 +45,25 @@ public class LanguageSelector extends Composite {
ValueListBox<String> languageSelectionUi;
/**
* Creates a new {@link LanguageSelector} instance using the provided label text.
* Creates a new {@link LanguageSelector} instance.
*/
@UiConstructor
public LanguageSelector() {
this.languageSelectionUi = new ValueListBox<>(new LanguageRenderer());
this.initWidget(uiBinder.createAndBindUi(this));
this.initLanguages(LocaleInfo.getCurrentLocale());
this.labelUi.getElement().getStyle().setDisplay(Display.NONE);
}
/**
* Sets the label text to use for this {@link LanguageSelector} instance.
*
* @param labelText
* {@link String text} to show in front of the link / selection
*/
@UiConstructor
public LanguageSelector(String labelText) {
languageSelectionUi = new ValueListBox<>(new LanguageRenderer());
initWidget(uiBinder.createAndBindUi(this));
public void setLabelText(String labelText) {
this.labelUi.getElement().getStyle().clearDisplay();
this.labelUi.setText(labelText);
this.initLanguages(LocaleInfo.getCurrentLocale());
}
private void initLanguages(final LocaleInfo currentLocale) {
@@ -7,7 +7,7 @@
.label:after {
content: ":";
}
.languageSwichLink {
.languageSwichLink, .languageSelection {
color: #efaa00;
cursor: pointer;
}
@@ -19,22 +19,18 @@
-moz-appearance: none;
-ms-appearance: none;
appearance: none;
margin-top: 25px;
color: #efaa00;
line-height: 1.5em;
height: 1.5em;
display: inline-block;
border: transparent;
cursor: pointer;
padding-right: 1.2em;
background: #333;
cursor: pointer;
background-image:url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0naHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmcnIHZlcnNpb249JzEuMScgaGVpZ2h0PScxOHB4JyB3aWR0aD0nMTZweCc+PHRleHQgeD0nMCcgeT0nMTUnIGZpbGw9JyNlZmFhMDAnIGZvbnQtc2l6ZT0nMTYnPiYjOTY2MDs8L3RleHQ+PC9zdmc+");
background: transparent;
background-image: url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0naHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmcnIHZlcnNpb249JzEuMScgaGVpZ2h0PScxOHB4JyB3aWR0aD0nMTZweCc+PHRleHQgeD0nMCcgeT0nMTUnIGZpbGw9JyNlZmFhMDAnIGZvbnQtc2l6ZT0nMTYnPiYjOTY2MDs8L3RleHQ+PC9zdmc+");
background-position: right center;
background-repeat: no-repeat;
}
</ui:style>
<g:FlowPanel>
<g:FlowPanel tag="span">
<g:InlineLabel ui:field="labelUi" addStyleNames="{style.label}"/>
<g:Anchor ui:field="languageSwitchLinkUi" styleName="{style.languageSwichLink}"/>
<g:ValueListBox ui:field="languageSelectionUi" addStyleNames="{style.languageSelection}"/>