New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

front_man

Package Overview
Dependencies
Maintainers
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

front_man

  • 0.2.0
  • Rubygems
  • Socket score

Version published
Maintainers
2
Created
Source

Frontman

A gem for easier front-end development in Ruby.

Installation

Add this line to your application's Gemfile:

gem 'front_man'

And then execute:

$ bundle

Middleman

If you're using middleman, add this line to config.rb:

activate :front_man

Usage

Import front_man in your application.scss:

@import 'front_man';

Or if you want to import components manually:

@import 'front_man/z-index';

Make sure the application.scss file has .scss extension (or .sass for Sass syntax). If you have just generated a new Rails app, it may come with a .css file instead. If this file exists, it will be served instead of Sass, so rename it:

$ mv app/assets/stylesheets/application.css app/assets/stylesheets/application.scss

Helper methods

The front_man gem includes several helper methods.

inline_svg(filename)

Renders svg file in a hidden div for later referencing of it's elements; usually used to load a single svg file that consists of all svg files concatenated together.

Example (you can put this at the bottom of your layout (application.html.erb) file:

<%= inline_svg('icons.svg') %>
sprite_tag(filename, options = {})

Works together with inline_svg to serve specific svg file from concatenated file.

Example:

<%= sprite_tag('icon-home', class: 'svgIcon svgIcon-40') %>

You can use css classes to style the icon:

.svgIcon-40 {
  width: 40px;
  height: 40px;
  fill: $base-color; // use fill instead of color
}

All the options passed to sprite_tag are passed on to svg content_tag.

image_set_tag(filename, options = {})

Used to set srcset attribute on img tag.

Example:

image_set_tag('http://placehold.it/1200x600',
  srcset: {
    'http://placehold.it/300x150' => '300w',
    'http://placehold.it/600x300' => '600w',
    'http://placehold.it/1200x600' => '1200w'
  }
)

If you would like to support lazy loading, in conjunction with lazySizes, you just need to add the class lazyload as follows:

image_set_tag('http://placehold.it/1200x600',
  srcset: {
    'http://placehold.it/300x150' => '300w',
    'http://placehold.it/600x300' => '600w',
    'http://placehold.it/1200x600' => '1200w'
  },
  class: 'lazyload'
)

N.B. You would need to ensure the lazySizes script is installed for this to work

Kudos

The conventions laid out in the asset files here were based upon those discussed in the article below. Kudos to @fat.

https://medium.com/@fat/mediums-css-is-actually-pretty-fucking-good-b8e2a6c78b06

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake spec 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.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/DVELP/front_man. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

License

The gem is available as open source under the terms of the MIT License.



DVELP logo

Seoable was created and is maintained by DVELP Ltd.

If you like what you see and would like to hire us or join us, get in touch!

FAQs

Package last updated on 22 Mar 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc