-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2bc0926
commit 16ed849
Showing
36 changed files
with
394 additions
and
134 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package scommons.materialui | ||
|
||
import io.github.shogowada.scalajs.reactjs.VirtualDOM.VirtualDOMAttributes | ||
import io.github.shogowada.statictags._ | ||
import scommons.materialui.styles.Styles | ||
|
||
/** @see https://material-ui.com/api/button-base/ | ||
*/ | ||
object ButtonBase { | ||
|
||
trait ButtonBaseAttributes { | ||
|
||
import ButtonBaseAttributes._ | ||
|
||
lazy val focusRipple = BooleanAttributeSpec("focusRipple") | ||
lazy val focusVisibleClassName = StringAttributeSpec("focusVisibleClassName") | ||
lazy val muiStyle = StyleAttributeSpec("style") | ||
} | ||
|
||
object ButtonBaseAttributes { | ||
|
||
import VirtualDOMAttributes.Type._ | ||
|
||
case class StyleAttributeSpec(name: String) extends AttributeSpec { | ||
def :=[T <: Styles](style: T): Attribute[T] = Attribute(name, style, AS_IS) | ||
} | ||
} | ||
} |
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
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
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 was deleted.
Oops, something went wrong.
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,16 @@ | ||
<!doctype html> | ||
<html> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta name="viewport" content="minimum-scale=1, initial-scale=1, width=device-width" /> | ||
|
||
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons" /> | ||
</head> | ||
<body> | ||
<div id="root">Loading, please, wait...</div> | ||
|
||
<script src="./scommons-material-ui-showcase-fastopt-library.js"></script> | ||
<script src="./scommons-material-ui-showcase-fastopt-loader.js"></script> | ||
<script src="./scommons-material-ui-showcase-fastopt.js"></script> | ||
</body> | ||
</html> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
136 changes: 136 additions & 0 deletions
136
showcase/src/main/scala/scommons/materialui/showcase/button/ButtonBases.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,136 @@ | ||
package scommons.materialui.showcase.button | ||
|
||
import scommons.materialui._ | ||
import scommons.materialui.styles._ | ||
import scommons.react._ | ||
|
||
import scala.scalajs.js | ||
|
||
object ButtonBases extends FunctionComponent[Unit] { | ||
|
||
private[button] val images = List( | ||
("static/images/image-list/breakfast.jpg", "Breakfast", "40%"), | ||
("static/images/image-list/burgers.jpg", "Burgers", "30%"), | ||
("static/images/image-list/camera.jpg", "Camera", "30%") | ||
) | ||
|
||
private[button] val useStyles = makeStyles(theme => { | ||
val s = new Styles { | ||
val root = new Styles { | ||
val display = "flex" | ||
val flexWrap = "wrap" | ||
val minWidth = 300 | ||
val width = "100%" | ||
} | ||
val image = js.Dynamic.literal( | ||
"position" -> "relative", | ||
"height" -> 200, | ||
theme.breakpoints.down("xs").asInstanceOf[String] -> { | ||
val s = new Styles { | ||
val width = "100% !important" // Overrides inline-style | ||
val height = 100 | ||
} | ||
s | ||
}, | ||
s"&:hover, &$$focusVisible" -> { | ||
val s = new Styles { | ||
val zIndex = 1 | ||
val `& $imageBackdrop` = new Styles { | ||
val opacity = 0.15 | ||
} | ||
val `& $imageMarked` = new Styles { | ||
val opacity = 0 | ||
} | ||
val `& $imageTitle` = new Styles { | ||
val border = "4px solid currentColor" | ||
} | ||
} | ||
s | ||
} | ||
) | ||
val focusVisible = new Styles {} | ||
val imageButton = new Styles { | ||
val position = "absolute" | ||
val left = 0 | ||
val right = 0 | ||
val top = 0 | ||
val bottom = 0 | ||
val display = "flex" | ||
val alignItems = "center" | ||
val justifyContent = "center" | ||
val color = theme.palette.common.white | ||
} | ||
val imageSrc = new Styles { | ||
val position = "absolute" | ||
val left = 0 | ||
val right = 0 | ||
val top = 0 | ||
val bottom = 0 | ||
val backgroundSize = "cover" | ||
val backgroundPosition = "center 40%" | ||
} | ||
val imageBackdrop = new Styles { | ||
val position = "absolute" | ||
val left = 0 | ||
val right = 0 | ||
val top = 0 | ||
val bottom = 0 | ||
val backgroundColor = theme.palette.common.black | ||
val opacity = 0.4 | ||
val transition = theme.transitions.create("opacity") | ||
} | ||
val imageTitle = new Styles { | ||
val position = "relative" | ||
val padding = | ||
s"${theme.spacing(2)}px ${theme.spacing(4)}px ${theme.spacing(1).asInstanceOf[Int] + 6}px" | ||
} | ||
val imageMarked = new Styles { | ||
val height = 3 | ||
val width = 18 | ||
val backgroundColor = theme.palette.common.white | ||
val position = "absolute" | ||
val bottom = -2 | ||
val left = "calc(50% - 9px)" | ||
val transition = theme.transitions.create("opacity") | ||
} | ||
} | ||
s | ||
}) | ||
|
||
protected def render(compProps: Props): ReactElement = { | ||
val classes = useStyles() | ||
|
||
<.div(^.className := styleOf(classes.root))( | ||
images.map { case (imageUrl, imageTitle, imageWidth) => | ||
<.ButtonBase( | ||
^.focusRipple := true, | ||
^.key := imageTitle, | ||
^.className := styleOf(classes.image), | ||
^.focusVisibleClassName := styleOf(classes.focusVisible), | ||
^.muiStyle := new Styles { | ||
val width = imageWidth | ||
} | ||
)( | ||
<.span( | ||
^.className := styleOf(classes.imageSrc), | ||
^.muiStyle := new Styles { | ||
val backgroundImage = s"url($imageUrl)" | ||
} | ||
)(), | ||
<.span(^.className := styleOf(classes.imageBackdrop))(), | ||
<.span(^.className := styleOf(classes.imageButton))( | ||
<.Typography( | ||
^.component := "span", | ||
^.variant := "subtitle1", | ||
^.color := "inherit", | ||
^.className := styleOf(classes.imageTitle) | ||
)( | ||
imageTitle, | ||
<.span(^.className := styleOf(classes.imageMarked))() | ||
) | ||
) | ||
) | ||
} | ||
) | ||
} | ||
} |
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
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
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
Oops, something went wrong.