mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2025-03-10 05:39:19 +01:00
Split plugin tab icon and title in the code
Affects issues: - Fixed #1933
This commit is contained in:
parent
b8b24c07c6
commit
9affbda220
@ -16,6 +16,7 @@
|
||||
*/
|
||||
package com.djrapitops.plan.delivery.rendering.html.structure;
|
||||
|
||||
import com.djrapitops.plan.delivery.rendering.html.icon.Icon;
|
||||
import org.apache.commons.lang3.RegExUtils;
|
||||
|
||||
/**
|
||||
@ -45,12 +46,12 @@ public class TabsElement {
|
||||
boolean first = true;
|
||||
for (Tab tab : tabs) {
|
||||
String id = tab.getId();
|
||||
String navText = tab.getNavText();
|
||||
String navHtml = tab.getNavHtml();
|
||||
String contentHtml = tab.getContentHtml();
|
||||
|
||||
nav.append("<li role=\"presentation\" class=\"nav-item col-black\"")
|
||||
.append("><a href=\"#").append(id).append("\" class=\"nav-link col-black").append(first ? " active" : "").append('"').append(" data-toggle=\"tab\">")
|
||||
.append(navText).append("</a></li>");
|
||||
.append(navHtml).append("</a></li>");
|
||||
content.append("<div role=\"tabpanel\" class=\"tab-pane fade").append(first ? " in active show" : "")
|
||||
.append("\" id=\"").append(id).append("\">")
|
||||
.append(contentHtml).append("</div>");
|
||||
@ -64,16 +65,18 @@ public class TabsElement {
|
||||
|
||||
public static class Tab {
|
||||
|
||||
private final String navText;
|
||||
private final Icon icon;
|
||||
private final String title;
|
||||
private final String contentHtml;
|
||||
|
||||
public Tab(String navText, String contentHtml) {
|
||||
this.navText = navText;
|
||||
public Tab(Icon icon, String title, String contentHtml) {
|
||||
this.icon = icon;
|
||||
this.title = title;
|
||||
this.contentHtml = contentHtml;
|
||||
}
|
||||
|
||||
public String getNavText() {
|
||||
return navText;
|
||||
public String getNavHtml() {
|
||||
return icon.toHtml() + ' ' + title;
|
||||
}
|
||||
|
||||
public String getContentHtml() {
|
||||
@ -81,7 +84,7 @@ public class TabsElement {
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return "tab_" + RegExUtils.removeAll(navText, "[^a-zA-Z0-9]*").toLowerCase();
|
||||
return "tab_" + RegExUtils.removeAll(title, "[^a-zA-Z0-9]*").toLowerCase();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -147,10 +147,8 @@ public class PlayerPluginTab implements Comparable<PlayerPluginTab> {
|
||||
String tabContentHtml = buildContentHtml(tabData);
|
||||
|
||||
String tabName = tabInformation.getTabName();
|
||||
return new TabsElement.Tab(tabName.isEmpty()
|
||||
? Icon.called("info-circle").build().toHtml() + " General"
|
||||
: Icon.fromExtensionIcon(tabInformation.getTabIcon()).toHtml() + ' ' + tabName,
|
||||
tabContentHtml);
|
||||
return tabName.isEmpty() ? new TabsElement.Tab(Icon.called("info-circle").build(), "General", tabContentHtml)
|
||||
: new TabsElement.Tab(Icon.fromExtensionIcon(tabInformation.getTabIcon()), tabName, tabContentHtml);
|
||||
}
|
||||
|
||||
private String buildContentHtml(ExtensionTabData tabData) {
|
||||
|
@ -172,10 +172,8 @@ public class ServerPluginTabs {
|
||||
String tabContentHtml = buildContentHtml(tabData);
|
||||
|
||||
String tabName = tabInformation.getTabName();
|
||||
return new TabsElement.Tab(tabName.isEmpty()
|
||||
? Icon.called("info-circle").build().toHtml() + " General"
|
||||
: Icon.fromExtensionIcon(tabInformation.getTabIcon()).toHtml() + ' ' + tabName,
|
||||
tabContentHtml);
|
||||
return tabName.isEmpty() ? new TabsElement.Tab(Icon.called("info-circle").build(), "General", tabContentHtml)
|
||||
: new TabsElement.Tab(Icon.fromExtensionIcon(tabInformation.getTabIcon()), tabName, tabContentHtml);
|
||||
}
|
||||
|
||||
private String buildContentHtml(ExtensionTabData tabData) {
|
||||
|
Loading…
Reference in New Issue
Block a user