Skip to content

Commit

Permalink
refactor: improve getLocaleRenderer readability
Browse files Browse the repository at this point in the history
  • Loading branch information
elPeiretti committed Aug 2, 2024
1 parent 87a6fb8 commit c2fc867
Showing 1 changed file with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,14 @@ public LocaleComboBox() {

private LitRenderer<Locale> getLocaleRenderer() {
return LitRenderer
.<Locale>of("<vaadin-horizontal-layout class=\"" + ITEM_LAYOUT_CLASS_NAME + "\">"
+ "<span class=\"fi fi-${item.countryCode} " + ITEM_FLAG_CLASS_NAME
+ "\" alt=\"${item.countryName}\'s flag\"></span>" + "<span>${item.displayName}</span>"
+ "</vaadin-horizontal-layout>")
.<Locale>of(
"""
<vaadin-horizontal-layout class="${item.layoutClass}">
<span class="fi fi-${item.countryCode} ${item.flagClass} alt="${item.countryName}'s flag"></span>
<span>${item.displayName}</span>
</vaadin-horizontal-layout>""")
.withProperty("layoutClass", loc -> ITEM_LAYOUT_CLASS_NAME)
.withProperty("flagClass", loc -> ITEM_FLAG_CLASS_NAME)
.withProperty("countryCode", loc -> loc.getCountry().toLowerCase())
.withProperty("countryName", loc -> loc.getDisplayCountry())
.withProperty("displayName", loc -> loc.getDisplayName());
Expand Down

0 comments on commit c2fc867

Please sign in to comment.