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 #97 from rpiaggio/master
Browse files Browse the repository at this point in the history
Allow passing String and Boolean to icon properties.
  • Loading branch information
rpiaggio authored Mar 10, 2020
2 parents 4c90ffe + bb334b0 commit 7f5ada5
Show file tree
Hide file tree
Showing 13 changed files with 100 additions and 89 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v2
- uses: olafurpg/setup-scala@v2
- uses: olafurpg/setup-gpg@v2
- name: Publish
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/scala.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v2
- name: Set up JDK 1.8
uses: olafurpg/setup-scala@v2
with:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import react.common.style._
import react.common._
import react.semanticui._
import react.semanticui.{ raw => suiraw }
import react.semanticui.elements.icon.Icon
import react.semanticui.elements.icon.IconShorthand
import react.semanticui.elements.icon.Icon.IconProps

final case class MenuItem(
Expand All @@ -24,7 +24,7 @@ final case class MenuItem(
disabled: js.UndefOr[Boolean] = js.undefined,
fitted: js.UndefOr[MenuItemFitted] = js.undefined,
header: js.UndefOr[Boolean] = js.undefined,
icon: js.UndefOr[Icon] = js.undefined,
icon: js.UndefOr[IconShorthand] = js.undefined,
index: js.UndefOr[Int] = js.undefined,
link: js.UndefOr[Boolean] = js.undefined,
name: js.UndefOr[String] = js.undefined,
Expand Down Expand Up @@ -83,7 +83,7 @@ object MenuItem {
var header: js.UndefOr[Boolean] = js.native

/** Item can be only icon. */
var icon: js.UndefOr[suiraw.SemanticShorthandItem[IconProps]] =
var icon: js.UndefOr[suiraw.SemanticShorthandItemSB[IconProps]] =
js.native

/** Item index inside Menu. */
Expand Down Expand Up @@ -140,7 +140,7 @@ object MenuItem {
disabled: js.UndefOr[Boolean] = js.undefined,
fitted: js.UndefOr[MenuItemFitted] = js.undefined,
header: js.UndefOr[Boolean] = js.undefined,
icon: js.UndefOr[Icon] = js.undefined,
icon: js.UndefOr[IconShorthand] = js.undefined,
index: js.UndefOr[Int] = js.undefined,
link: js.UndefOr[Boolean] = js.undefined,
name: js.UndefOr[String] = js.undefined,
Expand All @@ -158,7 +158,7 @@ object MenuItem {
p.disabled = disabled
p.fitted = fitted.toJs
p.header = header
p.icon = icon.map(_.props)
p.icon = icon.toJs
p.index = index
p.link = link
p.name = name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import react.common._
import react.semanticui._
import react.semanticui.{ raw => suiraw }
import react.semanticui.elements.icon.Icon.IconProps
import react.semanticui.elements.icon.Icon
import react.semanticui.elements.icon.IconShorthand

final case class Message(
as: js.UndefOr[AsC] = js.undefined,
Expand All @@ -26,7 +26,7 @@ final case class Message(
floating: js.UndefOr[Boolean] = js.undefined,
header: js.UndefOr[VdomNode | MessageHeader.MessageHeaderProps] = js.undefined,
hidden: js.UndefOr[Boolean] = js.undefined,
icon: js.UndefOr[Icon] = js.undefined,
icon: js.UndefOr[IconShorthand] = js.undefined,
info: js.UndefOr[Boolean] = js.undefined,
list: js.UndefOr[Seq[VdomNode] | MessageList.MessageListProps] = js.undefined,
negative: js.UndefOr[Boolean] = js.undefined,
Expand Down Expand Up @@ -97,7 +97,7 @@ object Message {
var hidden: js.UndefOr[Boolean] = js.undefined

/** Add an icon by icon name or pass an <Icon /.> */
var icon: js.UndefOr[suiraw.SemanticShorthandItem[IconProps]] = js.undefined
var icon: js.UndefOr[suiraw.SemanticShorthandItemSB[IconProps]] = js.undefined

/** A message may be formatted to display information. */
var info: js.UndefOr[Boolean] = js.undefined
Expand Down Expand Up @@ -174,7 +174,7 @@ object Message {
floating: js.UndefOr[Boolean] = js.undefined,
header: js.UndefOr[VdomNode | MessageHeader.MessageHeaderProps] = js.undefined,
hidden: js.UndefOr[Boolean] = js.undefined,
icon: js.UndefOr[Icon] = js.undefined,
icon: js.UndefOr[IconShorthand] = js.undefined,
info: js.UndefOr[Boolean] = js.undefined,
list: js.UndefOr[Seq[VdomNode] | MessageList.MessageListProps] = js.undefined,
negative: js.UndefOr[Boolean] = js.undefined,
Expand All @@ -198,7 +198,7 @@ object Message {
p.floating = floating
p.header = header.toRaw
p.hidden = hidden
p.icon = icon.map(_.props)
p.icon = icon.toJs
p.info = info
p.list = list.toRaw
p.negative = negative
Expand Down
39 changes: 19 additions & 20 deletions facade/src/main/scala/react/semanticui/elements/button/Button.scala
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import react.semanticui._
import react.semanticui.elements.label.Label.LabelProps
import react.semanticui.elements.label.Label
import react.semanticui.elements.icon.Icon.IconProps
import react.semanticui.elements.icon.Icon
import react.semanticui.elements.icon.IconShorthand

final case class Button(
as: js.UndefOr[AsC] = js.undefined,
Expand All @@ -31,7 +31,7 @@ final case class Button(
disabled: js.UndefOr[Boolean] = js.undefined,
floated: js.UndefOr[SemanticFloat] = js.undefined,
fluid: js.UndefOr[Boolean] = js.undefined,
icon: js.UndefOr[Icon] = js.undefined,
icon: js.UndefOr[IconShorthand] = js.undefined,
inverted: js.UndefOr[Boolean] = js.undefined,
label: js.UndefOr[Label] = js.undefined,
labelPosition: js.UndefOr[String] = js.undefined,
Expand Down Expand Up @@ -69,22 +69,21 @@ object Button {

@JSBracketAccess
def update(key: String, v: js.Any): Unit = js.native
var as: js.UndefOr[AsT] = js.native
var active: js.UndefOr[Boolean] = js.native
var animated: js.UndefOr[Boolean | String] = js.native
var attached: js.UndefOr[Boolean | String] = js.native
var basic: js.UndefOr[Boolean] = js.native
var children: js.UndefOr[React.Node] = js.native
var circular: js.UndefOr[Boolean] = js.native
var className: js.UndefOr[String] = js.native
var color: js.UndefOr[String] = js.native
var compact: js.UndefOr[Boolean] = js.native
var content: js.UndefOr[suiraw.SemanticShorthandContent] = js.native
var disabled: js.UndefOr[Boolean] = js.native
var floated: js.UndefOr[suiraw.SemanticFLOATS] = js.native
var fluid: js.UndefOr[Boolean] = js.native
var icon: js.UndefOr[suiraw.SemanticShorthandItem[IconProps]] =
js.native
var as: js.UndefOr[AsT] = js.native
var active: js.UndefOr[Boolean] = js.native
var animated: js.UndefOr[Boolean | String] = js.native
var attached: js.UndefOr[Boolean | String] = js.native
var basic: js.UndefOr[Boolean] = js.native
var children: js.UndefOr[React.Node] = js.native
var circular: js.UndefOr[Boolean] = js.native
var className: js.UndefOr[String] = js.native
var color: js.UndefOr[String] = js.native
var compact: js.UndefOr[Boolean] = js.native
var content: js.UndefOr[suiraw.SemanticShorthandContent] = js.native
var disabled: js.UndefOr[Boolean] = js.native
var floated: js.UndefOr[suiraw.SemanticFLOATS] = js.native
var fluid: js.UndefOr[Boolean] = js.native
var icon: js.UndefOr[suiraw.SemanticShorthandItemSB[IconProps]] = js.native
var inverted: js.UndefOr[Boolean] = js.native
var label: js.UndefOr[suiraw.SemanticShorthandItem[LabelProps]] = js.native
var labelPosition: js.UndefOr[String] = js.native
Expand Down Expand Up @@ -150,7 +149,7 @@ object Button {
disabled: js.UndefOr[Boolean] = js.undefined,
floated: js.UndefOr[SemanticFloat] = js.undefined,
fluid: js.UndefOr[Boolean] = js.undefined,
icon: js.UndefOr[Icon] = js.undefined,
icon: js.UndefOr[IconShorthand] = js.undefined,
inverted: js.UndefOr[Boolean] = js.undefined,
label: js.UndefOr[Label] = js.undefined,
labelPosition: js.UndefOr[String] = js.undefined,
Expand Down Expand Up @@ -181,7 +180,7 @@ object Button {
p.disabled = disabled
p.floated = floated.toJs
p.fluid = fluid
p.icon = icon.map(_.props)
p.icon = icon.toJs
p.inverted = inverted
p.label = label.map(_.props)
p.labelPosition = labelPosition
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import react.common.style._
import react.common._
import react.semanticui.{ raw => suiraw }
import react.semanticui._
import react.semanticui.elements.icon.IconShorthand
import react.semanticui.elements.icon.Icon.IconProps

final case class Header(
as: js.UndefOr[AsC] = js.undefined,
Expand All @@ -23,7 +25,7 @@ final case class Header(
disabled: js.UndefOr[Boolean] = js.undefined,
dividing: js.UndefOr[Boolean] = js.undefined,
floated: js.UndefOr[SemanticFloat] = js.undefined,
icon: js.UndefOr[Boolean] = js.undefined,
icon: js.UndefOr[IconShorthand] = js.undefined,
image: js.UndefOr[Boolean] = js.undefined,
inverted: js.UndefOr[Boolean] = js.undefined,
size: js.UndefOr[SemanticSize] = js.undefined,
Expand Down Expand Up @@ -85,7 +87,7 @@ object Header {
var floated: js.UndefOr[suiraw.SemanticFLOATS] = js.native

/** Add an icon by icon name or pass an Icon. */
var icon: js.UndefOr[Boolean] = js.native
var icon: js.UndefOr[suiraw.SemanticShorthandItemSB[IconProps]] = js.native

/** Add an image by img src or pass an Image. */
var image: js.UndefOr[Boolean] = js.native
Expand Down Expand Up @@ -141,7 +143,7 @@ object Header {
disabled: js.UndefOr[Boolean] = js.undefined,
dividing: js.UndefOr[Boolean] = js.undefined,
floated: js.UndefOr[SemanticFloat] = js.undefined,
icon: js.UndefOr[Boolean] = js.undefined,
icon: js.UndefOr[IconShorthand] = js.undefined,
image: js.UndefOr[Boolean] = js.undefined,
inverted: js.UndefOr[Boolean] = js.undefined,
size: js.UndefOr[SemanticSize] = js.undefined,
Expand All @@ -160,7 +162,7 @@ object Header {
p.disabled = disabled
p.dividing = dividing
p.floated = floated.toJs
p.icon = icon
p.icon = icon.toJs
p.image = image
p.inverted = inverted
p.size = size.toJs
Expand Down
14 changes: 14 additions & 0 deletions facade/src/main/scala/react/semanticui/elements/icon/package.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package react.semanticui.elements

import react.common._
import react.semanticui._
import scala.scalajs.js
import scala.scalajs.js.|

package icon {
sealed trait IconFlip extends Product with Serializable
Expand Down Expand Up @@ -36,6 +38,18 @@ package icon {
}

package object icon {
type IconShorthand = Boolean | String | Icon

implicit class IconShorthandOpsUndef(icon: js.UndefOr[IconShorthand]) {
def toJs: js.UndefOr[raw.SemanticShorthandItemSB[Icon.IconProps]] =
icon.map(i =>
(i: Any) match {
case s: String => s
case b: Boolean => b
case obj: Icon => obj.props
}
)
}

implicit class CopyIconOps(val i: Icon) extends AnyVal {
def size(s: SemanticSize): Icon =
Expand Down
35 changes: 15 additions & 20 deletions facade/src/main/scala/react/semanticui/elements/input/Input.scala
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import react.common.style._
import react.common._
import react.semanticui.{ raw => suiraw }
import react.semanticui._
import react.semanticui.elements.icon.Icon
import react.semanticui.elements.icon.IconShorthand
import react.semanticui.elements.icon.Icon.IconProps

final case class Input(
Expand All @@ -25,7 +25,7 @@ final case class Input(
error: js.UndefOr[Boolean] = js.undefined,
fluid: js.UndefOr[Boolean] = js.undefined,
focus: js.UndefOr[Boolean] = js.undefined,
icon: js.UndefOr[Boolean | Icon] = js.undefined,
icon: js.UndefOr[IconShorthand] = js.undefined,
iconPosition: js.UndefOr[IconPosition] = js.undefined,
input: js.UndefOr[VdomNode] = js.undefined,
inverted: js.UndefOr[Boolean] = js.undefined,
Expand Down Expand Up @@ -90,7 +90,7 @@ object Input {
var focus: js.UndefOr[Boolean] = js.native

/** Optional Icon to display inside the Input. */
var icon: js.UndefOr[Boolean | suiraw.SemanticShorthandItem[IconProps]] = js.native
var icon: js.UndefOr[suiraw.SemanticShorthandItemSB[IconProps]] = js.native

/** An Icon can appear inside an Input on the left or right. */
var iconPosition: js.UndefOr[String]
Expand Down Expand Up @@ -144,23 +144,18 @@ object Input {
p.error = q.error
p.fluid = q.fluid
p.focus = q.focus
p.icon = q.icon.map {
(_: Any) match {
case b: Boolean => b
case c: Icon => c.props
}
}
p.iconPosition = q.iconPosition.toJs
p.input = q.input.toJs
p.inverted = q.inverted
p.label = q.label.toJs
p.labelPosition = q.labelPosition.toJs
p.loading = q.loading
p.onChange = (q.onChangeE, q.onChange).toJs
p.size = q.size.toJs
p.tabIndex = q.tabIndex
p.transparent = q.transparent
p.`type` = q.`type`
p.icon = q.icon.toJs
p.iconPosition = q.iconPosition.toJs
p.input = q.input.toJs
p.inverted = q.inverted
p.label = q.label.toJs
p.labelPosition = q.labelPosition.toJs
p.loading = q.loading
p.onChange = (q.onChangeE, q.onChange).toJs
p.size = q.size.toJs
p.tabIndex = q.tabIndex
p.transparent = q.transparent
p.`type` = q.`type`
p
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ import react.common.style._
import react.common._
import react.semanticui._
import react.semanticui.{ raw => suiraw }
import react.semanticui.elements.icon.Icon
import react.semanticui.elements.icon.IconShorthand
import react.semanticui.elements.icon.Icon.IconProps

final case class Label(
as: js.UndefOr[AsC] = js.undefined,
Expand All @@ -28,14 +29,14 @@ final case class Label(
empty: js.UndefOr[Boolean] = js.undefined,
floating: js.UndefOr[Boolean] = js.undefined,
horizontal: js.UndefOr[Boolean] = js.undefined,
icon: js.UndefOr[Icon] = js.undefined,
icon: js.UndefOr[IconShorthand] = js.undefined,
image: js.UndefOr[Boolean] = js.undefined,
onClickE: js.UndefOr[Label.OnClick] = js.undefined,
onClick: js.UndefOr[Callback] = js.undefined,
onRemove: js.UndefOr[Label.OnClick] = js.undefined,
pointing: js.UndefOr[LabelPointing] = js.undefined,
prompt: js.UndefOr[Boolean] = js.undefined,
removeIcon: js.UndefOr[Icon] = js.undefined,
removeIcon: js.UndefOr[IconShorthand] = js.undefined,
ribbon: js.UndefOr[LabelRibbon] = js.undefined,
size: js.UndefOr[SemanticSize] = js.undefined,
tag: js.UndefOr[Boolean] = js.undefined,
Expand Down Expand Up @@ -77,7 +78,7 @@ object Label {
var empty: js.UndefOr[js.Any] = js.native
var floating: js.UndefOr[Boolean] = js.native
var horizontal: js.UndefOr[Boolean] = js.native
var icon: js.UndefOr[suiraw.SemanticShorthandItem[Icon.IconProps]] =
var icon: js.UndefOr[suiraw.SemanticShorthandItemSB[IconProps]] =
js.native
var image: js.UndefOr[js.Any] = js.native
var onClick: js.UndefOr[js.Function2[ReactMouseEvent, LabelProps, Unit]] =
Expand All @@ -88,7 +89,7 @@ object Label {

/** A label can prompt for an error in your forms. */
var prompt: js.UndefOr[Boolean]
var removeIcon: js.UndefOr[suiraw.SemanticShorthandItem[Icon.IconProps]] =
var removeIcon: js.UndefOr[suiraw.SemanticShorthandItemSB[IconProps]] =
js.native
var ribbon: js.UndefOr[Boolean | String] = js.native
var size: js.UndefOr[suiraw.SemanticSIZES] = js.native
Expand All @@ -113,13 +114,13 @@ object Label {
p.empty = q.empty.map(_.asInstanceOf[js.Any])
p.floating = q.floating
p.horizontal = q.horizontal
p.icon = q.icon.map(_.props)
p.icon = q.icon.toJs
p.image = q.image.map(_.asInstanceOf[js.Any])
p.onClick = (q.onClickE, q.onClick).toJs
p.onRemove = q.onRemove.toJs
p.pointing = q.pointing.toJs
p.prompt = q.prompt
p.removeIcon = q.removeIcon.map(_.props)
p.removeIcon = q.removeIcon.toJs
p.ribbon = q.ribbon.toJs
p.size = q.size.toJs
p.tag = q.tag
Expand Down
Loading

0 comments on commit 7f5ada5

Please sign in to comment.