-
-
Notifications
You must be signed in to change notification settings - Fork 28
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 flow-relative CSS properties #82
Comments
Main question is how to encode these props. We could spell out each property like we do for e.g. Few people use these new props (and actually test their websites to make sure they work with the different text directions), so I'm not sure if that's a good tradeoff. And in general I loathe having to define repetitive props. Alternatively, we could make those props nested, such as |
Regarding the I don't see the autocomplete "pollution" as a problem but rather as a feature it helps with the discoverability. But I do understand why it isn't the most good looking option. Making the props nested could be a very elegant solution. Here is a very rough idea (does not handle things like object Setter {
def instance[T](name: String): Setter[T] = (value: T) => s"$name: $value"
}
trait Setter[T] {
def :=(value: T): String
}
class TopBottomLeftRight[T](prefix: String) {
val top: Setter[T] = Setter.instance(s"$prefix-top")
val bottom: Setter[T] = Setter.instance(s"$prefix-bottom")
val left: Setter[T] = Setter.instance(s"$prefix-left")
val right: Setter[T] = Setter.instance(s"$prefix-right")
// (top and bottom, left and right).
def :=(t: (T, T)): String = s"$prefix: ${t._1} ${t._2}"
// (top, left and right, bottom).
def :=(t: (T, T, T)): String = s"$prefix: ${t._1} ${t._2} ${t._3}"
// (top, right, bottom, left)
def :=(t: (T, T, T, T)): String = s"$prefix: ${t._1} ${t._2} ${t._3} ${t._4}"
}
class BlockInline[T](prefix: String) extends Setter[T] {
override def :=(value: T): String = s"$prefix: $value"
// (start, end)
def :=(t: (T, T)): String = s"$prefix: ${t._1} ${t._2}"
val start: Setter[T] = Setter.instance(s"$prefix-start")
val end: Setter[T] = Setter.instance(s"$prefix-end")
}
class FourSidesProperty[T](prefix: String) extends TopBottomLeftRight[T](prefix) with Setter[T] {
override def :=(value: T): String = s"$prefix: $value"
val block: BlockInline[T] = new BlockInline(s"$prefix-block")
val inline: BlockInline[T] = new BlockInline(s"$prefix-inline")
}
@main def main(): Unit =
val margin: FourSidesProperty[Int] = new FourSidesProperty[Int]("margin")
val padding: FourSidesProperty[Int] = new FourSidesProperty[Int]("padding")
println(margin := 5)
println(margin := (5, 25, 5))
println(margin.top := 5)
println(margin.block := 5)
println(margin.block.start := 5)
println(margin.inline.end := 5)
println(padding.inline.end := 5)
Even the documentation could be easily done via interpolation. |
Such as:
For example,
margin-block-start
is basically equivalent tomargin-top
except it's aware of flow direction and text direction.There's more to these than just dimensional props, see this spec – note the TOC on the left, the new values for
text-align
, the newlogical
keyword, etc.cc @Lasering
The text was updated successfully, but these errors were encountered: