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

Commit

Permalink
Merge pull request #102 from cquiroz/modifiers
Browse files Browse the repository at this point in the history
Convert several components to use modifiers
  • Loading branch information
cquiroz authored Mar 14, 2020
2 parents 0e865d1 + 97979c3 commit 74acde4
Show file tree
Hide file tree
Showing 28 changed files with 511 additions and 493 deletions.
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ lazy val facade =
"com.github.japgolly.scalajs-react" %%% "core" % scalaJsReact,
"com.github.japgolly.scalajs-react" %%% "extra" % scalaJsReact,
"com.github.japgolly.scalajs-react" %%% "test" % scalaJsReact % Test,
"io.github.cquiroz.react" %%% "common" % "0.6.2",
"io.github.cquiroz.react" %%% "common" % "0.6.3",
"com.lihaoyi" %%% "utest" % "0.7.4" % Test,
"org.typelevel" %%% "cats-core" % "2.1.1" % Test
),
Expand Down
67 changes: 36 additions & 31 deletions facade/src/main/scala/react/semanticui/addons/radio/Radio.scala
Original file line number Diff line number Diff line change
Expand Up @@ -10,38 +10,41 @@ import react.common.style._
import react.common._
import react.semanticui._
import react.semanticui.modules.checkbox._
import japgolly.scalajs.react.vdom.TagMod

final case class Radio(
as: js.UndefOr[AsC] = js.undefined,
checked: js.UndefOr[Boolean] = js.undefined,
className: js.UndefOr[String] = js.undefined,
clazz: js.UndefOr[Css] = js.undefined,
defaultChecked: js.UndefOr[Boolean] = js.undefined,
defaultIndeterminate: js.UndefOr[Boolean] = js.undefined,
disabled: js.UndefOr[Boolean] = js.undefined,
fitted: js.UndefOr[Boolean] = js.undefined,
id: js.UndefOr[JsNumber | String] = js.undefined,
indeterminate: js.UndefOr[Boolean] = js.undefined,
label: js.UndefOr[VdomNode] = js.undefined,
name: js.UndefOr[String] = js.undefined,
onChangeE: js.UndefOr[Radio.Event] = js.undefined,
onChange: js.UndefOr[Callback] = js.undefined,
onClickE: js.UndefOr[Radio.Event] = js.undefined,
onClick: js.UndefOr[Callback] = js.undefined,
onMouseDownE: js.UndefOr[Radio.Event] = js.undefined,
onMouseDown: js.UndefOr[Callback] = js.undefined,
onMouseUpE: js.UndefOr[Radio.Event] = js.undefined,
onMouseUp: js.UndefOr[Callback] = js.undefined,
radio: js.UndefOr[Boolean] = js.undefined,
readOnly: js.UndefOr[Boolean] = js.undefined,
slider: js.UndefOr[Boolean] = js.undefined,
tabIndex: js.UndefOr[JsNumber | String] = js.undefined,
toggle: js.UndefOr[Boolean] = js.undefined,
`type`: js.UndefOr[CheckboxType] = CheckboxType.Radio,
value: js.UndefOr[String | JsNumber] = js.undefined
) extends GenericComponentP[Radio.RadioProps] {
override protected def cprops = Radio.props(this)
@inline def render = Radio.component(Radio.props(this))
as: js.UndefOr[AsC] = js.undefined,
checked: js.UndefOr[Boolean] = js.undefined,
className: js.UndefOr[String] = js.undefined,
clazz: js.UndefOr[Css] = js.undefined,
defaultChecked: js.UndefOr[Boolean] = js.undefined,
defaultIndeterminate: js.UndefOr[Boolean] = js.undefined,
disabled: js.UndefOr[Boolean] = js.undefined,
fitted: js.UndefOr[Boolean] = js.undefined,
id: js.UndefOr[JsNumber | String] = js.undefined,
indeterminate: js.UndefOr[Boolean] = js.undefined,
label: js.UndefOr[VdomNode] = js.undefined,
name: js.UndefOr[String] = js.undefined,
onChangeE: js.UndefOr[Radio.Event] = js.undefined,
onChange: js.UndefOr[Callback] = js.undefined,
onClickE: js.UndefOr[Radio.Event] = js.undefined,
onClick: js.UndefOr[Callback] = js.undefined,
onMouseDownE: js.UndefOr[Radio.Event] = js.undefined,
onMouseDown: js.UndefOr[Callback] = js.undefined,
onMouseUpE: js.UndefOr[Radio.Event] = js.undefined,
onMouseUp: js.UndefOr[Callback] = js.undefined,
radio: js.UndefOr[Boolean] = js.undefined,
readOnly: js.UndefOr[Boolean] = js.undefined,
slider: js.UndefOr[Boolean] = js.undefined,
tabIndex: js.UndefOr[JsNumber | String] = js.undefined,
toggle: js.UndefOr[Boolean] = js.undefined,
tpe: js.UndefOr[CheckboxType] = CheckboxType.Radio,
value: js.UndefOr[String | JsNumber] = js.undefined,
override val modifiers: Seq[TagMod] = Seq.empty
) extends GenericComponentPA[Radio.RadioProps, Radio] {
override protected def cprops = Radio.props(this)
override protected val component = Radio.component
override def addModifiers(modifiers: Seq[TagMod]) = copy(modifiers = this.modifiers ++ modifiers)
}

object Radio {
Expand Down Expand Up @@ -176,7 +179,7 @@ object Radio {
q.slider,
q.tabIndex,
q.toggle,
q.`type`,
q.tpe,
q.value
)

Expand Down Expand Up @@ -242,4 +245,6 @@ object Radio {

val defaultProps: RadioProps = props(Default)

def apply(content: TagMod*): Radio =
new Radio(modifiers = content)
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,26 @@ import react.common._
import react.semanticui._
import react.semanticui.elements.label.Label
import react.semanticui.{ raw => suiraw }
import japgolly.scalajs.react.vdom.TagMod

final case class FormField(
as: js.UndefOr[AsC] = js.undefined,
child: js.UndefOr[VdomNode] = js.undefined,
className: js.UndefOr[String] = js.undefined,
clazz: js.UndefOr[Css] = js.undefined,
content: js.UndefOr[VdomNode] = js.undefined,
disabled: js.UndefOr[Boolean] = js.undefined,
error: js.UndefOr[Label] = js.undefined,
inline: js.UndefOr[Boolean] = js.undefined,
label: js.UndefOr[Label] = js.undefined,
required: js.UndefOr[Boolean | Label] = js.undefined,
`type`: js.UndefOr[String] = js.undefined,
width: js.UndefOr[SemanticWidth] = js.undefined,
override val children: CtorType.ChildrenArgs = Seq.empty
) extends GenericComponentPC[FormField.FormFieldProps, FormField] {
override protected def cprops = FormField.props(this)
@inline def renderWith =
FormField.component(FormField.props(this))
override def withChildren(children: CtorType.ChildrenArgs) =
copy(children = children)
as: js.UndefOr[AsC] = js.undefined,
child: js.UndefOr[VdomNode] = js.undefined,
className: js.UndefOr[String] = js.undefined,
clazz: js.UndefOr[Css] = js.undefined,
content: js.UndefOr[VdomNode] = js.undefined,
disabled: js.UndefOr[Boolean] = js.undefined,
error: js.UndefOr[Label] = js.undefined,
inline: js.UndefOr[Boolean] = js.undefined,
label: js.UndefOr[Label] = js.undefined,
required: js.UndefOr[Boolean | Label] = js.undefined,
tpe: js.UndefOr[String] = js.undefined,
width: js.UndefOr[SemanticWidth] = js.undefined,
override val modifiers: Seq[TagMod] = Seq.empty
) extends GenericComponentPAC[FormField.FormFieldProps, FormField] {
override protected def cprops = FormField.props(this)
override protected val component = FormField.component
override def addModifiers(modifiers: Seq[TagMod]) = copy(modifiers = this.modifiers ++ modifiers)
}

object FormField {
Expand Down Expand Up @@ -102,7 +101,7 @@ object FormField {
q.inline,
q.label,
q.required,
q.`type`,
q.tpe,
q.width
)

Expand Down Expand Up @@ -142,6 +141,6 @@ object FormField {
private val component =
JsComponent[FormFieldProps, Children.Varargs, Null](RawComponent)

def apply(content: VdomNode*): FormField =
new FormField(children = content)
def apply(content: TagMod*): FormField =
new FormField(modifiers = content)
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,23 @@ import react.common.style._
import react.common._
import react.semanticui._
import react.semanticui.{ raw => suiraw }
import japgolly.scalajs.react.vdom.TagMod

final case class FormGroup(
as: js.UndefOr[AsC] = js.undefined,
child: js.UndefOr[VdomNode] = js.undefined,
className: js.UndefOr[String] = js.undefined,
clazz: js.UndefOr[Css] = js.undefined,
content: js.UndefOr[VdomNode] = js.undefined,
grouped: js.UndefOr[Boolean] = js.undefined,
inline: js.UndefOr[Boolean] = js.undefined,
unstackable: js.UndefOr[Boolean] = js.undefined,
widths: js.UndefOr[SemanticWidth | FormWidths] = js.undefined,
override val children: CtorType.ChildrenArgs = Seq.empty
) extends GenericComponentPC[FormGroup.FormGroupProps, FormGroup] {
override protected def cprops = FormGroup.props(this)
@inline def renderWith =
FormGroup.component(FormGroup.props(this))
override def withChildren(children: CtorType.ChildrenArgs) =
copy(children = children)
as: js.UndefOr[AsC] = js.undefined,
child: js.UndefOr[VdomNode] = js.undefined,
className: js.UndefOr[String] = js.undefined,
clazz: js.UndefOr[Css] = js.undefined,
content: js.UndefOr[VdomNode] = js.undefined,
grouped: js.UndefOr[Boolean] = js.undefined,
inline: js.UndefOr[Boolean] = js.undefined,
unstackable: js.UndefOr[Boolean] = js.undefined,
widths: js.UndefOr[SemanticWidth | FormWidths] = js.undefined,
override val modifiers: Seq[TagMod] = Seq.empty
) extends GenericComponentPAC[FormGroup.FormGroupProps, FormGroup] {
override protected def cprops = FormGroup.props(this)
override protected val component = FormGroup.component
override def addModifiers(modifiers: Seq[TagMod]) = copy(modifiers = this.modifiers ++ modifiers)
}

object FormGroup {
Expand Down Expand Up @@ -112,6 +111,6 @@ object FormGroup {
private val component =
JsComponent[FormGroupProps, Children.Varargs, Null](RawComponent)

def apply(content: VdomNode*): FormGroup =
new FormGroup(children = content)
def apply(content: TagMod*): FormGroup =
new FormGroup(modifiers = content)
}
77 changes: 38 additions & 39 deletions facade/src/main/scala/react/semanticui/collections/menu/Menu.scala
Original file line number Diff line number Diff line change
Expand Up @@ -10,41 +10,40 @@ import react.common.style._
import react.common._
import react.semanticui._
import react.semanticui.{ raw => suiraw }
import japgolly.scalajs.react.vdom.TagMod

final case class Menu(
as: js.UndefOr[AsC] = js.undefined,
activeIndex: js.UndefOr[Int | String] = js.undefined,
attached: js.UndefOr[MenuAttached] = js.undefined,
borderless: js.UndefOr[Boolean] = js.undefined,
child: js.UndefOr[VdomNode] = js.undefined,
className: js.UndefOr[String] = js.undefined,
clazz: js.UndefOr[Css] = js.undefined,
color: js.UndefOr[SemanticColor] = js.undefined,
compact: js.UndefOr[Boolean] = js.undefined,
defaultActiveIndex: js.UndefOr[Int | String] = js.undefined,
fixed: js.UndefOr[MenuFixed] = js.undefined,
floated: js.UndefOr[MenuFloated] = js.undefined,
fluid: js.UndefOr[Boolean] = js.undefined,
icon: js.UndefOr[MenuIcon] = js.undefined,
inverted: js.UndefOr[Boolean] = js.undefined,
onItemClickE: js.UndefOr[Menu.OnItemClick] = js.undefined,
onItemClick: js.UndefOr[Callback] = js.undefined,
pagination: js.UndefOr[Boolean] = js.undefined,
pointing: js.UndefOr[Boolean] = js.undefined,
secondary: js.UndefOr[Boolean] = js.undefined,
size: js.UndefOr[SemanticSize] = js.undefined,
stackable: js.UndefOr[Boolean] = js.undefined,
tabular: js.UndefOr[MenuTabular] = js.undefined,
text: js.UndefOr[Boolean] = js.undefined,
vertical: js.UndefOr[Boolean] = js.undefined,
widths: js.UndefOr[SemanticWidth] = js.undefined,
override val children: CtorType.ChildrenArgs = Seq.empty
) extends GenericComponentPC[Menu.MenuProps, Menu] {
override protected def cprops = Menu.props(this)
@inline def renderWith =
Menu.component(Menu.props(this))
override def withChildren(children: CtorType.ChildrenArgs) =
copy(children = children)
as: js.UndefOr[AsC] = js.undefined,
activeIndex: js.UndefOr[Int | String] = js.undefined,
attached: js.UndefOr[MenuAttached] = js.undefined,
borderless: js.UndefOr[Boolean] = js.undefined,
child: js.UndefOr[VdomNode] = js.undefined,
className: js.UndefOr[String] = js.undefined,
clazz: js.UndefOr[Css] = js.undefined,
color: js.UndefOr[SemanticColor] = js.undefined,
compact: js.UndefOr[Boolean] = js.undefined,
defaultActiveIndex: js.UndefOr[Int | String] = js.undefined,
fixed: js.UndefOr[MenuFixed] = js.undefined,
floated: js.UndefOr[MenuFloated] = js.undefined,
fluid: js.UndefOr[Boolean] = js.undefined,
icon: js.UndefOr[MenuIcon] = js.undefined,
inverted: js.UndefOr[Boolean] = js.undefined,
onItemClickE: js.UndefOr[Menu.OnItemClick] = js.undefined,
onItemClick: js.UndefOr[Callback] = js.undefined,
pagination: js.UndefOr[Boolean] = js.undefined,
pointing: js.UndefOr[Boolean] = js.undefined,
secondary: js.UndefOr[Boolean] = js.undefined,
size: js.UndefOr[SemanticSize] = js.undefined,
stackable: js.UndefOr[Boolean] = js.undefined,
tabular: js.UndefOr[MenuTabular] = js.undefined,
text: js.UndefOr[Boolean] = js.undefined,
vertical: js.UndefOr[Boolean] = js.undefined,
widths: js.UndefOr[SemanticWidth] = js.undefined,
override val modifiers: Seq[TagMod] = Seq.empty
) extends GenericComponentPAC[Menu.MenuProps, Menu] {
override protected def cprops = Menu.props(this)
override protected val component = Menu.component
override def addModifiers(modifiers: Seq[TagMod]) = copy(modifiers = this.modifiers ++ modifiers)
}

object Menu {
Expand Down Expand Up @@ -146,10 +145,6 @@ object Menu {
var widths: js.UndefOr[suiraw.SemanticWIDTHS] = js.native
}

val Default: Menu = Menu()

val defaultProps: MenuProps = props(Default)

def props(q: Menu): MenuProps =
rawprops(
q.as,
Expand Down Expand Up @@ -238,7 +233,11 @@ object Menu {
private val component =
JsComponent[MenuProps, Children.Varargs, Null](RawComponent)

def apply(content: VdomNode*): Menu =
new Menu(children = content)
val Default: Menu = Menu()

val defaultProps: MenuProps = props(Default)

def apply(content: TagMod*): Menu =
new Menu(modifiers = content)

}
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,19 @@ import react.common.style._
import react.common._
import react.semanticui._
import react.semanticui.{ raw => suiraw }
import japgolly.scalajs.react.vdom.TagMod

final case class MenuHeader(
as: js.UndefOr[AsC] = js.undefined,
child: js.UndefOr[VdomNode] = js.undefined,
className: js.UndefOr[String] = js.undefined,
clazz: js.UndefOr[Css] = js.undefined,
content: js.UndefOr[VdomNode] = js.undefined,
override val children: CtorType.ChildrenArgs = Seq.empty
) extends GenericFnComponentPC[MenuHeader.MenuHeaderProps, MenuHeader] {
override protected def cprops = MenuHeader.props(this)
override def withChildren(children: CtorType.ChildrenArgs) =
copy(children = children)
@inline def renderWith =
MenuHeader.component(MenuHeader.props(this))
as: js.UndefOr[AsC] = js.undefined,
child: js.UndefOr[VdomNode] = js.undefined,
className: js.UndefOr[String] = js.undefined,
clazz: js.UndefOr[Css] = js.undefined,
content: js.UndefOr[VdomNode] = js.undefined,
override val modifiers: Seq[TagMod] = Seq.empty
) extends GenericFnComponentPAC[MenuHeader.MenuHeaderProps, MenuHeader] {
override protected def cprops = MenuHeader.props(this)
override protected val component = MenuHeader.component
override def addModifiers(modifiers: Seq[TagMod]) = copy(modifiers = this.modifiers ++ modifiers)
}

object MenuHeader {
Expand Down Expand Up @@ -74,6 +73,6 @@ object MenuHeader {
private val component =
JsFnComponent[MenuHeaderProps, Children.Varargs](RawComponent)

def apply(content: VdomNode*): MenuHeader =
new MenuHeader(children = content)
def apply(content: TagMod*): MenuHeader =
new MenuHeader(modifiers = content)
}
Loading

0 comments on commit 74acde4

Please sign in to comment.