Closed dakom closed 4 years ago
You can do this:
.class(["min-h-screen", "flex", "items-center", "justify-center", "bg-gray-50", "py-12", "px-4", "sm:px-6", "lg:px-8"])
Would there be any significant disadvantage with a string-based interface as mentioned by David?
Besides looking cleaner and being faster to type there probably would be other benefits.
For example, we could use the 'format' macro to generate the string.
@d4h0 You can use .attribute("class", "foo bar qux")
if you really want to use spaces.
But it's easier to use .class
(it's also better performance if the classes aren't static):
// Better
.class([
&*FOO,
&*BAR,
&*QUX,
])
// Worse
.attribute("class", &format!("{} {} {}", &*FOO, &*BAR, &*QUX))
My thinking was more something like:
.class(format!("{0}-foo {0}-bar {0}-baz", theme))
And conditional activation/deactivation of classes maybe also would be easier (not sure, however, if this all makes sense. I just finished reading the Rust book).
But I guess .attribute("class", ...)
would be good enough, if this isn't needed very often.
@d4h0 That doesn't seem like a good idea to me. If you want themes, you're far better off creating classes using class!
and then either putting the classes into a signal or passing them as arguments to render
. You can also use a mixin to make this easier, and use a struct to organize the classes.
@Pauan: Okay, thanks, I'll keep that in mind.
Can this be supported?
e.g. using TailwindCSS, this:
instead of this: