Skip to content

Commit a7c9786

Browse files
elPeirettipaodb
authored andcommitted
refactor: improve getLocaleRenderer readability
1 parent 870e973 commit a7c9786

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/main/java/com/flowingcode/vaadin/addons/localecombobox/LocaleComboBox.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,14 @@ public LocaleComboBox() {
5656

5757
private LitRenderer<Locale> getLocaleRenderer() {
5858
return LitRenderer
59-
.<Locale>of("<vaadin-horizontal-layout class=\"" + ITEM_LAYOUT_CLASS_NAME + "\">"
60-
+ "<span class=\"fi fi-${item.countryCode} " + ITEM_FLAG_CLASS_NAME
61-
+ "\" alt=\"${item.countryName}\'s flag\"></span>" + "<span>${item.displayName}</span>"
62-
+ "</vaadin-horizontal-layout>")
59+
.<Locale>of(
60+
"""
61+
<vaadin-horizontal-layout class="${item.layoutClass}">
62+
<span class="fi fi-${item.countryCode} ${item.flagClass} alt="${item.countryName}'s flag"></span>
63+
<span>${item.displayName}</span>
64+
</vaadin-horizontal-layout>""")
65+
.withProperty("layoutClass", loc -> ITEM_LAYOUT_CLASS_NAME)
66+
.withProperty("flagClass", loc -> ITEM_FLAG_CLASS_NAME)
6367
.withProperty("countryCode", loc -> loc.getCountry().toLowerCase())
6468
.withProperty("countryName", loc -> loc.getDisplayCountry())
6569
.withProperty("displayName", loc -> loc.getDisplayName());

0 commit comments

Comments
 (0)