svg-clj icon indicating copy to clipboard operation
svg-clj copied to clipboard

alternate arity to give full customization for attributes of an object.

Open AbhinavOmprakash opened this issue 4 years ago • 2 comments
trafficstars

I don't know if this is a design decision but it would be nice to have control over the font size and text-anchor spot. in elements like the following. I'd be happy to implement them.

(defn text
  [text]
  [:text {:x 0
          :y 0
          :font-size 12
          :text-anchor "middle"
          :dominant-baseline "middle"} text])

(defn label
  [font-size text]
  [:text 
   {:x 0 :y 0 
    :style {:font-family "Verdana"
            :text-anchor "middle"
            :dominant-baseline "middle"
            :font-size font-size}} text])

AbhinavOmprakash avatar Jul 08 '21 14:07 AbhinavOmprakash

This is an issue I'll leave open for a bit of discussion.

First up, I admit that label function is ... not great design.

I would like to leave the text function very simple. The intent is to allow the user to transform the element with tf/style as follows:

(-> (text "Some example text")
    (tf/style {:text-anchor "start"
               :font-size 16})))

A user could very easily make their own helper fn with that pattern, giving them maximum freedom for building up the elements they want.

But, the label function is already a 'composite' element and doesn't have to be restricted. I say go ahead and build your solution for the label function, but please leave the text element alone.

I will give thought to the default values for the text properties though.

adam-james-v avatar Jul 08 '21 16:07 adam-james-v

that does make sense. I didn't notice the tf/style in the examples. that's on me.

if the user can change the default values, don't sweat it so much.

AbhinavOmprakash avatar Jul 08 '21 16:07 AbhinavOmprakash