{% comment %} # ----------------------------------------------------------------------------- # ~/_includes/themes/j1/procedures/blocks/get_wave.proc # Liquid PROCEDURE to generate the HTML portion of a wave element # applied to J1 block elements (like footers, banners and panels). # # https://jekyll.one # Copyright (C) 2023 Juergen Adams # # J1 Template is licensed under the MIT License. # See: https://github.com/jekyll-one-org/j1-template/blob/main/LICENSE.md # # ----------------------------------------------------------------------------- # Global procedure. Read RGB category values from j1_categorys.yml and returns # the category found with liquid var category # # Usage: # 1) load (capture) the procedure 'get_wave.proc' # 2) reference (include) the procedure 'get_wave.proc' # 3) assign the 'wave' variable to (hash) data the wave element is # defined. # 4) finally, assign the resulting HTML data (for output) # # Example: # # {% capture get_wave %}themes/{{site.template.name}}/procedures/blocks/get_wave.proc{% endcapture %} # # {% include {{get_wave}} wave=footer_settings.wave %} # {% assign my_wave = {{_wave}} %} # # ----------------------------------------------------------------------------- # Test data: # {{ liquid_var | debug }} # category: {{ item[0] }}: {{ item[1] }} # ----------------------------------------------------------------------------- {% endcomment %} {% comment %} Variables -------------------------------------------------------------------------------- {% endcomment %} {% assign position = include.position %} {% assign wave_settings = include.wave %} {% assign _wave = nil %} {% comment %} Main -------------------------------------------------------------------------------- {% endcomment %} {% comment %} Calculate|Set WAVE scales TODO: Check why corrections of plus:1 or minus:1 are required -------------------------------------------------------------------------------- {% if wave_height > 1 %} {% if position == 'top' %} {% assign translate_y = wave_height|times:-2|plus:1 %} {% assign position_class = 'wave-top' %} {% elsif position == 'bottom' %} {% assign translate_y = wave_height|times:2|minus:1 %} {% assign position_class = 'wave-bottom' %} {% else %} {% assign translate_y = 1 %} {% endif %} {% endif %} -------------------------------------------------------------------------------- {% endcomment %} {% comment %} Calculate|Set WAVE scales -------------------------------------------------------------------------------- {% endcomment %} {% assign wave_height = wave_settings.height %} {% assign wave_height_factor = wave_settings.height|plus:1 %} {% assign min-height = wave_height|times:10|plus:100 %} {% assign padding-value = wave_height|times:10 %} {% capture padding %}{{padding-value}}px{% endcapture %} {% comment %} Disabled translate_y (scale wave) -------------------------------------------------------------------------------- {% endcomment %} {% if wave_height > 1 %} {% if position == 'top' %} {% assign translate_y = 0 %} {% assign position_class = 'wave-top' %} {% elsif position == 'bottom' %} {% assign translate_y = 0 %} {% assign position_class = 'wave-bottom' %} {% else %} {% assign translate_y = 0 %} {% endif %} {% endif %} {% if wave_height > 1 %} {% capture scale %}translate(0,{{translate_y}}) scale(1,1.{{wave_height}}){% endcapture %} {% else %} {% capture scale %}scale(1,1){% endcapture %} {% endif %} {% if wave_settings.background_color == 'auto' %} {% assign wave_background_color = 'var(--bs-body-bg)' %} {% else %} {% assign wave_background_color = wave_settings.background_color %} {% endif %} {% comment %} Set WAVE transformations -------------------------------------------------------------------------------- {% endcomment %} {% assign wave_transforms = wave_settings.transform|normalize_whitespace|split:' ' %} {% assign wave_transform = '' %} {% assign transform_filters = '' %} {% for item in wave_transforms %} {% if item == 'rotate' %} {% capture wave_transform %}rotate(180){% endcapture %} {% elsif item == 'flip-x' %} {% capture wave_transform %}scale(1,-1){% endcapture %} {% elsif item == 'flip-y' %} {% capture wave_transform %}scale(-1,1){% endcapture %} {% else %} {% capture wave_transform %}{% endcapture %} {% endif %} {% capture transform_filters %}{{transform_filters}} {{wave_transform}}{% endcapture %} {% endfor %} {% capture wave_transform %}transform="{{transform_filters}}"{% endcapture %} {% comment %} Set WAVE styles -------------------------------------------------------------------------------- {% endcomment %} {% case wave_settings.style %} {% when 'wave-1' %} {% capture wave %} > {% endcapture %} {% when 'wave-2' %} {% capture wave %} > {% endcapture %} {% when 'wave-3' %} {% capture wave %} > {% endcapture %} {% when 'wave-4' %} {% capture wave %} > {% endcapture %} {% when 'wave-5' %} {% capture wave %} > {% endcapture %} {% else %} {% capture wave %} > {% endcapture %} {% endcase %} {% comment %} Generate WAVE container TODO: Check why corrections of margin-top:-1 or margin-bottom:-1 are required {% capture _wave %}
{{wave}}
{% endcapture %} {% capture _wave %}
{{wave}}
{% endcapture %} -------------------------------------------------------------------------------- {% endcomment %} {% if position == 'top' %} {% capture _wave %}
{{wave}}
{% endcapture %} {% else %} {% capture _wave %}
{{wave}}
{% endcapture %} {% endif %}