From 099f68be3c98308d8b5867787a1e267371944b93 Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Tue, 30 Jan 2018 10:22:24 +0200 Subject: [PATCH] Added Html utility for creating Tabs (Like on Performance tab) easily. --- .../djrapitops/plan/utilities/html/Html.java | 5 ++ .../utilities/html/structure/TabsElement.java | 70 +++++++++++++++++++ 2 files changed, 75 insertions(+) create mode 100644 Plan/src/main/java/com/djrapitops/plan/utilities/html/structure/TabsElement.java diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/html/Html.java b/Plan/src/main/java/com/djrapitops/plan/utilities/html/Html.java index fe6a68183..4752242d8 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/html/Html.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/html/Html.java @@ -51,6 +51,11 @@ public enum Html { DIV_W_CLASS_STYLE("
${2}
"), // ROW("
${0}
"), + CARD("
${0}
"), + BODY("
${0}
"), + PANEL("
${0}
"), + PANEL_BODY("
${0}
"), + // TABLE_END(""), TABLE(""), diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/html/structure/TabsElement.java b/Plan/src/main/java/com/djrapitops/plan/utilities/html/structure/TabsElement.java new file mode 100644 index 000000000..4b4342044 --- /dev/null +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/html/structure/TabsElement.java @@ -0,0 +1,70 @@ +/* + * Licence is provided in the jar as license.yml also here: + * https://github.com/Rsl1122/Plan-PlayerAnalytics/blob/master/Plan/src/main/resources/license.yml + */ +package com.djrapitops.plan.utilities.html.structure; + +import com.djrapitops.plugin.utilities.Format; + +/** + * Represents a structural HTML element that has Tabs on the top. + * + * @author Rsl1122 + */ +public class TabsElement { + + private final Tab[] tabs; + + public TabsElement(Tab... tabs) { + this.tabs = tabs; + } + + public String toHtml() { + StringBuilder nav = new StringBuilder(); + StringBuilder content = new StringBuilder(); + + nav.append(""); + + return nav.toString() + content.toString(); + } + + public static class Tab { + + private final String navText; + private final String contentHtml; + + public Tab(String navText, String contentHtml) { + this.navText = navText; + this.contentHtml = contentHtml; + } + + public String getNavText() { + return navText; + } + + public String getContentHtml() { + return contentHtml; + } + + public String getId() { + return "tab_" + new Format(navText).removeSymbols().removeWhitespace().lowerCase().toString(); + } + } +} \ No newline at end of file