Class: Megatron::GridHelper::Grid
- Defined in:
- app/helpers/megatron/grid_helper.rb
Constant Summary collapse
- DEFAULTS =
{ tag: :div, match_gutters: false }
Instance Method Summary collapse
- #add_media_classes(breakpoint, sizes) ⇒ Object
- #cell(*args, &block) ⇒ Object
- #cell_classes(args, options = {}) ⇒ Object
- #display(body) ⇒ Object
- #grid_classes ⇒ Object
-
#initialize(options = {}) ⇒ Grid
constructor
A new instance of Grid.
Methods inherited from Helper
Constructor Details
Instance Method Details
#add_media_classes(breakpoint, sizes) ⇒ Object
39 40 41 |
# File 'app/helpers/megatron/grid_helper.rb', line 39 def add_media_classes(breakpoint, sizes) sizes.empty? ? '' : width(*[breakpoint, *sizes]) end |
#cell(*args, &block) ⇒ Object
18 19 20 21 22 |
# File 'app/helpers/megatron/grid_helper.rb', line 18 def cell(*args, &block) = (args) [:tag] ||= :div content_tag [:tag], class: cell_classes(args, ), &block end |
#cell_classes(args, options = {}) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'app/helpers/megatron/grid_helper.rb', line 24 def cell_classes(args, ={}) classes = ['grid-cell'] if !args.empty? or !.empty? classes << width(*args) if !args.empty? classes << [:class] if [:class] classes << add_media_classes(:xsmall, [:xsmall]) if [:xsmall] classes << add_media_classes(:small, [:small]) if [:small] classes << add_media_classes(:medium, [:medium]) if [:medium] classes << add_media_classes(:large, [:large]) if [:large] classes << add_media_classes(:xlarge, [:xlarge]) if [:xlarge] end classes end |
#display(body) ⇒ Object
14 15 16 |
# File 'app/helpers/megatron/grid_helper.rb', line 14 def display(body) content_tag(@options[:tag], class: grid_classes) { body } end |
#grid_classes ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'app/helpers/megatron/grid_helper.rb', line 43 def grid_classes classes = ['grid'] classes << "align-#{@options[:valign]}" if @options[:valign] classes << "align-#{@options[:align]}" if @options[:align] classes << 'match-gutters' if @options[:match_gutters] if @options[:gutters] if @options[:gutters].to_s == 'none' @options[:gutters] = 'no' end classes << "#{@options[:gutters]}-gutter" unless @options[:gutters].to_s == 'medium' end classes << @options[:class] if @options[:class] classes end |