https://github.com/telecta/buttons_for
ActionView Helper for generating Bootstrap buttons.
https://github.com/telecta/buttons_for
bootstrap-buttons fontawesome icons rails
Last synced: 3 months ago
JSON representation
ActionView Helper for generating Bootstrap buttons.
- Host: GitHub
- URL: https://github.com/telecta/buttons_for
- Owner: telecta
- License: mit
- Created: 2015-09-01T05:49:16.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2017-07-07T08:20:49.000Z (almost 8 years ago)
- Last Synced: 2024-03-14T22:10:21.029Z (about 1 year ago)
- Topics: bootstrap-buttons, fontawesome, icons, rails
- Language: Ruby
- Size: 65.4 KB
- Stars: 1
- Watchers: 7
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.txt
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
[travis]: https://travis-ci.org/blacktangent/buttons_for
[codeclimate]: https://codeclimate.com/github/blacktangent/buttons_for
[fontawesome]: https://fortawesome.github.io/Font-Awesome
[fontawesomerails]: https://github.com/bokmann/font-awesome-rails
[coveralls]: https://coveralls.io/r/blacktangent/buttons_for
[rubygems]: https://rubygems.org/gems/buttons_for
[gemnasium]: https://gemnasium.com/blacktangent/buttons_for# ButtonsFor
[][travis]
[][codeclimate]
[][coveralls]
[][rubygems]
[][gemnasium]ActiveView helper to generate Bootstrap buttons and dropdown-buttons.
## Installation
Add this line to your application's Gemfile:
```ruby
gem 'buttons_for'
```And then execute:
$ bundle
Or install it yourself as:
$ gem install buttons_for
Run generator to add I18n locales:
$ rails generate buttons_for:install
The gem depends on [Bootstrap 3](http://getbootstrap.com/) to create buttons and dropdown-buttons. Bring bootstrap into
your project by using [Bootstrap for Sass](https://github.com/twbs/bootstrap-sass) or you preferred method.`buttons_for` depends on [Font Awesome][fontawesome] icon and CSS
framework, bring [Font Awesome][fontawesome] into your project using
[font-awesome-rails][fontawesomerails] or your preferred method.## Screenshot
## Usage
`buttons_for` has multiple helper methods. The API is intentionally made
quite simple and does not support url generation or any advanced
functionallity. It's just ment as a thin wrapper around `link_to` and
should pass the options transparently.The helpers you'll use the most provide buttons with a color and a
leading icon. The following standard buttons can be used: `new`, `edit`,
`delete` and `export`. These buttons are just wrappers around the `button` helper
giving it options containing icon and button class.`buttons_for` also provides a helper for creating dropdown buttons. Use
`dropdown` with a block containing `link` elements to achive this.Example show button menu:
```erb
<%= buttons_for do |b| %>
<%= b.dropdown :actions do %>
<%= b.link "Projects", company_projects_path(@company), icon: "list" %>
<% end %>
<%= b.button t(".lock"), lock_company_path(@company), icon: "lock", class: "btn-default" %>
<%= b.edit edit_company_path(@company) %>
<%= b.delete company_path(@company) %>
<% end %>```
Example index button menu:
```erb
<%= buttons_for do |b| %>
<%= b.new url_for(action: :new) %>
<%= b.export url_for(format: :csv) %>
<% end %>
```## Options
Available options:
* __:label__ - Override standard label.
* __:class__ - Appendse given string to existing CSS classes.
* __:icon__ - Prefix or replace exsiting icon.## Translations
The installer copies the file `buttons_for.en.yml` into your
`config/locales/` directory. Add a corresponding file with your own
locale to translate the buttons.## Sample
Sample applicaiton using `buttons_for` can be found [here](https://github.com/blacktangent/buttons_for-demo).## Development
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake rspec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
## Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/blacktangent/buttons_for. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
## Testing
To test against all supported Rails versions, run:
```
appraisal rake test
```To update all supported Rails to latest patch version:
```
appraisal update
```## License
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).