Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Created Accordion functionality for Bootstrap
Added support for Bootstrap Button to add children Created Card support for Bootstrap Updated Component.id in HTMLComponent to be assigned to element.id
- Loading branch information
1 parent
d363968
commit 1caab48
Showing
8 changed files
with
169 additions
and
3 deletions.
There are no files selected for viewing
29 changes: 29 additions & 0 deletions
29
ui/js/src/main/scala/io/youi/component/bootstrap/Accordion.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package io.youi.component.bootstrap | ||
|
||
import io.youi.component.{Component, Container, HTMLContainer} | ||
import io.youi.dom | ||
import io.youi.theme.Theme | ||
import org.scalajs.dom.html | ||
|
||
class Accordion(element: html.Element) extends HTMLContainer[AccordionEntry](element) with BootstrapComponent[html.Element] { | ||
def this() = { | ||
this(dom.create[html.Div]("div")) | ||
} | ||
|
||
override protected def defaultParentTheme: Theme = Container | ||
override def componentType: String = "bootstrap.Accordion" | ||
|
||
override protected def init(): Unit = { | ||
super.init() | ||
|
||
element.classList.add("accordion") | ||
} | ||
|
||
def entry(header: Component, | ||
body: Component, | ||
element: html.Element = dom.create[html.Div]("div")): AccordionEntry = { | ||
val e = new AccordionEntry(this, header, body, element) | ||
children += e | ||
e | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
ui/js/src/main/scala/io/youi/component/bootstrap/AccordionEntry.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package io.youi.component.bootstrap | ||
|
||
import io.youi.component.{Component, Container} | ||
import io.youi.dom | ||
import io.youi.theme.Theme | ||
import org.scalajs.dom.html | ||
|
||
class AccordionEntry(accordion: Accordion, | ||
header: Component, | ||
body: Component, | ||
element: html.Element = dom.create[html.Div]("div")) extends Card(element) { | ||
override protected def defaultParentTheme: Theme = Container | ||
override def componentType: String = "bootstrap.AccordionEntry" | ||
|
||
override protected def init(): Unit = { | ||
super.init() | ||
|
||
val collapsible = new Container { | ||
classList += "collapse" | ||
data("parent") := s"#${accordion.id()}" | ||
children += new CardBody { | ||
children += body | ||
} | ||
} | ||
|
||
val cardHeader = new CardHeader { | ||
children += new Button { | ||
`type` := ButtonType.Link | ||
data("toggle") := "collapse" | ||
data("target") := s"#${collapsible.id()}" | ||
aria("expanded") := "false" | ||
aria("controls") := collapsible.id() | ||
children += header | ||
} | ||
} | ||
|
||
collapsible.aria("labelledby") := cardHeader.id() | ||
|
||
children += cardHeader | ||
children += collapsible | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
ui/js/src/main/scala/io/youi/component/bootstrap/Card.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package io.youi.component.bootstrap | ||
|
||
import io.youi.component.Container | ||
import io.youi.dom | ||
import io.youi.theme.Theme | ||
import org.scalajs.dom.html | ||
|
||
class Card(element: html.Element) extends Container(element) with BootstrapComponent[html.Element] { | ||
def this() = { | ||
this(dom.create[html.Div]("div")) | ||
} | ||
|
||
override protected def defaultParentTheme: Theme = Container | ||
override def componentType: String = "bootstrap.Card" | ||
|
||
override protected def init(): Unit = { | ||
super.init() | ||
|
||
element.classList.add("card") | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
ui/js/src/main/scala/io/youi/component/bootstrap/CardBody.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package io.youi.component.bootstrap | ||
|
||
import io.youi.component.Container | ||
import io.youi.dom | ||
import io.youi.theme.Theme | ||
import org.scalajs.dom.html | ||
|
||
class CardBody(element: html.Element) extends Container(element) with BootstrapComponent[html.Element] { | ||
def this() = { | ||
this(dom.create[html.Div]("div")) | ||
} | ||
|
||
override protected def defaultParentTheme: Theme = Container | ||
override def componentType: String = "bootstrap.CardBody" | ||
|
||
override protected def init(): Unit = { | ||
super.init() | ||
|
||
element.classList.add("card-body") | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
ui/js/src/main/scala/io/youi/component/bootstrap/CardHeader.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package io.youi.component.bootstrap | ||
|
||
import io.youi.component.Container | ||
import io.youi.dom | ||
import io.youi.theme.Theme | ||
import org.scalajs.dom.html | ||
|
||
class CardHeader(element: html.Element) extends Container(element) with BootstrapComponent[html.Element] { | ||
def this() = { | ||
this(dom.create[html.Div]("div")) | ||
} | ||
|
||
override protected def defaultParentTheme: Theme = Container | ||
override def componentType: String = "bootstrap.CardHeader" | ||
|
||
override protected def init(): Unit = { | ||
super.init() | ||
|
||
element.classList.add("card-header") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters