garden
garden copied to clipboard
Re-add Object/toString CSSColor implementation
Continued from: https://github.com/noprompt/garden/commit/eb16db635d47a4a2634863669fca809a6088316f#commitcomment-4614132
Commit eb16db635d47a4a2634863669fca809a6088316f included the following hunk:
- #+clj Object #+cljs default
- (toString [this]
- (as-hex this)))
+ ;;Introduces an infinite loop when as-hex throws an exception
+ ;;Object
+ ;;(toString [this]
+ ;; (as-hex this))
This was presumably done in the interest of ClojureScript compatibility, however, the implicit as-hex
string conversion of CSSColor instances is very convenient:
(css [:elem {:box-shadow (str "0px 1px 1px " deep-blue)}])
In the interests of bringing back this feature I propose either:
- Change as-hex and related functions to not throw Exceptions in favor of using default values and clipping out-of-bound values
- Wrap
(as-hex this)
in a try catch and return a default string.
This is not a major issue, of course, but it would be nice.
Thanks!
Right I caught an infinite loop while migrating this part to ClojureScript. It's not strictly needed for ClojureScript compatibility but just commented it waiting for a better solution.
Have you tried something like {:box-shadow [[0 (px 1) (px 1) deep-blue]]}
? It looks like it does what you expect.
Oh, wrapping with another vector suppresses commas? Very useful, I should pay more attention.
I won't mind if you close this issue, but if you are looking to reinstate a toString we could keep it open.
I'll let @noprompt comment on that, I personnaly don't really have an opinion :)
Oh, wrapping with another vector suppresses commas?
Yes [1 2 3] => 1, 2, 3
and [[1 2] [3 4]] => 1 2, 3 4
. Also, I agree it is/was nice. In general I think the garden.color
namespace is the most in need of some attention (next to the compiler). I've been a bit on the busy side recently (just started a new job) and without an internet connection at home (the horror) so if anyone wants to look in to this that'd be awesome. Pull requests are always welcome and I know both of you are skilled programmers. :-)