Skip to content

Commit

Permalink
New DSL: <String>.color
Browse files Browse the repository at this point in the history
  • Loading branch information
japgolly committed Apr 15, 2015
1 parent 0c9de7c commit 930667b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
5 changes: 5 additions & 0 deletions core/src/main/scala/scalacss/Dsl.scala
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@ object DslBase {
@inline def *(l: Resolution[N])(implicit N: Numeric[N]) = l * self
}

final class DslStr(val self: String) extends AnyVal {
@inline def color = scalacss.Color(self)
}

/** Untyped attributes */
final class DslAttr(val self: Attr) extends AnyVal {
@inline def :=(value: Value) : AV = AV(self, value)
Expand Down Expand Up @@ -154,6 +158,7 @@ abstract class DslBase
@inline implicit final def autoDslInt (a: Int) : DslInt = new DslInt(a)
@inline implicit final def autoDslNumI (a: Int) : DslNum[Int] = new DslNum[Int](a)
@inline implicit final def autoDslNumD (a: Double) : DslNum[Double] = new DslNum[Double](a)
@inline implicit final def autoDslStr (a: String) : DslStr = new DslStr(a)
@inline implicit final def autoDslAttr (a: Attr) : DslAttr = new DslAttr(a)
@inline implicit final def autoDslAttrT(a: TypedAttrBase): DslAttrT = new DslAttrT(a)
@inline implicit final def autoDslAV (a: AV) : DslAV = new DslAV(a)
Expand Down
4 changes: 2 additions & 2 deletions core/src/test/scala/scalacss/full/InlineTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ object MyInline extends StyleSheet.Inline {
content := none
),
unsafeRoot(".DEBUG")(
borderColor.red
borderColor("#080".color)
)
)

Expand Down Expand Up @@ -164,7 +164,7 @@ object InlineTest extends utest.TestSuite {
|}
|
|.DEBUG {
| border-color: red;
| border-color: #080;
|}
|
|.MyInline-0002 {
Expand Down
1 change: 1 addition & 0 deletions doc/history/0.2.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
*(The difference between `style()` which registers, and `styleS()` which doesn't, was too fine.)*
* New DSL: `mixinIf(bool)(…)`.
* New DSL: `mixinIfElse(bool)(…)(…)`.
* New DSL: `<String>.color`. Example: `borderColor("#080".color)`.
* Add literals to DSL auto-import: `inherit`,`initial`, `unset`.
* Renamed literal `each_line` to `eachLine`.

Expand Down

0 comments on commit 930667b

Please sign in to comment.