bhauman / devcards

Devcards aims to provide a visual REPL experience for ClojureScript
1.53k stars 116 forks source link

Add an option for changing background color of card #44

Closed codebeige closed 8 years ago

codebeige commented 8 years ago

When styling a component outside of its original context it is often desirable to do it against a appropriate background color. In such cases it would be great to allow setting the background of the actual card as an option like so:

(devcard white-thingy
"I need a dark surrounding"
(sab/html [:div {:style {:background "#fff"}} "Can you see my background?"])
{}
{:background "#333"})
bhauman commented 8 years ago

I'm thinking that adding a :classname option is a good way to go here.

But just so you know you can use CSS to color of the background for a whole namespace like this:

.your_munged-name_space .com-rigsomelight-devcards_rendered-card {
  background-color: black;
}

I think that is enough specificity.

codebeige commented 8 years ago

I totally agree that a :classname option would be a good thing to have here. Maybe even a more general :attributes map?

I want to keep the default styling for most of the cards (also testcards and markdown cards), but needed a way to render some cards differently. I worked around it so far by wrapping it inside an additional component. An option would be much more convenient, though.