Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/maful/ruby-phosphor-icons
Phosphor Icons for Ruby and Rails
https://github.com/maful/ruby-phosphor-icons
gem hacktoberfest icon phosphor-icons rails ruby
Last synced: 4 days ago
JSON representation
Phosphor Icons for Ruby and Rails
- Host: GitHub
- URL: https://github.com/maful/ruby-phosphor-icons
- Owner: maful
- License: mit
- Created: 2023-06-22T01:19:31.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-07-24T00:39:30.000Z (4 months ago)
- Last Synced: 2024-10-29T09:07:36.249Z (22 days ago)
- Topics: gem, hacktoberfest, icon, phosphor-icons, rails, ruby
- Language: Ruby
- Homepage:
- Size: 52.7 KB
- Stars: 13
- Watchers: 1
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# Ruby Phosphor Icons
A gem to easily include [Phosphor Icons](https://phosphoricons.com) in your Ruby and Rails apps.
For a full list of available icons see [the assets directory](https://github.com/phosphor-icons/core/tree/c67d7a849f450be1bfe64fd5820471e4019e5ff0/assets) or preview them at [phosphoricons.com](https://phosphoricons.com/).
## Requirements
- Ruby 2.7 or higher
## Installation
Install the gem and add to the application's Gemfile by executing:
```sh
bundle add phosphor_icons
```or add this in your Gemfile
```rb
gem "phosphor_icons"
```## Usage
```ruby
require "phosphor_icons"icon = PhosphorIcons::Icon.new("alarm")
icon.to_svg
#
```If you are using Ruby on Rails, you can use `phosphor_icon` helper in your views directly
```erb
<%= phosphor_icon "alarm", class: "h-5 w-5" %>
<%= phosphor_icon "x", height: 48 %>
```## Documentation
The `Icon` 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 Phosphor Icon you want to use. For example `alarm`. [Full list of icons](https://phosphoricons.com)
### Options
* `:style` - Apply a specific style to the icon. Available options are `regular` (default), `bold`, `light`, `duotone`, `fill` and `thin`.
* `:height` - When setting the height to a number, the icon will scale to that size. For example, passing `24`, 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 `24`, will calculate the width based on the icon's natural size.### Attributes
Once initialized, you can read a few properties from the icon.
#### `symbol`
Returns the string of the symbol name
```rb
icon = PhosphorIcons::Icon.new("alarm")
icon.symbol
# "alarm"
```#### `style`
Returns the style of the icon
```rb
icon = PhosphorIcons::Icon.new("alarm", style: :bold)
icon.style
# "bold"
```#### `path`
Path returns the string representation of the path of the icon.
```rb
icon = PhosphorIcons::Icon.new("alarm")
icon.path
#
```#### `options`
This is a hash of all the `options` that will be added to the output tag.
```rb
icon = PhosphorIcons::Icon.new("alarm")
icon.options
# {:class=>"phosphor-icon", :viewBox=>"0 0 256 256", :xmlns=>"http://www.w3.org/2000/svg", :fill=>"currentColor", :width=>24, :height=>24}
```#### `width`
Width is the icon's true width.
```rb
icon = PhosphorIcons::Icon.new("alarm", width: 24)
icon.height
# 24
```#### `height`
Height is the icon's true height.
```rb
icon = PhosphorIcons::Icon.new("alarm", height: 24)
icon.height
# 24
```### Methods
#### `to_svg`
Returns a string of the svg tag
```rb
icon = PhosphorIcons::Icon.new("alarm")
icon.to_svg
#
```## Development
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
## Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/maful/ruby-phosphor-icons. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/maful/ruby-phosphor-icons/blob/main/CODE_OF_CONDUCT.md).
## License
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
## Code of Conduct
Everyone interacting in the PhosphorIcons project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/maful/ruby-phosphor-icons/blob/main/CODE_OF_CONDUCT.md).