From 0298e0c88db2900fb980d2dfa552ef3fe7a11b3e Mon Sep 17 00:00:00 2001 From: Oded Niv Date: Fri, 17 Mar 2017 18:07:35 +0200 Subject: [PATCH] add line-height to glyph's container --- lib/fontcustom/generator/template.rb | 11 +++++++++++ lib/fontcustom/templates/_fontcustom-rails.scss | 5 +++++ lib/fontcustom/templates/_fontcustom.scss | 5 +++++ lib/fontcustom/templates/fontcustom-preview.html | 5 +++++ lib/fontcustom/templates/fontcustom.css | 5 +++++ 5 files changed, 31 insertions(+) diff --git a/lib/fontcustom/generator/template.rb b/lib/fontcustom/generator/template.rb index d7f107c5..8d492104 100644 --- a/lib/fontcustom/generator/template.rb +++ b/lib/fontcustom/generator/template.rb @@ -181,6 +181,13 @@ def woff_base64 Base64.encode64(File.binread(File.join(woff_path))).gsub("\n", "") end + def glyph_container_selectors + output = @glyphs.map do |name, value| + @options[:css_selector].sub("{{glyph}}", name.to_s) + end + output.join ",\n" + end + def glyph_selectors output = @glyphs.map do |name, value| @options[:css_selector].sub("{{glyph}}", name.to_s) + ":before" @@ -188,6 +195,10 @@ def glyph_selectors output.join ",\n" end + def glyph_container_properties +%Q| line-height: 1;| + end + def glyph_properties %Q| display: inline-block; font-family: "#{font_name}"; diff --git a/lib/fontcustom/templates/_fontcustom-rails.scss b/lib/fontcustom/templates/_fontcustom-rails.scss index cc162107..db5cd61e 100644 --- a/lib/fontcustom/templates/_fontcustom-rails.scss +++ b/lib/fontcustom/templates/_fontcustom-rails.scss @@ -11,4 +11,9 @@ <%= glyph_properties %> } +[data-icon], +<%= glyph_container_selectors %> { +<%= glyph_container_properties %> +} + <%= glyphs %> diff --git a/lib/fontcustom/templates/_fontcustom.scss b/lib/fontcustom/templates/_fontcustom.scss index c8c775b8..ba97d9e5 100644 --- a/lib/fontcustom/templates/_fontcustom.scss +++ b/lib/fontcustom/templates/_fontcustom.scss @@ -11,6 +11,11 @@ <%= glyph_properties %> } +[data-icon], +<%= glyph_container_selectors %> { +<%= glyph_container_properties %> +} + <%= glyphs %> <% @glyphs.each do |name, value| %> $font-<%= font_name.gsub(/[^\w\d_]/, '-') %>-<%= name.to_s %>: "\<%= value[:codepoint].to_s(16) %>";<% end %> diff --git a/lib/fontcustom/templates/fontcustom-preview.html b/lib/fontcustom/templates/fontcustom-preview.html index b640ffab..9f033517 100644 --- a/lib/fontcustom/templates/fontcustom-preview.html +++ b/lib/fontcustom/templates/fontcustom-preview.html @@ -130,6 +130,11 @@ <%= glyph_properties %> } + [data-icon], + <%= glyph_container_selectors %> { + <%= glyph_container_properties %> + } + <%= glyphs %> diff --git a/lib/fontcustom/templates/fontcustom.css b/lib/fontcustom/templates/fontcustom.css index f5dfd6e2..690b827a 100644 --- a/lib/fontcustom/templates/fontcustom.css +++ b/lib/fontcustom/templates/fontcustom.css @@ -11,4 +11,9 @@ <%= glyph_properties %> } +[data-icon], +<%= glyph_container_selectors %> { +<%= glyph_container_properties %> +} + <%= glyphs %>