Class: Psd2html::PsConvertor::Text

Inherits:
Convertor
  • Object
show all
Defined in:
lib/psd2html/psconvertor/text.rb

Direct Known Subclasses

TextLink

Constant Summary

Constants inherited from Convertor

Convertor::CSS_HASH_BASE, Convertor::CSS_TPL, Convertor::HTML_HASH_BASE, Convertor::HTML_TPL

Instance Attribute Summary

Attributes inherited from Convertor

#childrenConvertors, #index, #parentConvertor, #psNode

Instance Method Summary collapse

Methods inherited from Convertor

#css_map, #curleft, #curtop, #get_css_tpl, #get_html_tpl, #guid, #initialize, #render_css, #render_html, #sync_css, #sync_html

Constructor Details

This class inherits a constructor from Psd2html::Convertor

Instance Method Details

#css_skeletonObject



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/psd2html/psconvertor/text.rb', line 4

def css_skeleton
	cssRenderData = {
	"classname" => "text-#{guid}",
	"styles" => {
		"position" => "absolute",
		"display" => "inline-block",
		"width" => "#{@psNode.width+2}px",
		"height" => "#{@psNode.height+2}px",
		"left" => curleft,
		"top" => curtop,
		"z-index" => "#{@psNode.depth}#{@parentConvertor.childrenConvertors.length - @index.to_i}"
	}
}
@psNode.text[:font][:css].split(";").each do |styleString|
	styleKey = styleString.split(":")[0]
	styleValue = styleString.split(":")[1]
	cssRenderData["styles"][styleKey] = css_hook(styleValue)
end
	cssRenderData = CSS_HASH_BASE.merge(cssRenderData)
end

#html_skeletonObject



24
25
26
27
28
29
30
31
32
33
# File 'lib/psd2html/psconvertor/text.rb', line 24

def html_skeleton
	htmlRenderData = {
		"attributes" => {
		"class" => "text-#{guid}",
	},
	"tag" => "span",
	"content" => @psNode.text[:value]
	}
	htmlRenderData = HTML_HASH_BASE.merge(htmlRenderData)
end