Sha256: 903dc690fd300aa9c1d6e7051c42f6b98dde3aa0f53bc5e1a1b818645fb37147

Contents?: true

Size: 1.93 KB

Versions: 19

Compression:

Stored size: 1.93 KB

Contents

<%
#         576   768   992   1200
#          |     |     |     |
# BS4   xs | sm  | md  | lg  | xl
# BS3      xs    | sm  | md  | lg

# Docs:
# BS4 : https://getbootstrap.com/docs/4.1/layout/overview/#responsive-breakpoints
# BS3 : https://getbootstrap.com/docs/3.3/css/#grid

# Basic idea is: default layout concerns desktop and tablet.
# There is a small difference between 3 and 4 regarding tablets:
# - BS4 treats tablets as desktop (expected behaviour)
# - BS3 treats tablets as mobile (wrong behaviour for us)

# Desktop
size = component[:attributes].dig(:size, :value)
offset = component[:attributes].dig(:offset, :value)
classes  = " col-lg-#{size} offset-lg-#{offset} col-lg-offset-#{offset}" # BS4 desktop+, BS3 desktop large

# Tablet override
# - md for BS4
# - sm for BS3
if component[:attributes].dig(:tablet, :value, :enabled, :value)
  size = component[:attributes].dig(:tablet, :value, :size, :value)
  offset = component[:attributes].dig(:tablet, :value, :offset, :value)
  classes += " col-md-#{size} col-md-offset-#{offset} offset-md-#{offset}" # BS4, breaks small desktop for BS3
  classes += " col-sm-#{size} col-sm-offset-#{offset} offset-sm-#{offset}" # BS3, breaks mobile landscape for BS4
else
  # No tablet override
  classes += " col-md-#{size} offset-md-#{offset} col-md-offset-#{offset}" # BS4 tablet+, BS3 desktop only
end

# Mobile override
# - no class for BS4 (xs disappears, sm is treated in the same way)
# - xs for BS3
if component[:attributes].dig(:mobile, :value, :enabled, :value)
  size = component[:attributes].dig(:mobile, :value, :size, :value)
  offset = component[:attributes].dig(:mobile, :value, :offset, :value)
  classes += " col-#{size} offset-#{offset}" # BS4, does nothing for BS3
  classes += " col-xs-#{size} col-xs-offset-#{offset}" # BS3, does nothing for BS4
end
%>
<div class="<%= classes %> <%= promethee_class_for component %>">
  <%= render 'promethee/show/components', components: component[:children] %>
</div>

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
promethee-4.1.9 app/views/promethee/components/column/_show.html.erb
promethee-4.1.8 app/views/promethee/components/column/_show.html.erb
promethee-4.1.7 app/views/promethee/components/column/_show.html.erb
promethee-4.1.6 app/views/promethee/components/column/_show.html.erb
promethee-4.1.5 app/views/promethee/components/column/_show.html.erb
promethee-4.1.4 app/views/promethee/components/column/_show.html.erb
promethee-4.1.3 app/views/promethee/components/column/_show.html.erb
promethee-4.1.2 app/views/promethee/components/column/_show.html.erb
promethee-4.1.1 app/views/promethee/components/column/_show.html.erb
promethee-4.1.0 app/views/promethee/components/column/_show.html.erb
promethee-4.0.8 app/views/promethee/components/column/_show.html.erb
promethee-4.0.7 app/views/promethee/components/column/_show.html.erb
promethee-4.0.6 app/views/promethee/components/column/_show.html.erb
promethee-4.0.5 app/views/promethee/components/column/_show.html.erb
promethee-4.0.4 app/views/promethee/components/column/_show.html.erb
promethee-4.0.3 app/views/promethee/components/column/_show.html.erb
promethee-4.0.2 app/views/promethee/components/column/_show.html.erb
promethee-4.0.1 app/views/promethee/components/column/_show.html.erb
promethee-4.0.0 app/views/promethee/components/column/_show.html.erb