-
Notifications
You must be signed in to change notification settings - Fork 422
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SCSS content variables like Font Awesome #151
Comments
You can do this with a custom template. For instance in my template I have: // Variables just for the content value
<% @data[:glyphs].each_with_index do |name, index| %>
$font-bgr_icon-<%= name %>: "\<%= (61696+index).to_s(16) %>";<% end %> Which results in SASS: $font-bgr_icon-authors: "\f100";
$font-bgr_icon-comments-background: "\f101";
$font-bgr_icon-comments-count: "\f102"; |
@cfg Thanks for the template code. However, when I tried it, something didn’t work on my system. This code would go in a file "my-custom-template.yml" correct – with a link to it in fontcustom.yml? Appreciate your help, |
Sorry that the code I was using for an earlier verison. I've since upgraded to 1.3 and had to upgrade my templates to account for changes in variables. My directory structure is probably not ideal.
A snippet from one of my .scss template files ( <%
# Some common variables that I've found useful
# the font name, including the hash. but with no extension
bgr_base_file_name = File.basename @manifest[:fonts].first, File.extname(@manifest[:fonts].first)
# re-define variables to make fontcustom updates easier
bgr_css_prefix = @options[:css_prefix]
bgr_css_selector = @options[:css_selector]
bgr_file_name = if @options[:preprocessor_path]
File.join @options[:preprocessor_path], bgr_base_file_name
else
bgr_base_file_name
end
%>
// extend-only definitions for every glyph
<% @glyphs.each do |name, value| %>
%<%= bgr_css_prefix + name.to_s %> { content: "\<%= value[:codepoint].to_s(16) %>"; }<% end %>
// SASS variables to use for content
<% @glyphs.each do |name, value| %>
$font-bgr_icon-<%= name.to_s %>: "\<%= value[:codepoint].to_s(16) %>";<% end %> I run fontcustom out of the font_name: bgr
css_prefix: icon-
# preprocessor_path: ""
autowidth: true
no_hash: true
debug: false
quiet: false
templates: [ _bgr-font-variables.scss ]
input:
vectors: font-vectors
output:
fonts: ../fonts
css: ../sass
preview: ../fonts |
@webinsation You'll want to save your custom template as a regular SCSS (just with a bit of ERB sprinkled in). Add this file to the input:
vectors: foo
templates: path/to/templates
templates: [ preview, custom.scss ] # name the scss file whatever you want |
Added in 1.3.4. |
I.e. something like this in the generated scss file:
The text was updated successfully, but these errors were encountered: