ndreynolds / ratatouille

A TUI (terminal UI) kit for Elixir
MIT License
752 stars 39 forks source link

Add attributes for Panel #4

Closed iboard closed 5 years ago

iboard commented 5 years ago

I missed the possibility to highlight a panel's title.

With these changes, you can use panel title: "Some Text" as before or pass extra attributes which will be forwarded to the text(...) function for panel's title.

    panel title: { "The Text", [ background: color(:white), color: color(:black)]}
ndreynolds commented 5 years ago

Thanks, I think this is a great addition!

My only thought is that it would be nice to pass the attributes through in a way that allows for them to be documented and validated similarly to the others, and based on the element specs here:

https://github.com/ndreynolds/ratatouille/blob/master/lib/ratatouille/renderer/element.ex#L27

I'm not sure how to do that with the tuple approach. What do you think about passing the attributes via the panel's attributes? E.g.:

panel title: "The Text", title_background: color(:white), title_color: color(:black)

Or allowing title to be passed as a text element, e.g.:

panel title: text(content: "The Text", background: color(:white), color: color(:black))
iboard commented 5 years ago

Yes, you're right. I'll try to solve it this way. I just figured out how the documentation is generated through the macros. Interesting ;-) When done I'll update this PR.

iboard commented 5 years ago

I couldn't figure out how panel title: title( content: "whatever" ) can work. So, I implemented the first way you mentioned

panel title: "Title", color: ..., background: ...

the two new arguments are documented with View.panel

ndreynolds commented 5 years ago

Looks great, thank you very much!