Octicons gem
Octicons gem to distribute octicons svg
Install
Add this to your Gemfile
gem 'octicons'
Then bundle install
.
Usage
require 'octicons'
icon = Octicons::Octicon.new("x")
icon.to_svg
Documentation
The Octicon
class takes two arguments. The first is the symbol of the icon, and the second is a hash of arguments representing html attributes
symbol
(required)
This is the name of the octicon you want to use. For example alert
. Full list of icons
Options
:height
- When setting the height to a number, the icon will scale to that size. For example, passing 32
, will calculate the width based on the icon's natural size.:width
- When setting the width to a number, the icon will scale to that size. For example, passing 32
, will calculate the width based on the icon's natural size.
If both :width, :height
are passed into the options hash, then the icon will be sized exactly at those dimensions.
Attributes
Once initialized, you can read a few properties from the icon.
symbol
Returns the string of the symbol name
icon = Octicons::Octicon.new("x")
icon.symbol
path
Path returns the string representation of the path of the icon.
icon = Octicons::Octicon.new("x")
icon.path
options
This is a hash of all the options
that will be added to the output tag.
icon = Octicons::Octicon.new("x")
icon.options
width
Width is the icon's true width. Based on the svg view box width. Note, this doesn't change if you scale it up with size options, it only is the natural width of the icon
height
Height is the icon's true height. Based on the svg view box height. Note, this doesn't change if you scale it up with size options, it only is the natural height of the icon
keywords
Returns an array of keywords for the icon. The data comes from the data file in lib. Consider contributing more aliases for the icons.
icon = Octicons::Octicon.new("x")
icon.keywords
Methods
to_svg
Returns a string of the svg tag
icon = Octicons::Octicon.new("x")
icon.to_svg
Documentation
For a full list of options available, see the octicons_gem documentation
License
(c) GitHub, Inc.
When using the GitHub logos, be sure to follow the GitHub logo guidelines.
MIT