
com.karasiq.bootstrap4.dropdown.UniversalDropdowns.scala Maven / Gradle / Ivy
package com.karasiq.bootstrap4.dropdown
import com.karasiq.bootstrap.context.RenderingContext
import com.karasiq.bootstrap4.utils.Utils
trait UniversalDropdowns { self: RenderingContext with Dropdowns with Utils ⇒
import scalaTags.all._
import BootstrapAttrs._
type Dropdown = AbstractDropdown
object Dropdown extends DropdownFactory {
def link(target: String, md: Modifier*): Tag = {
a(`class` := "dropdown-item", href := target, md)
}
def apply(title: Modifier, items: Modifier*): Dropdown = {
new UniversalDropdown(title, items)
}
}
private[dropdown] final class UniversalDropdown(val title: Modifier,
val items: Seq[Modifier],
val dropdownId: String = Bootstrap.newId)
extends AbstractDropdown {
def dropdown: Tag = {
div(`class` := "dropdown")(
Bootstrap.button(
"dropdown-toggle".addClass,
id := dropdownId,
`data-toggle` := "dropdown",
aria.haspopup := true,
aria.expanded := false,
title,
Bootstrap.nbsp,
span(`class` := "caret")
),
div(`class` := "dropdown-menu", aria.labelledby := dropdownId)(items:_*)
)
}
def dropup: Tag = this.dropdown(`class` := "dropup")
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy