Skip to content

Importless css #450

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import japgolly.scalajs.benchmark._
import japgolly.scalajs.benchmark.gui._
import scalatags.JsDom.all._

object CssStylesApply extends CssView {
object CssStylesApply {

val styles = Benchmark("three styles") {
div(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import scalatags.JsDom.all._
final class DismissibleUdashAlert private[alert](
alertStyle: ReadableProperty[BootstrapStyles.Color], override val componentId: ComponentId
)(content: Binding.NestedInterceptor => Modifier) extends UdashAlertBase(alertStyle, componentId) {
import io.udash.css.CssView._

private val _dismissed = Property[Boolean](false)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ package alert
import io.udash._
import io.udash.bindings.modifiers.Binding
import io.udash.bootstrap.utils.{BootstrapStyles, UdashBootstrapComponent}
import io.udash.css.CssView._
import io.udash.wrappers.jquery.{JQuery, jQ}
import org.scalajs.dom.html.Div
import scalatags.JsDom.TypedTag
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ class UdashBadge private[badge](
)(content: Binding.NestedInterceptor => Modifier)
extends UdashBootstrapComponent {

import io.udash.css.CssView._

protected def baseTag: TypedTag[Element] = span

override val render: Element = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ final class UdashBreadcrumbs[ItemType, ElemType <: ReadableProperty[ItemType]] p
isActive: ItemType => Boolean
) extends UdashBootstrapComponent {

import io.udash.css.CssView._

override val render: Element = {
import scalatags.JsDom.all._
import scalatags.JsDom.tags2.nav
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ final class UdashButton private(
override val componentId: ComponentId,
tag: UdashButton.ButtonTag
)(content: Binding.NestedInterceptor => Modifier) extends UdashBootstrapComponent with Listenable[UdashButton, ButtonClickEvent] {
import io.udash.css.CssView._

private val classes: List[Modifier] = {
(BootstrapStyles.Button.btn: Modifier) ::
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ final class UdashButtonGroup[ItemType, ElemType <: ReadableProperty[ItemType]] p
override val componentId: ComponentId
)(itemFactory: (ElemType, Binding.NestedInterceptor) => Seq[Element]) extends UdashBootstrapComponent {

import io.udash.css.CssView._

private def buttonFullWidth: Binding =
BootstrapStyles.Sizing.width100.styleIf(justified)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ final class UdashButtonToolbar[ItemType, ElemType <: ReadableProperty[ItemType]]
override val componentId: ComponentId
)(itemFactory: (ElemType, Binding.NestedInterceptor) => Seq[Element]) extends UdashBootstrapComponent {

import io.udash.css.CssView._

override val render: Element =
div(role := "toolbar", BootstrapStyles.Button.toolbar, id := componentId)(
repeatWithNested(items)(itemFactory)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import io.udash.bindings.modifiers.Binding
import io.udash.bootstrap.list.UdashListGroup
import io.udash.bootstrap.nav.UdashNav
import io.udash.bootstrap.utils.{BootstrapStyles, UdashBootstrapComponent}
import io.udash.css.CssView._
import org.scalajs.dom.Element
import scalatags.JsDom.all._

Expand Down Expand Up @@ -98,19 +97,19 @@ final class UdashCard private(
/** Puts the provided list group into the card with additional `list-group-flush` style.
* More: <a href="http://getbootstrap.com/docs/4.1/components/card/#list-groups">Bootstrap Docs</a>. */
def listGroup(list: Binding.NestedInterceptor => UdashListGroup[_, _]): Modifier = {
list(externalBinding).render.styles(BootstrapStyles.ListGroup.flush)
list(externalBinding).render +: BootstrapStyles.ListGroup.flush
}

/** Puts the provided navigation tabs into the card with additional `card-header-tabs` style.
* More: <a href="http://getbootstrap.com/docs/4.1/components/card/#navigation">Bootstrap Docs</a>. */
def navigationTabs(navigation: Binding.NestedInterceptor => UdashNav[_, _]): Modifier = {
navigation(externalBinding).render.styles(BootstrapStyles.Card.navTabs)
navigation(externalBinding).render +: BootstrapStyles.Card.navTabs
}

/** Puts the provided navigation tabs into the card with additional `card-header-pills` style.
* More: <a href="http://getbootstrap.com/docs/4.1/components/card/#navigation">Bootstrap Docs</a>. */
def navigationPills(navigation: Binding.NestedInterceptor => UdashNav[_, _]): Modifier = {
navigation(externalBinding).render.styles(BootstrapStyles.Card.navPills)
navigation(externalBinding).render +: BootstrapStyles.Card.navPills
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ final class UdashCarousel[ItemType, ElemType <: ReadableProperty[ItemType]] priv
import UdashCarousel._
import io.udash.bootstrap.utils.BootstrapStyles.Carousel
import io.udash.bootstrap.utils.BootstrapTags._
import io.udash.css.CssView._
import io.udash.wrappers.jquery._

if (activeSlide.get >= slides.size) activeSlide.set(slides.size - 1)
Expand Down Expand Up @@ -300,7 +299,7 @@ object UdashCarousel {
* @param caption Slide caption content.
*/
case class UdashCarouselSlide(imgSrc: Url)(caption: Modifier*) {
import io.udash.css.CssView._


lazy val render: Node = {
Seq(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ final class UdashAccordion[ItemType, ElemType <: ReadableProperty[ItemType]] pri
with Listenable[UdashAccordion[ItemType, ElemType], UdashAccordion.AccordionEvent[ItemType, ElemType]] {

import io.udash.bootstrap.utils.BootstrapTags._
import io.udash.css.CssView._
import scalatags.JsDom.all._

private val collapses = mutable.Map.empty[ElemType, UdashCollapse]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ final class UdashCollapse private(

import UdashCollapse._
import io.udash.bootstrap.utils.BootstrapTags._
import io.udash.css.CssView._
import io.udash.wrappers.jquery._

/** Toggle state of this collapse. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ final class UdashDatePicker private[datepicker](
) extends UdashBootstrapComponent with Listenable[UdashDatePicker, UdashDatePicker.DatePickerEvent] with CrossLogging {

import UdashDatePicker._
import io.udash.css.CssView._
import scalatags.JsDom.all._

private val inp = input(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ final class UdashDropdown[ItemType, ElemType <: ReadableProperty[ItemType]] priv

import UdashDropdown._
import io.udash.bootstrap.dropdown.UdashDropdown.DropdownEvent._
import io.udash.css.CssView._

/** Dropdown menu list ID. */
val menuId: ComponentId = componentId.subcomponent("menu")
Expand Down Expand Up @@ -144,7 +143,7 @@ object UdashDropdown {
/** Renders DOM element for [[io.udash.bootstrap.dropdown.UdashDropdown.DefaultDropdownItem]]. */
def defaultItemFactory(item: DefaultDropdownItem, nested: Binding.NestedInterceptor): Element = {
import DefaultDropdownItem._
import io.udash.css.CssView._

item match {
case Text(text) =>
span(BootstrapStyles.Dropdown.itemText, text).render
Expand All @@ -157,7 +156,7 @@ object UdashDropdown {
case Header(title) =>
h6(BootstrapStyles.Dropdown.header)(title).render
case Disabled(item) =>
val res = defaultItemFactory(item, nested).styles(BootstrapStyles.disabled)
val res = defaultItemFactory(item, nested) +: BootstrapStyles.disabled
res.addEventListener("click", (ev: Event) => {
ev.preventDefault()
ev.stopPropagation()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ final class UdashForm private(
)(content: FormElementsFactory => Modifier)
extends UdashBootstrapComponent with Listenable[UdashForm, UdashForm.FormEvent] with CrossLogging {

import io.udash.css.CssView._

private[form] val validationProperties: MSet[Property[Option[ValidationResult]]] = MSet.empty

def clearValidationResults(): Unit = {
Expand Down Expand Up @@ -134,7 +132,7 @@ final class FormElementsFactory(
form: OptArg[UdashForm] = OptArg.Empty
) extends CrossLogging {

import io.udash.css.CssView._


/** Use this method to bond the external binding's lifecycle with the lifecycle of the elements created via this factory. */
def externalBinding[T <: Binding](binding: T): T = {
Expand Down Expand Up @@ -582,7 +580,7 @@ final class FormElementsFactory(

override val render: Element = div(
id := groupId, BootstrapStyles.Form.customControl, BootstrapStyles.Form.customCheckbox,
input.render.styles(BootstrapStyles.Form.customControlInput),
input.render +: BootstrapStyles.Form.customControlInput,
nestedInterceptor(BootstrapStyles.Form.customControlInline.styleIf(inline)),
label(`for` := inputId, BootstrapStyles.Form.customControlLabel)(
labelContent.map(_.apply(nestedInterceptor)).getOrElse(span("\u00a0"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ final class UdashInputGroup private(
override val componentId: ComponentId
)(content: Modifier*) extends UdashBootstrapComponent {

import io.udash.css.CssView._

override val render: Element =
div(
BootstrapStyles.InputGroup.inputGroup,
Expand All @@ -21,7 +19,7 @@ final class UdashInputGroup private(
}

object UdashInputGroup {
import io.udash.css.CssView._


/**
* Creates an inputs group.
Expand All @@ -42,15 +40,15 @@ object UdashInputGroup {

/** Adds `form-control` style to provided element. It's required to properly display input as part of group. */
def input(el: Element): Element =
el.styles(BootstrapStyles.Form.control)
el +: BootstrapStyles.Form.control

/** Adds `custom-select` style to provided element. It's required to properly display select as part of group. */
def select(el: Element): Element =
el.styles(BootstrapStyles.Form.control, BootstrapStyles.InputGroup.customSelect)
(el +: BootstrapStyles.Form.control) +: BootstrapStyles.InputGroup.customSelect

/** Adds `custom-file` style to provided element. It's required to properly display file input as part of group. */
def file(el: Element): Element =
el.styles(BootstrapStyles.Form.control, BootstrapStyles.InputGroup.customFile)
(el +: BootstrapStyles.Form.control) +: BootstrapStyles.InputGroup.customFile

/** Creates an element to be prepended to the input of this input group. */
def prepend(content: Modifier*): Modifier =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ final class UdashJumbotron private(
override val componentId: ComponentId
)(content: Binding.NestedInterceptor => Modifier) extends UdashBootstrapComponent {

import io.udash.css.CssView._

override val render: Element = {
div(
id := componentId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ final class UdashListGroup[ItemType, ElemType <: ReadableProperty[ItemType]] pri
flush: ReadableProperty[Boolean],
override val componentId: ComponentId
)(itemFactory: (ElemType, Binding.NestedInterceptor) => Element) extends UdashBootstrapComponent {
import io.udash.css.CssView._
import scalatags.JsDom.all._

override val render: Element =
Expand All @@ -22,7 +21,7 @@ final class UdashListGroup[ItemType, ElemType <: ReadableProperty[ItemType]] pri
)(
nestedInterceptor(
repeatWithNested(items) { (item, nested) =>
itemFactory(item, nested).styles(BootstrapStyles.ListGroup.item)
itemFactory(item, nested) +: BootstrapStyles.ListGroup.item
}
)
).render
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ final class UdashModal private(
) extends UdashBootstrapComponent with Listenable[UdashModal, UdashModal.ModalEvent] {

import UdashModal._
import io.udash.css.CssView._
import io.udash.wrappers.jquery._
import scalatags.JsDom.all._

Expand All @@ -44,7 +43,7 @@ final class UdashModal private(
(bodyFactory, BootstrapStyles.Modal.body),
(footerFactory, BootstrapStyles.Modal.footer)
).collect { case (Some(factory), styleName) =>
factory(nestedInterceptor).styles(styleName)
factory(nestedInterceptor) +: styleName
}

val el = div(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ final class UdashNav[ItemType, ElemType <: ReadableProperty[ItemType]] private(
isDisabled: ElemType => ReadableProperty[Boolean],
isDropdown: ElemType => ReadableProperty[Boolean]
) extends UdashBootstrapComponent {
import io.udash.css.CssView._

override val render: Element = {
ul(
Expand Down Expand Up @@ -67,7 +66,7 @@ final class UdashNav[ItemType, ElemType <: ReadableProperty[ItemType]] private(
}

object UdashNav {
import io.udash.css.CssView._


/** Default navigation model. */
class NavItem(val name: String, val link: Url)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,9 @@ final class UdashNavbar[ItemType, ElemType <: ReadableProperty[ItemType]] privat
)(
navigationFactory: Binding.NestedInterceptor => Modifier,
brand: Modifier
)
extends UdashBootstrapComponent {
) extends UdashBootstrapComponent {

import io.udash.bootstrap.utils.BootstrapTags._
import io.udash.css.CssView._

private val collapseId = ComponentId.newId()

Expand Down Expand Up @@ -87,9 +85,9 @@ object UdashNavbar {
navigationFactory: Binding.NestedInterceptor => UdashNav[ItemType, ElemType],
brand: Modifier = ()
): UdashNavbar[ItemType, ElemType] = {
import io.udash.css.CssView._

new UdashNavbar(expandBreakpoint, darkStyle, backgroundStyle, position, componentId)(
interceptor => navigationFactory(interceptor).render.styles(BootstrapStyles.NavigationBar.nav),
interceptor => navigationFactory(interceptor).render +: BootstrapStyles.NavigationBar.nav,
brand
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ final class UdashPagination[PageType : PropertyCreator, ElemType <: ReadableProp
additionalListModifiers: Binding.NestedInterceptor => Modifier
) extends UdashBootstrapComponent {

import io.udash.css.CssView._

// keep track of pages sequence changes and update selected page
propertyListeners += pages.listenStructure { patch =>
if (patch.idx <= selectedPageIdx.get && patch.idx + patch.removed.size > selectedPageIdx.get) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ final class UdashProgressBar private[progressbar](
override val componentId: ComponentId
)(labelFactory: (ReadableProperty[Int], ReadableProperty[Int], ReadableProperty[Int], Binding.NestedInterceptor) => Modifier) extends UdashBootstrapComponent {

import io.udash.css.CssView._

protected def barModifiers: Seq[Modifier] = Seq[Modifier](
role := "progressbar", BootstrapStyles.ProgressBar.progressBar,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ final class UdashTable[ItemType, ElemType <: ReadableProperty[ItemType]] private
rowFactory: (ElemType, Binding.NestedInterceptor) => Element
) extends UdashBootstrapComponent {

import io.udash.css.CssView._

override val render: Element = {
div(
nestedInterceptor((BootstrapStyles.Table.responsive _).reactiveOptionApply(responsive)),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ object UdashPopover extends TooltipUtils[UdashPopover] {

override protected val defaultPlacement = Placement.Right
override protected val defaultTemplate: String = {
import io.udash.css.CssView._
import scalatags.Text.all._
div(BootstrapStyles.Popover.popover, role := "tooltip")(
div(BootstrapStyles.arrow),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ object UdashTooltip extends TooltipUtils[UdashTooltip] {

override protected val defaultPlacement = Placement.Top
override protected val defaultTemplate: String = {
import io.udash.css.CssView._
import scalatags.Text.all._
div(BootstrapStyles.Tooltip.tooltip, role := "tooltip")(
div(BootstrapStyles.Tooltip.arrow),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import io.udash.testing.UdashCoreFrontendTest
import org.scalajs.dom.Element

class BootstrapImplicitsTest extends UdashCoreFrontendTest {
import io.udash.css.CssView._

"StyleOps" should {
"apply style conditionally" in {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import scalatags.JsDom.all._

import scala.concurrent.Future

class UdashIconsTest extends AsyncUdashCoreFrontendTest with CssView {
class UdashIconsTest extends AsyncUdashCoreFrontendTest {
override protected def beforeAll(): Unit = document.body.appendChild(UdashBootstrap.loadFontAwesome())

"Bootstrap icons" should {
Expand Down
3 changes: 2 additions & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import org.openqa.selenium.firefox.{FirefoxDriverLogLevel, FirefoxOptions}
import org.scalajs.jsenv.jsdomnodejs.JSDOMNodeJSEnv
import org.scalajs.jsenv.selenium.SeleniumJSEnv
import org.scalajs.sbtplugin.JSModuleID
import sbt.Def

name := "udash"

Expand Down Expand Up @@ -127,7 +128,7 @@ val aggregateProjectSettings = noPublishSettings ++ Seq(
crossScalaVersions := Nil,
)

def sourceDirsSettings(baseMapper: File => File) = {
def sourceDirsSettings(baseMapper: File => File): Seq[Def.Setting[Seq[File]]] = {
def mkSourceDirs(base: File, scalaBinary: String, conf: String): Seq[File] = Seq(
base / "src" / conf / "scala",
base / "src" / conf / s"scala-$scalaBinary",
Expand Down
Loading