Abstracting out two lines of code in Coffeescript
I'd say your abstracted function looks OK - it's up to the caller to supply the right height. That's the abstraction. The function doesn't have to know exactly what it's looking at, it just needs an element and (optionally) a height.

So you either call:

@computeStyle componentA.element, componentA.height * 50


or

@computeStyle someElement, componentB?.height


if I'm not mistaken. Something like that anyway.

I'd be more worried about the magic width/height values in the function, to be honest. And I'd encourage you to use is rather than == - both compile into === so there's zero difference, but I'd use the more coffeescript'y is.

Oh, and you have an error in your else if conditional: You're referencing element, but in your abstracted function, it's called componentElement

Incidentally, since returns are implicit at the exit point of a function, and object literals can be written quite tersely, you can reduce your function to this:

computeStyle = (componentElement, height) -&gt;
  switch componentElement.type
    when 'table'
      height: height or 600
    when 'single_value'
      height: 200
      width: 800
    else
      {}


or even more tersely:

computeStyle = (componentElement, height) -&gt;
  switch componentElement.type
    when 'table' then height: height or 600
    when 'single_value' then height: 200, width: 800
    else {}