Skip to content

Commit

Permalink
Merge pull request #37 from InkApplications/breadcrumbs
Browse files Browse the repository at this point in the history
Add Breadcrumbs in static renderer
  • Loading branch information
ReneeVandervelde authored Sep 21, 2024
2 parents c4d5a8e + 300b248 commit 3cffdf7
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 0 deletions.
4 changes: 4 additions & 0 deletions render-static-html/api/render-static-html.api
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ public abstract class ink/ui/render/statichtml/PartialScript : ink/ui/render/sta
public fun include (Ljava/lang/String;)V
}

public final class ink/ui/render/statichtml/renderer/BreadcrumbRendererKt {
public static final fun getBreadcrumbRenderer ()Link/ui/render/statichtml/renderer/ElementRenderer;
}

public final class ink/ui/render/statichtml/renderer/DividerRendererKt {
public static final fun getDividerRenderer ()Link/ui/render/statichtml/renderer/ElementRenderer;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class HtmlRenderer(
TextRenderer,
DividerRenderer,
FormattedTextRenderer,
BreadcrumbRenderer,
StatusRenderer(iconUrl),
IconRenderer(iconUrl),
LinkButtonRenderer(iconUrl)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package ink.ui.render.statichtml.renderer

import ink.ui.structures.elements.BreadcrumbElement
import kotlinx.html.*

val BreadcrumbRenderer = renderer<BreadcrumbElement> { element ->
nav {
ul {
element.items.forEach { breadcrumb ->
li {
a(href = breadcrumb.url) { +breadcrumb.text }
}
}
}
}
}
6 changes: 6 additions & 0 deletions sample-web/src/staticMain/header.inkui.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@

addPageHeader(TextElement("Page Header", TextStyle.H1))
addPageHeader(TextElement("Subtitle"))
addPageHeader(
BreadcrumbElement(listOf(
BreadcrumbElement.Breadcrumb("Home", "#"),
BreadcrumbElement.Breadcrumb("Guide", "#guide"),
))
)
24 changes: 24 additions & 0 deletions structures/api/structures.api
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,30 @@ public final class ink/ui/structures/TextStyle : java/lang/Enum {
public static fun values ()[Link/ui/structures/TextStyle;
}

public final class ink/ui/structures/elements/BreadcrumbElement : ink/ui/structures/elements/UiElement$Static {
public fun <init> (Ljava/util/List;)V
public final fun component1 ()Ljava/util/List;
public final fun copy (Ljava/util/List;)Link/ui/structures/elements/BreadcrumbElement;
public static synthetic fun copy$default (Link/ui/structures/elements/BreadcrumbElement;Ljava/util/List;ILjava/lang/Object;)Link/ui/structures/elements/BreadcrumbElement;
public fun equals (Ljava/lang/Object;)Z
public final fun getItems ()Ljava/util/List;
public fun hashCode ()I
public fun toString ()Ljava/lang/String;
}

public final class ink/ui/structures/elements/BreadcrumbElement$Breadcrumb {
public fun <init> (Ljava/lang/String;Ljava/lang/String;)V
public final fun component1 ()Ljava/lang/String;
public final fun component2 ()Ljava/lang/String;
public final fun copy (Ljava/lang/String;Ljava/lang/String;)Link/ui/structures/elements/BreadcrumbElement$Breadcrumb;
public static synthetic fun copy$default (Link/ui/structures/elements/BreadcrumbElement$Breadcrumb;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Link/ui/structures/elements/BreadcrumbElement$Breadcrumb;
public fun equals (Ljava/lang/Object;)Z
public final fun getText ()Ljava/lang/String;
public final fun getUrl ()Ljava/lang/String;
public fun hashCode ()I
public fun toString ()Ljava/lang/String;
}

public final class ink/ui/structures/elements/ButtonElement : ink/ui/structures/elements/UiElement$Interactive {
public synthetic fun <init> (Ljava/lang/String;Lkotlin/jvm/functions/Function0;Link/ui/structures/Sentiment;ZZLjava/lang/String;Ljava/lang/String;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
public synthetic fun <init> (Ljava/lang/String;Lkotlin/jvm/functions/Function0;Link/ui/structures/Sentiment;ZZLjava/lang/String;Ljava/lang/String;Lkotlin/jvm/internal/DefaultConstructorMarker;)V
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package ink.ui.structures.elements

data class BreadcrumbElement(
val items: List<Breadcrumb>,
): UiElement.Static {
data class Breadcrumb(
val text: String,
val url: String,
)
}

0 comments on commit 3cffdf7

Please sign in to comment.