# HG changeset patch # User Tomas Zeman # Date 1498159179 -7200 # Node ID 33ec811608b21d8e27246f4a7c298ed12f1bf0c4 # Parent 1ff4ef98bbfb9d69fbe233ea4026acfdfaee187f uibTabs: tab dsl diff -r 1ff4ef98bbfb -r 33ec811608b2 shared/src/main/scala/twbsTags.scala --- a/shared/src/main/scala/twbsTags.scala Tue Jun 13 15:51:23 2017 +0200 +++ b/shared/src/main/scala/twbsTags.scala Thu Jun 22 21:19:39 2017 +0200 @@ -1,5 +1,5 @@ /* - * Copyright 2015-2016 Tomas Zeman + * Copyright 2015-2017 Tomas Zeman * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,6 +15,7 @@ */ package net.tz.ngtags +import scala.language.implicitConversions import scalatags.Text.all._ @deprecated("Use uibAccordion", "0.5") @@ -64,7 +65,25 @@ } object uibTabs { - val tabset = tag("uib-tabset") + + implicit def ts2tag(x: Tabset): ConcreteHtmlTag[String] = x() + + case class Tab(heading: Seq[Modifier], content: Seq[Modifier]) + + case class Tabset(activeE: String, _tabs: Seq[Tab] = Nil, _justified: Option[Boolean] = None) { + def justified(b: Boolean): Tabset = copy(_justified = Some(b)) + def justified: Tabset = justified(true) + def tab(heading: Modifier*) = new { + def content(xs: Modifier*): Tabset = copy(_tabs = _tabs :+ Tab(heading, xs)) + } + def emptyTab(heading: Modifier*): Tabset = tab(heading).content() + + def apply(xs: Modifier*) = + tag("uib-tabset")(attr("active"):=activeE, _justified.map(attr("justified"):=_), xs, + _tabs.map {t => tag("uib-tab")(tag("uib-tab-heading")(t.heading), t.content)}) + } + + def tabset(activeExpr: String) = Tabset(activeExpr) val tab = tag("uib-tab") val tabHeading = tag("uib-tab-heading") val heading = attr("heading")