From d07942712b3a94f299a5228c31a6c91fc35a0db3 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 25290baa..89220c44 100644 --- a/lib/fontcustom/generator/template.rb +++ b/lib/fontcustom/generator/template.rb @@ -189,6 +189,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) + @pseudo_element @@ -196,6 +203,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 608b5e36..663d13f1 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 87b31d5f..31539ce1 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 932d6414..9cddbf67 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 %>