diff --git a/config/project/entryTypes/cardGrid--7ced3e9d-9b54-47f6-8103-e5c3a4fbaf9c.yaml b/config/project/entryTypes/cardGrid--7ced3e9d-9b54-47f6-8103-e5c3a4fbaf9c.yaml index b288522..6a08103 100644 --- a/config/project/entryTypes/cardGrid--7ced3e9d-9b54-47f6-8103-e5c3a4fbaf9c.yaml +++ b/config/project/entryTypes/cardGrid--7ced3e9d-9b54-47f6-8103-e5c3a4fbaf9c.yaml @@ -35,6 +35,22 @@ fieldLayouts: userCondition: null warning: null width: 100 + - + dateAdded: '2024-10-02T23:56:36+00:00' + elementCondition: null + fieldUid: 4382f55f-01a1-4b67-84c8-ebbc89b238d2 # Heading + handle: null + includeInCards: false + instructions: null + label: null + providesThumbs: false + required: false + tip: null + type: craft\fieldlayoutelements\CustomField + uid: dbdfb37c-efcb-4c7f-a367-c9bf274977ed + userCondition: null + warning: null + width: 100 - dateAdded: '2024-09-30T23:33:26+00:00' elementCondition: null diff --git a/config/project/project.yaml b/config/project/project.yaml index 7bc5f37..023cfd5 100644 --- a/config/project/project.yaml +++ b/config/project/project.yaml @@ -1,4 +1,4 @@ -dateModified: 1727908021 +dateModified: 1727913396 email: fromEmail: $SYSTEM_EMAIL_FROM fromName: 'Viget Craft Starter' diff --git a/templates/_blocks/_cardGrid.twig b/templates/_blocks/_cardGrid.twig index 9156312..a1ec144 100644 --- a/templates/_blocks/_cardGrid.twig +++ b/templates/_blocks/_cardGrid.twig @@ -1,25 +1,36 @@ {# @var \craft\elements\Entry block #} {% set block = block ?? null %} -
- {% for card in block.cardGrid.eagerly().all() %} - {% switch card.type.handle %} - {% case 'imageCard' %} - {{ include('_components/card-image.twig', { - image: card.image.eagerly().one(), - href: card.href, - newWindow: card.newWindow, - title: card.title, - description: card.description, - }) }} - {% case 'iconCard' %} - {{ include('_components/card-icon.twig', { - href: card.href, - newWindow: card.newWindow, - icon: card.icon.value, - title: card.title, - description: card.description, - }) }} - {% endswitch %} - {% endfor %} +{% set cardHeadingLevel = block.heading is not empty ? 3 : 2 %} + +
+ {% if block.heading %} +

+ {{ block.heading }} +

+ {% endif %} +
+ {% for card in block.cardGrid.eagerly().all() %} + {% switch card.type.handle %} + {% case 'imageCard' %} + {{ include('_components/card-image.twig', { + image: card.image.eagerly().one(), + href: card.href, + newWindow: card.newWindow, + title: card.title, + description: card.description, + headingLevel: cardHeadingLevel, + }) }} + {% case 'iconCard' %} + {{ include('_components/card-icon.twig', { + href: card.href, + newWindow: card.newWindow, + icon: card.icon.value, + title: card.title, + description: card.description, + headingLevel: cardHeadingLevel, + }) }} + {% endswitch %} + {% endfor %} +
diff --git a/templates/_components/card-icon.twig b/templates/_components/card-icon.twig index a6888c9..b916e2b 100644 --- a/templates/_components/card-icon.twig +++ b/templates/_components/card-icon.twig @@ -15,13 +15,18 @@ {# @var string|null icon #} {% set icon = icon ?? null %} +{# @var int headingLevel #} +{% set headingLevel = headingLevel ?? 3 %} + {# @var string|null title #} {% set title = title ?? null %} {# @var string|null description #} {% set description = description ?? null %} +{# Computed values #} {% set element = href ? 'a' : 'article' %} +{% set headingElement = "h#{headingLevel}" %} {% tag element with { class: cx(class, 'flex flex-col gap-24', { @@ -42,7 +47,11 @@ {% if title or description %}
{% if title %} -

{{ title }}

+ {% tag headingElement with { + class: 'text-xl font-bold', + } %} + {{ title }} + {% endtag %} {% endif %} {% if description %}

{{ description }}

diff --git a/templates/_components/card-image.twig b/templates/_components/card-image.twig index f3b95b3..dc0753a 100644 --- a/templates/_components/card-image.twig +++ b/templates/_components/card-image.twig @@ -21,13 +21,18 @@ {# @var string align #} {% set align = align ?? 'left' %} +{# @var int headingLevel #} +{% set headingLevel = headingLevel ?? 3 %} + {# @var string|null title #} {% set title = title ?? null %} {# @var string|null description #} {% set description = description ?? null %} +{# Computed values #} {% set element = href ? 'a' : 'article' %} +{% set headingElement = "h#{headingLevel}" %} {% tag element with { class: cx(class, 'flex flex-col gap-24', { @@ -48,7 +53,11 @@ {% if title or description %}
{% if title %} -

{{ title }}

+ {% tag headingElement with { + class: 'text-xl font-bold', + } %} + {{ title }} + {% endtag %} {% endif %} {% if description %}

{{ description }}