Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Preliminary integration of material icon support
Updates to GoogleFont to use latest version of fonts Updated examples project to use youi-plugin
- Loading branch information
1 parent
4472542
commit 52732fe
Showing
11 changed files
with
5,743 additions
and
3,682 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
31 changes: 31 additions & 0 deletions
31
example/js/src/main/scala/io/youi/example/ui/MaterialIconsExample.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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,31 @@ | |||
package io.youi.example.ui | |||
|
|||
import io.youi.Color | |||
import io.youi.example.screen.UIExampleScreen | |||
import io.youi.font.{Material, MaterialIconView} | |||
import io.youi.net._ | |||
import io.youi.style.FontWeight | |||
|
|||
import scala.concurrent.Future | |||
import scribe.Execution.global | |||
|
|||
class MaterialIconsExample extends UIExampleScreen { | |||
override def title: String = "Material Icons Example" | |||
|
|||
override def path: Path = path"/examples/material-icons.html" | |||
|
|||
override def createUI(): Future[Unit] = for { | |||
material <- Material.load() | |||
} yield { | |||
val iconView = new MaterialIconView { | |||
value := Material.Icons.Action.Alarm | |||
font := material | |||
font.weight := FontWeight("bold") | |||
font.size := 128.0 | |||
color := Color.Blue | |||
position.x := container.size.center | |||
position.y := container.size.middle | |||
} | |||
container.children += iconView | |||
} | |||
} |
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
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,27 @@ | |||
package io.youi.font | |||
|
|||
import io.youi.component.extras.HTMLComponent | |||
import io.youi.dom._ | |||
import io.youi.theme.{MaterialIconViewTheme, Theme} | |||
import org.scalajs.dom._ | |||
|
|||
class MaterialIconView(protected val element: html.Element, | |||
val existing: Boolean = false) extends HTMLComponent[html.Element] with MaterialIconViewTheme { | |||
def this() = { | |||
this(create[html.Element]("i")) | |||
} | |||
|
|||
element.classList.add("material-icons") | |||
|
|||
override protected def defaultParentTheme: Theme = MaterialIconView | |||
|
|||
override def componentType: String = "MaterialIconView" | |||
} | |||
|
|||
object MaterialIconView extends MaterialIconViewTheme { | |||
override protected def defaultParentTheme: Theme = HTMLComponent | |||
|
|||
def existing(id: String, in: html.Element = document.body): MaterialIconViewTheme = { | |||
new MaterialIconView(in.byId[html.Element](id), existing = true) | |||
} | |||
} |
14 changes: 14 additions & 0 deletions
14
ui/js/src/main/scala/io/youi/theme/MaterialIconViewTheme.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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,14 @@ | |||
package io.youi.theme | |||
|
|||
import io.youi.font.{Material, MaterialIcon} | |||
import io.youi.theme.mixins.HTMLFontTheme | |||
|
|||
trait MaterialIconViewTheme extends HTMLComponentTheme with HTMLFontTheme { | |||
private implicit val iconStringify: Stringify[MaterialIcon] = new Stringify[MaterialIcon] { | |||
override def fromString(value: String): Option[MaterialIcon] = Some(MaterialIcon(value)) | |||
|
|||
override def toString(value: MaterialIcon): Option[String] = Some(value.name) | |||
} | |||
|
|||
lazy val value: StyleProp[MaterialIcon] = style[MaterialIcon]("value", Material.Icons.Action.Help, StyleConnect.content[MaterialIcon], updatesTransform = false) | |||
} |
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.