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

Add vendor prefixes to keyframes #106

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
24 changes: 13 additions & 11 deletions core/shared/src/main/scala/scalacss/internal/Renderer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ object StringRenderer {

type KeyframeSelectorO = Option[KeyframeSelector]

case class FormatSB(kfStart : String => Unit,
case class FormatSB(kfStart : (String, String) => Unit,
kfsStart: Value => Unit,
mqStart : CssMediaQuery => Unit,
selStart: (CssMediaQueryO, CssSelector) => Unit,
Expand Down Expand Up @@ -80,15 +80,17 @@ object StringRenderer {
e.mq foreach mqEnd

case e: CssEntry.Keyframes =>
kfStart(e.name.value)
for ((sel, styles) <- e.frames) {
kfsStart(sel.value)
val selO = Some(sel)
for (s <- styles)
printCssKV(selO, s.mq, s.content)
kfsEnd(sel)
Seq("-webkit-", "-moz-", "-o-", "").foreach { p =>
kfStart(p, e.name.value)
for ((sel, styles) <- e.frames) {
kfsStart(sel.value)
val selO = Some(sel)
for (s <- styles)
printCssKV(selO, s.mq, s.content)
kfsEnd(sel)
}
kfEnd(e.name)
}
kfEnd(e.name)

case e: CssEntry.FontFace =>
ff(e)
Expand Down Expand Up @@ -138,7 +140,7 @@ object StringRenderer {
quoteIfNeeded(sb, c.value, quote)
}
FormatSB(
kfStart = n => { sb append "@keyframes "; sb append n; sb append '{' },
kfStart = (p, n) => { sb append s"@${p}keyframes "; sb append n; sb append '{' },
kfsStart = s => { sb append s; sb append '{' },
mqStart = m => { sb append m; sb append '{' },
selStart = (_, s) => { sb append s; sb append '{' },
Expand Down Expand Up @@ -177,7 +179,7 @@ object StringRenderer {
sb append ";\n"
}
FormatSB(
kfStart = n => { sb append "@keyframes "; sb append n; sb append " {\n" },
kfStart = (p, n) => { sb append s"@${p}keyframes "; sb append n; sb append " {\n" },
kfsStart = s => { sb append indent; sb append s; sb append " {\n" },
mqStart = mq => {
sb append mq
Expand Down
54 changes: 54 additions & 0 deletions core/shared/src/test/scala/scalacss/full/InlineTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 +506,60 @@ object InlineTest extends utest.TestSuite {
}

'keyframes - assertEq(norm(MyInlineWithKeyframes.render), norm("""
|@-webkit-keyframes MyInlineWithKeyframes-kf1 {
| 0% {
| height: 100px;
| width: 30px;
| }
|
| 20.5% {
| height: 150px;
| width: 30px;
| }
|
| 100% {
| height: 200px;
| width: 60px;
| }
|
|}
|
|@-moz-keyframes MyInlineWithKeyframes-kf1 {
| 0% {
| height: 100px;
| width: 30px;
| }
|
| 20.5% {
| height: 150px;
| width: 30px;
| }
|
| 100% {
| height: 200px;
| width: 60px;
| }
|
|}
|
|@-o-keyframes MyInlineWithKeyframes-kf1 {
| 0% {
| height: 100px;
| width: 30px;
| }
|
| 20.5% {
| height: 150px;
| width: 30px;
| }
|
| 100% {
| height: 200px;
| width: 60px;
| }
|
|}
|
|@keyframes MyInlineWithKeyframes-kf1 {
| 0% {
| height: 100px;
Expand Down
51 changes: 51 additions & 0 deletions doc/features/keyframes.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,57 @@ This code will not produce separate CSS for value `hello2`; its style will only
Rendered CSS gonna look like following:

```css
@-webkit-keyframes Demo-kf1 {
0% {
height: 100px;
width: 30px;
}

20% {
height: 150px;
width: 30px;
}

100% {
height: 200px;
width: 60px;
}
}

@-moz-keyframes Demo-kf1 {
0% {
height: 100px;
width: 30px;
}

20% {
height: 150px;
width: 30px;
}

100% {
height: 200px;
width: 60px;
}
}

@-o-keyframes Demo-kf1 {
0% {
height: 100px;
width: 30px;
}

20% {
height: 150px;
width: 30px;
}

100% {
height: 200px;
width: 60px;
}
}

@keyframes Demo-kf1 {
0% {
height: 100px;
Expand Down