Skip to content
This repository has been archived by the owner on Aug 10, 2024. It is now read-only.

Commit

Permalink
clean up DSL a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
sanity committed Jan 27, 2017
1 parent cbdebf3 commit 6c3ff0d
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ import com.github.sanity.kweb.plugins.materialdesignlite.MDLElement

fun MDLElement.list(attributes: Map<String, Any> = attr) = MDLUlElement(ul(attributes.classes("mdl-list")))

class MDLUlElement(wrapped: ULElement) : ULElement(wrapped) {
fun item(attributes: Map<String, Any> = attr, type: ListItemType = ListItemType.oneLine) = MDLItemElement(super.li(attributes
class MDLUlElement(wrapped: ULElement) : MDLElement(wrapped) {
fun item(attributes: Map<String, Any> = attr, type: ListItemType = ListItemType.oneLine)
= MDLItemElement(createElement("li", attributes
.classes("mdl-list__item")
.classes("mdl-list__item--two-line", onlyIf = type == ListItemType.twoLine)
.classes("mdl-list__item--three-line", onlyIf = type == ListItemType.threeLine)
Expand All @@ -24,7 +25,7 @@ enum class ListItemType {
oneLine, twoLine, threeLine
}

class MDLItemElement(wrapped: Element, val type: ListItemType) : Element(wrapped) {
class MDLItemElement(wrapped: Element, val type: ListItemType) : MDLElement(wrapped) {
fun primaryContent(attributes: Map<String, Any> = attr) = MDLItemElement(span(attributes.classes("mdl-list__item-primary-content")), type)
fun avatar(attributes: Map<String, Any> = attr) = MDLItemElement(i(attributes.classes("mdl-list__item-avatar")), type)
fun icon(attributes: Map<String, Any> = attr) = MDLItemElement(i(attributes.classes("material-icons", "mdl-list__item-icon")), type)
Expand Down

0 comments on commit 6c3ff0d

Please sign in to comment.