# HG changeset patch # User Tomas Zeman # Date 1548796266 -3600 # Node ID 950431e16cb44084e262361774b05115a9d7c6a7 # Parent 782f121133c716cfe970f191c6b302ad6102e47a Restored CamelCase for icon idents/names diff -r 782f121133c7 -r 950431e16cb4 build.sc --- a/build.sc Thu Jan 17 18:29:45 2019 +0100 +++ b/build.sc Tue Jan 29 22:11:06 2019 +0100 @@ -6,6 +6,8 @@ import mill.scalalib.publish._ import mill.util.Loose +import scala.language.postfixOps + object V { val fatags = "0.5-SNAPSHOT" val scalaJs = "0.6.26" @@ -17,6 +19,16 @@ val scalatags = ivy"com.lihaoyi::scalatags::0.6.7" } +def camelCase(s: String): String = { + def inner(l: List[Char]): List[Char] = l match { + case '-' :: '-' :: c :: rest => c.toUpper :: inner(rest) + case '-' :: c :: rest => c.toUpper :: inner(rest) + case c :: rest => c :: inner(rest) + case Nil => Nil + } + inner(s toList) mkString "" +} + trait Common extends CrossSbtModule with PublishModule { def publishVersion: Target[String] = V.fatags @@ -73,14 +85,11 @@ } private def tpl(d: IcoDef): String = { - val sym = d._1 match { - //case "clone" => "clone_" - case x => x - } + val sym = d._1 d._2.map { - case "brands" => s""" val `fab-$sym`: T = fab("${d._1}")\n""" - case "solid" => s""" val `fas-$sym`: T = fas("${d._1}")\n""" - case "regular" => s""" val `far-$sym`: T = far("${d._1}")\n""" + case "brands" => s""" val ${camelCase(s"fab-$sym")}: T = fab("$sym")\n""" + case "solid" => s""" val ${camelCase(s"fas-$sym")}: T = fas("$sym")\n""" + case "regular" => s""" val ${camelCase(s"far-$sym")}: T = far("$sym")\n""" }.mkString } @@ -107,24 +116,7 @@ | private def far(w: String): T = FA(FaStyle.Regular, w) | private def fas(w: String): T = FA(FaStyle.Solid, w) | - | ${icons map(tpl) mkString} - | - | /* - | object fab { - | private def fa(w: String): T = FA(FaStyle.Brands, w) - | {icons.filter(_._2.contains("brands")).map(tpl).mkString} - | } - | - | object fas { - | private def fa(w: String): T = FA(FaStyle.Solid, w) - | {icons.filter(_._2.contains("solid")).map(tpl).mkString} - | } - | - | object far { - | private def fa(w: String): T = FA(FaStyle.Regular, w) - | {icons.filter(_._2.contains("regular")).map(tpl).mkString} - | } - | */ + | ${icons map tpl mkString} | | } """.stripMargin) diff -r 782f121133c7 -r 950431e16cb4 example/src/example/Example5.scala --- a/example/src/example/Example5.scala Thu Jan 17 18:29:45 2019 +0100 +++ b/example/src/example/Example5.scala Tue Jan 29 22:11:06 2019 +0100 @@ -17,40 +17,40 @@ h1("Font awesome demo..."), h2("Larger icons"), div(cls:="pure-g", - div(cls:="pure-u-1-5", `fas-camera-retro`.lg, "fa-lg"), - div(cls:="pure-u-1-5", `fas-camera-retro`.x2, "fa-2x"), - div(cls:="pure-u-1-5", `fas-camera-retro`.x3, "fa-3x"), - div(cls:="pure-u-1-5", `fas-camera-retro`.x4, "fa-4x"), - div(cls:="pure-u-1-5", `fas-camera-retro`.x5, "fa-5x") + div(cls:="pure-u-1-5", fasCameraRetro.lg, "fa-lg"), + div(cls:="pure-u-1-5", fasCameraRetro.x2, "fa-2x"), + div(cls:="pure-u-1-5", fasCameraRetro.x3, "fa-3x"), + div(cls:="pure-u-1-5", fasCameraRetro.x4, "fa-4x"), + div(cls:="pure-u-1-5", fasCameraRetro.x5, "fa-5x") ), h2("Fixed width icons (default)"), - div(cls:="pure-u-1", `fas-home`, "Home"), - div(cls:="pure-u-1", `fas-book`, "Library"), - div(cls:="pure-u-1", `fas-pencil-alt`, "Applications"), - div(cls:="pure-u-1", `fas-cog`, "Settings"), + div(cls:="pure-u-1", fasHome, "Home"), + div(cls:="pure-u-1", fasBook, "Library"), + div(cls:="pure-u-1", fasPencilAlt, "Applications"), + div(cls:="pure-u-1", fasCog, "Settings"), h2("No fixed width icons"), div(cls:="pure-u-1", - `fas-wifi`.noFw, `fab-wikipedia-w`.noFw, `fas-won-sign`.noFw, - `fab-wordpress`.noFw, - `fab-xing`.noFw, `fab-yahoo`.noFw, `fab-yelp`.noFw, `fas-yen-sign`.noFw, - `fab-yoast`.noFw, `fab-youtube`.noFw), + fasWifi.noFw, fabWikipediaW.noFw, fasWonSign.noFw, + fabWordpress.noFw, + fabXing.noFw, fabYahoo.noFw, fabYelp.noFw, fasYenSign.noFw, + fabYoast.noFw, fabYoutube.noFw), h2("List icons"), ul(cls:="fa-ul", - li(`fas-check-square`.li, "List icons"), - li(`far-check-square`.li, "can be used"), - li(`fas-spinner`.li.spin, "as bullets"), - li(`fas-square`.li, "in lists") + li(fasCheckSquare.li, "List icons"), + li(farCheckSquare.li, "can be used"), + li(fasSpinner.li.spin, "as bullets"), + li(fasSquare.li, "in lists") ), h2("Bordered & Pulled Icons"), div(cls:="pure-u-1-4", - `fas-quote-left`.x3.pullLeft.border, + fasQuoteLeft.x3.pullLeft.border, s"""...tomorrow we will run faster, stretch out our arms farther... And then one fine morning - So we beat on, boats against the current, borne back ceaselessly into the past."""), h2("Animated Icons "), div(cls:="pure-u-1", - `fas-spinner`.x3.spin, `fas-circle-notch`.x3.spin, `fas-sync`.x3.spin, - `fas-cog`.x3.spin, `fas-spinner`.x3.pulse + fasSpinner.x3.spin, fasCircleNotch.x3.spin, fasSync.x3.spin, + fasCog.x3.spin, fasSpinner.x3.pulse ) ).render) }