Skip to content
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

fontFamily(): allow string value for font-family attribute #121

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
3 changes: 2 additions & 1 deletion core/shared/src/main/scala/scalacss/internal/Attrs.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1011,7 +1011,8 @@ object Attrs {
*/
object fontFamily extends TypedAttrBase {
override val attr = Attr.real("font-family")
def apply(a: FontFace[String]): AV = av(a.fontFamily)
def apply(a: FontFace[String]): AV = apply(a.fontFamily)
def apply(familyName: String): AV = av(familyName)
}

/**
Expand Down
29 changes: 29 additions & 0 deletions core/shared/src/test/scala/scalacss/full/InlineTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,18 @@ object MyInlineWithFontFace extends StyleSheet.Inline {
val myFontText3 = style(fontFamily(ff6))
}

object MyInlineWithRawFontFamily extends StyleSheet.Inline {
import dsl._

val myFont1 = style( fontFamily("verdana") )
val myFont2 = style( fontFamily("comic-sans") )
val myFont3 = style(
fontFamily("times-new-roman"),
backgroundColor( Color("#ffff00") )
)
}


object InlineTest extends utest.TestSuite {
import utest._
import scalacss.test.TestUtil._
Expand Down Expand Up @@ -678,5 +690,22 @@ object InlineTest extends utest.TestSuite {
| font-family: MyInlineWithFontFace-0002;
|}
""".stripMargin))

'fontFamilies - assertMultiline( norm(MyInlineWithRawFontFamily.render), norm(
"""
|.MyInlineWithRawFontFamily-myFont1 {
| font-family: verdana;
|}
|
|.MyInlineWithRawFontFamily-myFont2 {
| font-family: comic-sans;
|}
|
|.MyInlineWithRawFontFamily-myFont3 {
| font-family: times-new-roman;
| background-color: #ffff00;
|}
""".stripMargin))

}
}