From d262b559bb0e4ad5ceda3acffd2223a26d09b78b Mon Sep 17 00:00:00 2001 From: Alex Skrypnyk Date: Mon, 6 Nov 2023 16:31:55 +1100 Subject: [PATCH] Fixed Twig coding standards. --- .twig_cs.php | 15 ++++++- .../00-base/colors/colors.stories.twig | 2 +- .../components/00-base/icon/icon.twig | 2 +- .../components/01-atoms/button/button.twig | 4 +- .../components/01-atoms/chip/chip.twig | 2 +- .../components/01-atoms/link/link.twig | 2 +- .../components/01-atoms/tag/tag.twig | 2 +- .../02-molecules/attachment/attachment.twig | 2 +- .../02-molecules/breadcrumb/breadcrumb.twig | 6 +-- .../02-molecules/callout/callout.twig | 2 +- .../form-element/form-element.twig | 11 +++-- .../group-filter/group-filter.twig | 6 +-- .../components/02-molecules/logo/logo.twig | 2 +- .../navigation-card/navigation-card.twig | 4 +- .../publication-card/publication-card.twig | 2 +- .../components/02-molecules/quote/quote.twig | 4 +- .../service-card/service-card.twig | 4 +- .../single-filter/single-filter.twig | 4 +- .../02-molecules/tag-list/tag-list.twig | 4 +- .../components/03-organisms/alert/alert.twig | 2 +- .../03-organisms/banner/banner.twig | 4 +- .../03-organisms/campaign/campaign.twig | 4 +- .../03-organisms/header/header.twig | 2 +- .../03-organisms/message/message.twig | 2 +- .../03-organisms/navigation/navigation.twig | 4 +- .../components/03-organisms/slider/slide.twig | 4 +- .../social-links/social-links.twig | 2 +- ...-civictheme-secondary-navigation.html.twig | 2 +- .../templates/block/block.html.twig | 6 +-- .../field/field--field-c-n-date.html.twig | 6 --- .../templates/form/checkboxes.html.twig | 2 +- .../templates/form/radios.html.twig | 3 +- .../templates/layout/html.html.twig | 42 +++++++++---------- .../templates/layout/page.html.twig | 4 +- .../paragraph--civictheme-iframe.html.twig | 2 +- .../templates/views/views-view.html.twig | 2 +- 36 files changed, 86 insertions(+), 87 deletions(-) diff --git a/.twig_cs.php b/.twig_cs.php index 2097644a5..15cc29b95 100644 --- a/.twig_cs.php +++ b/.twig_cs.php @@ -4,11 +4,22 @@ use FriendsOfTwig\Twigcs; +// Exclude directories with compiled components. +$excluded = [ + '.components-civictheme', + 'components_combined', +]; + +// Filter-out stories templates +$filter = function (\SplFileInfo $fileInfo) { + return !str_contains($fileInfo->getFilename(), 'stories'); +}; + return Twigcs\Config\Config::create() ->setName('custom-config') ->setSeverity('error') ->setReporter('console') ->setRuleSet(Twigcs\Ruleset\Official::class) ->addFinder(Twigcs\Finder\TemplateFinder::create()->in(__DIR__ . '/web/modules/custom')) - ->addFinder(Twigcs\Finder\TemplateFinder::create()->in(__DIR__ . '/web/themes/contrib/civictheme')) - ->addFinder(Twigcs\Finder\TemplateFinder::create()->in(__DIR__ . '/web/themes/custom')); + ->addFinder(Twigcs\Finder\TemplateFinder::create()->in(__DIR__ . '/web/themes/contrib/civictheme')->exclude($excluded)->filter($filter)) + ->addFinder(Twigcs\Finder\TemplateFinder::create()->in(__DIR__ . '/web/themes/custom')->exclude($excluded)->filter($filter)); diff --git a/web/themes/contrib/civictheme/civictheme_library/components/00-base/colors/colors.stories.twig b/web/themes/contrib/civictheme/civictheme_library/components/00-base/colors/colors.stories.twig index 68a1d9d4a..86d8a5dc0 100644 --- a/web/themes/contrib/civictheme/civictheme_library/components/00-base/colors/colors.stories.twig +++ b/web/themes/contrib/civictheme/civictheme_library/components/00-base/colors/colors.stories.twig @@ -21,7 +21,7 @@
{% for color_name, color in colors %}
- {{ color_name|capitalize|replace({'-':' '}) }} + {{ color_name|capitalize|replace({'-': ' '}) }}
{% endfor %}
diff --git a/web/themes/contrib/civictheme/civictheme_library/components/00-base/icon/icon.twig b/web/themes/contrib/civictheme/civictheme_library/components/00-base/icon/icon.twig index 7405e713d..b22d4bef4 100644 --- a/web/themes/contrib/civictheme/civictheme_library/components/00-base/icon/icon.twig +++ b/web/themes/contrib/civictheme/civictheme_library/components/00-base/icon/icon.twig @@ -18,7 +18,7 @@ {% if symbol is not empty %} {% set source = source(assets_dir ~ '/icons/' ~ symbol ~ '.svg', true) %} {% if source is not empty %} - {% set attributes = 'class="ct-icon ' ~ (size ? 'ct-icon--size-' ~ size : '') ~ ' ' ~ modifier_class|default('') ~ '" aria-hidden="true" role="img" ' ~ (alt is defined ? 'alt="' ~ alt ~ '"' : '') ~ attributes|default('') %} + {% set attributes = 'class="ct-icon ' ~ (size ? 'ct-icon--size-' ~ size : '') ~ ' ' ~ modifier_class|default('') ~ '" aria-hidden="true" role="img" ' ~ (alt is defined ? 'alt="' ~ alt ~ '"' : '') ~ attributes|default('') %} {{ source|replace({' diff --git a/web/themes/contrib/civictheme/civictheme_library/components/01-atoms/chip/chip.twig b/web/themes/contrib/civictheme/civictheme_library/components/01-atoms/chip/chip.twig index e3af3e1b8..d9b4c44fd 100644 --- a/web/themes/contrib/civictheme/civictheme_library/components/01-atoms/chip/chip.twig +++ b/web/themes/contrib/civictheme/civictheme_library/components/01-atoms/chip/chip.twig @@ -20,7 +20,7 @@ {% set kind_class = kind ? 'ct-chip--%s'|format(kind) : '' %} {% set size = size in ['large', 'regular', 'small'] ? size : 'regular' %} {% set size_class = 'ct-chip--%s'|format(size) %} -{% set selected_class = is_selected ? 'active' : '' %} +{% set selected_class = is_selected ? 'active' : '' %} {% set multiple_class = is_multiple ? 'ct-chip--multiple' : '' %} {% set theme_class = 'ct-theme-%s'|format(theme|default('light')) %} {% set modifier_class = '%s %s %s %s %s %s'|format(theme_class, kind_class, size_class, selected_class, multiple_class, modifier_class|default('')) %} diff --git a/web/themes/contrib/civictheme/civictheme_library/components/01-atoms/link/link.twig b/web/themes/contrib/civictheme/civictheme_library/components/01-atoms/link/link.twig index aa48e2045..8298f99ef 100644 --- a/web/themes/contrib/civictheme/civictheme_library/components/01-atoms/link/link.twig +++ b/web/themes/contrib/civictheme/civictheme_library/components/01-atoms/link/link.twig @@ -20,7 +20,7 @@ #} {% set text = text|default('') %} -{% set only_icon_class = icon is not empty and text is empty ? 'ct-link--only-icon' : '' %} +{% set only_icon_class = icon is not empty and text is empty ? 'ct-link--only-icon' : '' %} {% set icon_placement = icon_placement in ['before', 'after'] ? icon_placement : 'after' %} {% set is_external_class = is_external ? 'ct-link--external' : '' %} {% set is_active_class = is_active ? 'ct-link--active' : '' %} diff --git a/web/themes/contrib/civictheme/civictheme_library/components/01-atoms/tag/tag.twig b/web/themes/contrib/civictheme/civictheme_library/components/01-atoms/tag/tag.twig index 4caef7c0a..dbfec7c74 100644 --- a/web/themes/contrib/civictheme/civictheme_library/components/01-atoms/tag/tag.twig +++ b/web/themes/contrib/civictheme/civictheme_library/components/01-atoms/tag/tag.twig @@ -22,7 +22,7 @@ {% set icon_class = icon is not empty ? 'ct-tag--with-icon' : '' %} {% set icon_placement = icon_placement in ['before', 'after'] ? icon_placement : 'after' %} {% set icon_placement_class = icon ? 'ct-tag--icon-%s'|format(icon_placement|default('before')) : '' %} -{% set is_external = is_external ? 'ct-tag--external': '' %} +{% set is_external = is_external ? 'ct-tag--external' : '' %} {% set theme_class = 'ct-theme-%s'|format(theme|default('light')) %} {% set modifier_class = '%s %s %s %s %s %s'|format(theme_class, type_class, icon_class, icon_placement_class, is_external, modifier_class|default('')) %} diff --git a/web/themes/contrib/civictheme/civictheme_library/components/02-molecules/attachment/attachment.twig b/web/themes/contrib/civictheme/civictheme_library/components/02-molecules/attachment/attachment.twig index b6e8622d9..ec5515fc9 100644 --- a/web/themes/contrib/civictheme/civictheme_library/components/02-molecules/attachment/attachment.twig +++ b/web/themes/contrib/civictheme/civictheme_library/components/02-molecules/attachment/attachment.twig @@ -70,7 +70,7 @@ {% block links %} {% set link_items = [] %} - {% for k, file in files %} + {% for file in files %} {%- set link %} {% include '@base/icon/icon.twig' with { symbol: file.icon ? file.icon : 'download-file', diff --git a/web/themes/contrib/civictheme/civictheme_library/components/02-molecules/breadcrumb/breadcrumb.twig b/web/themes/contrib/civictheme/civictheme_library/components/02-molecules/breadcrumb/breadcrumb.twig index 5ffb1fb31..c9eb5420d 100644 --- a/web/themes/contrib/civictheme/civictheme_library/components/02-molecules/breadcrumb/breadcrumb.twig +++ b/web/themes/contrib/civictheme/civictheme_library/components/02-molecules/breadcrumb/breadcrumb.twig @@ -24,7 +24,7 @@