-
-
Notifications
You must be signed in to change notification settings - Fork 44
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
Parent method in conditional CSS #79
Comments
I can't remember if there's a way to do this with the existing DSL or not. If not, the good news is that it will be trivial to add as the underlying mechanics are already in place to support it. It might just need a PR to wire it up with a prepend value. So you'd just want to end up with a value of |
I wanted this functionality too, and independently re-invented it as an This is what I came up with, which would be an trivial addition to
Until this feature is implemented in
|
@japgolly What is the status of this? The issue is quite old, perhaps this feature is already implement? If so please point me to the right place. Otherwise, what do you think about including this into the library? I've extended it a bit: import scalacss.internal.{Compose, StyleA}
import scalacss.internal.DslBase.ToStyle
trait AugmentedStylesheetInline extends scalacss.StyleSheet.Inline {
import dsl._
def ancestor(p: StyleA)(t: ToStyle*)(implicit c: Compose): Style.UnsafeExt = unsafeParent(s".${p.htmlClass}")(t: _*)
def parent(p: StyleA)(t: ToStyle*)(implicit c: Compose): Style.UnsafeExt = unsafeParent(s".${p.htmlClass} >")(t: _*)
def unsafeParent(p: String)(t: ToStyle*)(implicit c: Compose): Style.UnsafeExt = unsafeExt(p + " " + _)(t: _*)
} Named it just In any case, I can make a PR, unless there is a reason you wouldn't want such change introduced? |
Use case: we need to use button hovers on desktop only, so we can detect desktop devices and add class "no-touch" to html tag.
CSS should be:
It would be fine, if we had some parent() method for ampersand, e.g.
The text was updated successfully, but these errors were encountered: