templates/components/Spacer/index.twig line 1

Open in your IDE?
  1. {% set spacerClassName = random() %}
  2. {% set className = className ?? '' %}
  3. {% set height = height ?? null %}
  4. {% set mediumHeight = mediumHeight ?? null %}
  5. {% set largeHeight = largeHeight ?? null %}
  6. {% set xlargeHeight = xlargeHeight ?? null %}
  7. {% set width = width ?? null %}
  8. {% set mediumWidth = mediumWidth ?? null %}
  9. {% set largeWidth = largeWidth ?? null %}
  10. {% set xlargeWidth = xlargeWidth ?? null %}
  11. <div class="spacer-{{ spacerClassName }} {{ className }}"></div>
  12. <style>
  13.   {% if height or width %}
  14.     .spacer-{{ spacerClassName }} {
  15.       {% if height %}
  16.         height: {{ height / 16 }}rem;
  17.       {% endif %}
  18.       {% if width %}
  19.         flex: 0 0 {{ width / 16 }}rem; width: {{ width / 16 }}rem;
  20.       {% endif %}
  21.     }
  22.   {% endif %}
  23.   {% if mediumHeight is not null or mediumWidth is not null %}
  24.     @media screen and (min-width: 640px) {
  25.       .spacer-{{ spacerClassName }} {
  26.         {% if mediumHeight is not null %}
  27.           height: {{ mediumHeight / 16 }}rem;
  28.         {% endif %}
  29.         {% if mediumWidth is not null %}
  30.           flex: 0 0 {{ mediumWidth / 16 }}rem; width: {{ mediumWidth / 16 }}rem;
  31.         {% endif %}
  32.       }
  33.     }
  34.   {% endif %}
  35.   {% if largeHeight is not null or largeWidth is not null %}
  36.     @media screen and (min-width: 1024px) {
  37.       .spacer-{{ spacerClassName}} {
  38.         {% if largeHeight is not null %}
  39.           height: {{ largeHeight / 16 }}rem;
  40.         {% endif %}
  41.         {% if largeWidth is not null %}
  42.           flex: 0 0 {{ largeWidth / 16 }}rem; width: {{ largeWidth / 16 }}rem;
  43.         {% endif %}
  44.       }
  45.     }
  46.   {% endif %}
  47.   {% if xlargeHeight is not null or xlargeWidth is not null %}
  48.     @media screen and (min-width: 1200px) {
  49.       .spacer-{{ spacerClassName }} {
  50.         {% if xlargeHeight is not null %}
  51.           height: {{ xlargeHeight / 16 }}rem;
  52.         {% endif %}
  53.         {% if xlargeWidth is not null %}
  54.           flex: 0 0 {{ xlargeWidth / 16 }}rem; width: {{ xlargeWidth / 16 }}rem;
  55.         {% endif %}
  56.       }
  57.     }
  58.   {% endif %}
  59. </style>