templates/_snippets/sections/general_section_settings.html.twig line 1

Open in your IDE?
  1. {# ----------------------------- PARAMÈTRAGES ----------------------------- #}
  2. {# ------------------------------------------------------------------------ #}
  3. {# Appliquer uniquement les styles réellement renseignés #}
  4. {% set typeTitleSection = (content.typeTitleSection is defined and content.typeTitleSection is not empty) ? content.typeTitleSection : 'h2' %}
  5. {% set paddingUnitSection = content.paddingUnitSection|default('px') %}
  6. {% set bordersRadiusUnitSection = content.bordersRadiusUnitSection|default('px') %}
  7. {% set titleSizeUnitSection = content.titleSizeUnitSection|default('px') %}
  8. {% set pictogramBorderRadiusUnitSection = content.pictogramBorderRadiusUnitSection|default('px') %}
  9. {% set pictogramBorderSizeUnitSection = content.pictogramBorderSizeUnitSection|default('px') %}
  10. {% set sectionSettings = {
  11. 'background-color': (content.backgroundColorSection is defined and content.backgroundColorSection is not empty) ? content.backgroundColorSection : null,
  12. 'padding': (content.paddingTopBottomSection is defined and content.paddingLeftRightSection is defined) ? content.paddingTopBottomSection ~ paddingUnitSection ~ ' ' ~ content.paddingLeftRightSection ~ paddingUnitSection : null,
  13. 'border-radius': (content.bordersRadiusSection is defined and content.bordersRadiusSection is not null) ? content.bordersRadiusSection ~ bordersRadiusUnitSection : null,
  14. }|filter((value) => value is not null) %}
  15. {% set titleSectionSettings = {
  16. 'font-weight': (content.weightTitleSection is defined and content.weightTitleSection is not empty) ? content.weightTitleSection : null,
  17. 'font-size': (content.titleSizeSection is defined and content.titleSizeSection is not null) ? content.titleSizeSection ~ titleSizeUnitSection : null,
  18. }|filter((value) => value is not null) %}
  19. {% set pictogramSectionSettings = {
  20. 'color': (content.pictogramTitleColorSection is defined and content.pictogramTitleColorSection is not empty) ? content.pictogramTitleColorSection : null,
  21. 'background-color': (content.pictogramTitleBackgroundColorSection is defined and content.pictogramTitleBackgroundColorSection is not empty) ? content.pictogramTitleBackgroundColorSection : null,
  22. 'border-radius': (content.pictogramBorderRadiusSection is defined and content.pictogramBorderRadiusSection is not null) ? content.pictogramBorderRadiusSection ~ pictogramBorderRadiusUnitSection : null,
  23. 'border': (content.pictogramBorderSizeSection is defined and content.pictogramBorderSizeSection is not null and content.pictogramBorderColorSection is defined and content.pictogramBorderColorSection is not empty) ? content.pictogramBorderSizeSection ~ pictogramBorderSizeUnitSection ~ ' solid ' ~ content.pictogramBorderColorSection : null,
  24. }|filter((value) => value is not null) %}
  25. {% set shouldRenderTitleStyles = titleSectionSettings is not empty or pictogramSectionSettings is not empty %}
  26. <style>
  27. {% if sectionSettings is not empty %}
  28. #{{ id }} {
  29. {{ sectionSettings|map((value, key) => key ~ ':' ~ value)|join('; ') }};
  30. }
  31. {% endif %}
  32. {% if shouldRenderTitleStyles %}
  33. #{{ id }} {{ typeTitleSection }} {
  34. display: inline-flex;
  35. justify-content: flex-start;
  36. align-items: center;
  37. gap: 0.75rem;
  38. {{ titleSectionSettings|map((value, key) => key ~ ':' ~ value)|join('; ') }};
  39. }
  40. {% endif %}
  41. #{{ id }} :is(h1, h2, h3, h4, h5, h6) > .icon {
  42. box-sizing: border-box;
  43. {% if pictogramSectionSettings is not empty %}
  44. {{ pictogramSectionSettings|map((value, key) => key ~ ':' ~ value)|join('; ') }};
  45. {% endif %}
  46. }
  47. #{{ id }} :is(h1, h2, h3, h4, h5, h6) > .icon svg {
  48. padding: 3px;
  49. }
  50. </style>