From 8fcd31455b2fff18fcab29e3e208324eb114e1b1 Mon Sep 17 00:00:00 2001 From: Joshua Pease Date: Mon, 30 Sep 2024 16:47:26 -0700 Subject: [PATCH] [#45] Adds Card Grid Block - Uses both image & icon cards --- ...-7ced3e9d-9b54-47f6-8103-e5c3a4fbaf9c.yaml | 67 +++++++++++++ ...-3f1dc0c5-f091-469a-858a-4cbd3596bab7.yaml | 99 +++++++++++++++++++ ...-7d418368-91eb-4c64-8f5b-94c62cd62359.yaml | 99 +++++++++++++++++++ ...-5e84b0b7-6851-47ed-962e-76498ac9476f.yaml | 21 ++++ ...-a99edea2-f8ae-44e5-a12f-89cb9aa66738.yaml | 16 +++ ...-0011a64a-91b6-4aa3-98e6-be048394a2cf.yaml | 65 ++++++++++++ ...-570fb481-ad97-46db-8bad-f7b0fd90e831.yaml | 35 +++++++ ...-7bd21dd3-6b12-4163-8432-030ea6a3f8d3.yaml | 1 + ...-69fe4c18-21c9-4a3d-8fce-9988d3f741e4.yaml | 51 ++++++++++ config/project/project.yaml | 10 +- templates/_blocks/_cardGrid.twig | 23 +++++ templates/_blocks/_richText.twig | 3 +- 12 files changed, 488 insertions(+), 2 deletions(-) create mode 100644 config/project/entryTypes/cardGrid--7ced3e9d-9b54-47f6-8103-e5c3a4fbaf9c.yaml create mode 100644 config/project/entryTypes/iconCard--3f1dc0c5-f091-469a-858a-4cbd3596bab7.yaml create mode 100644 config/project/entryTypes/imageCard--7d418368-91eb-4c64-8f5b-94c62cd62359.yaml create mode 100644 config/project/fields/cardGrid--5e84b0b7-6851-47ed-962e-76498ac9476f.yaml create mode 100644 config/project/fields/description--a99edea2-f8ae-44e5-a12f-89cb9aa66738.yaml create mode 100644 config/project/fields/icon--0011a64a-91b6-4aa3-98e6-be048394a2cf.yaml create mode 100644 config/project/fields/image--570fb481-ad97-46db-8bad-f7b0fd90e831.yaml create mode 100644 config/project/fields/primaryLink--69fe4c18-21c9-4a3d-8fce-9988d3f741e4.yaml create mode 100644 templates/_blocks/_cardGrid.twig diff --git a/config/project/entryTypes/cardGrid--7ced3e9d-9b54-47f6-8103-e5c3a4fbaf9c.yaml b/config/project/entryTypes/cardGrid--7ced3e9d-9b54-47f6-8103-e5c3a4fbaf9c.yaml new file mode 100644 index 0000000..b288522 --- /dev/null +++ b/config/project/entryTypes/cardGrid--7ced3e9d-9b54-47f6-8103-e5c3a4fbaf9c.yaml @@ -0,0 +1,67 @@ +color: null +fieldLayouts: + 20f64bfb-c1fa-4afa-9631-7660c7cdeb37: + tabs: + - + elementCondition: null + elements: + - + autocapitalize: true + autocomplete: false + autocorrect: true + class: null + dateAdded: '2024-09-30T23:24:00+00:00' + disabled: false + elementCondition: null + id: null + includeInCards: false + inputType: null + instructions: null + label: null + max: null + min: null + name: null + orientation: null + placeholder: null + providesThumbs: false + readonly: false + requirable: false + size: null + step: null + tip: null + title: null + type: craft\fieldlayoutelements\entries\EntryTitleField + uid: 7a16feb6-d7c0-4a94-8bd4-07a2e30e67a7 + userCondition: null + warning: null + width: 100 + - + dateAdded: '2024-09-30T23:33:26+00:00' + elementCondition: null + fieldUid: 5e84b0b7-6851-47ed-962e-76498ac9476f # Card Grid + handle: null + includeInCards: false + instructions: null + label: null + providesThumbs: false + required: false + tip: null + type: craft\fieldlayoutelements\CustomField + uid: 34ece3df-7fa2-439f-985c-2cd74abfd1e3 + userCondition: null + warning: null + width: 100 + name: Content + uid: be2ae502-0ddb-4540-a73b-eecc45b4753a + userCondition: null +handle: cardGrid +hasTitleField: false +icon: grid +name: 'Card Grid' +showSlugField: false +showStatusField: true +slugTranslationKeyFormat: null +slugTranslationMethod: site +titleFormat: '' +titleTranslationKeyFormat: null +titleTranslationMethod: site diff --git a/config/project/entryTypes/iconCard--3f1dc0c5-f091-469a-858a-4cbd3596bab7.yaml b/config/project/entryTypes/iconCard--3f1dc0c5-f091-469a-858a-4cbd3596bab7.yaml new file mode 100644 index 0000000..8211ad3 --- /dev/null +++ b/config/project/entryTypes/iconCard--3f1dc0c5-f091-469a-858a-4cbd3596bab7.yaml @@ -0,0 +1,99 @@ +color: null +fieldLayouts: + 57d6dbf5-4050-46e9-b1d8-2990c925c04c: + tabs: + - + elementCondition: null + elements: + - + dateAdded: '2024-09-30T23:33:06+00:00' + elementCondition: null + fieldUid: 0011a64a-91b6-4aa3-98e6-be048394a2cf # Icon + handle: null + includeInCards: false + instructions: null + label: null + providesThumbs: false + required: false + tip: null + type: craft\fieldlayoutelements\CustomField + uid: 93e23b5a-05ee-4ba1-9ae8-b4a7471b69e1 + userCondition: null + warning: null + width: 100 + - + dateAdded: '2024-09-30T23:33:06+00:00' + elementCondition: null + fieldUid: 69fe4c18-21c9-4a3d-8fce-9988d3f741e4 # Link + handle: null + includeInCards: false + instructions: null + label: null + providesThumbs: false + required: false + tip: null + type: craft\fieldlayoutelements\CustomField + uid: 7a0ed038-606f-41eb-a3a3-c5783a9e4df4 + userCondition: null + warning: null + width: 100 + - + autocapitalize: true + autocomplete: false + autocorrect: true + class: null + dateAdded: '2024-09-30T23:29:31+00:00' + disabled: false + elementCondition: null + id: null + includeInCards: false + inputType: null + instructions: null + label: null + max: null + min: null + name: null + orientation: null + placeholder: null + providesThumbs: false + readonly: false + requirable: false + size: null + step: null + tip: null + title: null + type: craft\fieldlayoutelements\entries\EntryTitleField + uid: 2a49c922-8c52-4df2-8069-e87e89e2f03e + userCondition: null + warning: null + width: 100 + - + dateAdded: '2024-09-30T23:33:06+00:00' + elementCondition: null + fieldUid: a99edea2-f8ae-44e5-a12f-89cb9aa66738 # Description + handle: null + includeInCards: false + instructions: null + label: null + providesThumbs: false + required: false + tip: null + type: craft\fieldlayoutelements\CustomField + uid: e44a04d0-1ede-4985-9d10-8e2c13dfc7d9 + userCondition: null + warning: null + width: 100 + name: Content + uid: 3eca7200-b91a-4369-98b2-54b2d5970c79 + userCondition: null +handle: iconCard +hasTitleField: true +icon: icons +name: 'Icon Card' +showSlugField: true +showStatusField: true +slugTranslationKeyFormat: null +slugTranslationMethod: site +titleFormat: '' +titleTranslationKeyFormat: null +titleTranslationMethod: site diff --git a/config/project/entryTypes/imageCard--7d418368-91eb-4c64-8f5b-94c62cd62359.yaml b/config/project/entryTypes/imageCard--7d418368-91eb-4c64-8f5b-94c62cd62359.yaml new file mode 100644 index 0000000..0e64635 --- /dev/null +++ b/config/project/entryTypes/imageCard--7d418368-91eb-4c64-8f5b-94c62cd62359.yaml @@ -0,0 +1,99 @@ +color: null +fieldLayouts: + 35c4a5cf-04f0-400e-a3bd-107187ab73ee: + tabs: + - + elementCondition: null + elements: + - + dateAdded: '2024-09-30T23:29:23+00:00' + elementCondition: null + fieldUid: 570fb481-ad97-46db-8bad-f7b0fd90e831 # Image + handle: null + includeInCards: true + instructions: null + label: null + providesThumbs: false + required: false + tip: null + type: craft\fieldlayoutelements\CustomField + uid: 137a7e8f-bd2a-46c9-972b-365f2ea8a1b7 + userCondition: null + warning: null + width: 100 + - + dateAdded: '2024-09-30T23:29:23+00:00' + elementCondition: null + fieldUid: 69fe4c18-21c9-4a3d-8fce-9988d3f741e4 # Link + handle: null + includeInCards: false + instructions: null + label: null + providesThumbs: false + required: false + tip: null + type: craft\fieldlayoutelements\CustomField + uid: c76db590-6bba-4a59-9353-adbf9eeb9cf6 + userCondition: null + warning: null + width: 100 + - + autocapitalize: true + autocomplete: false + autocorrect: true + class: null + dateAdded: '2024-09-30T23:24:56+00:00' + disabled: false + elementCondition: null + id: null + includeInCards: false + inputType: null + instructions: null + label: null + max: null + min: null + name: null + orientation: null + placeholder: null + providesThumbs: false + readonly: false + requirable: false + size: null + step: null + tip: null + title: null + type: craft\fieldlayoutelements\entries\EntryTitleField + uid: 860a8146-8741-437e-95e0-b4e2bf886d5f + userCondition: null + warning: null + width: 100 + - + dateAdded: '2024-09-30T23:29:23+00:00' + elementCondition: null + fieldUid: a99edea2-f8ae-44e5-a12f-89cb9aa66738 # Description + handle: null + includeInCards: false + instructions: null + label: null + providesThumbs: false + required: false + tip: null + type: craft\fieldlayoutelements\CustomField + uid: 14a7db31-c0d3-47d5-a03a-24b0bba82130 + userCondition: null + warning: null + width: 100 + name: Content + uid: 2d299e0f-b490-4172-874c-983cf1b2cd4f + userCondition: null +handle: imageCard +hasTitleField: true +icon: image-polaroid +name: 'Image Card' +showSlugField: true +showStatusField: true +slugTranslationKeyFormat: null +slugTranslationMethod: site +titleFormat: '' +titleTranslationKeyFormat: null +titleTranslationMethod: site diff --git a/config/project/fields/cardGrid--5e84b0b7-6851-47ed-962e-76498ac9476f.yaml b/config/project/fields/cardGrid--5e84b0b7-6851-47ed-962e-76498ac9476f.yaml new file mode 100644 index 0000000..b2e4bb1 --- /dev/null +++ b/config/project/fields/cardGrid--5e84b0b7-6851-47ed-962e-76498ac9476f.yaml @@ -0,0 +1,21 @@ +columnSuffix: null +handle: cardGrid +instructions: null +name: 'Card Grid' +searchable: false +settings: + createButtonLabel: 'New card' + entryTypes: + - 7d418368-91eb-4c64-8f5b-94c62cd62359 # Image Card + - 3f1dc0c5-f091-469a-858a-4cbd3596bab7 # Icon Card + includeTableView: false + maxEntries: null + minEntries: null + pageSize: 50 + propagationKeyFormat: null + propagationMethod: all + showCardsInGrid: true + viewMode: cards +translationKeyFormat: null +translationMethod: site +type: craft\fields\Matrix diff --git a/config/project/fields/description--a99edea2-f8ae-44e5-a12f-89cb9aa66738.yaml b/config/project/fields/description--a99edea2-f8ae-44e5-a12f-89cb9aa66738.yaml new file mode 100644 index 0000000..65a501b --- /dev/null +++ b/config/project/fields/description--a99edea2-f8ae-44e5-a12f-89cb9aa66738.yaml @@ -0,0 +1,16 @@ +columnSuffix: null +handle: description +instructions: null +name: Description +searchable: false +settings: + byteLimit: null + charLimit: null + code: false + initialRows: 2 + multiline: true + placeholder: null + uiMode: normal +translationKeyFormat: null +translationMethod: none +type: craft\fields\PlainText diff --git a/config/project/fields/icon--0011a64a-91b6-4aa3-98e6-be048394a2cf.yaml b/config/project/fields/icon--0011a64a-91b6-4aa3-98e6-be048394a2cf.yaml new file mode 100644 index 0000000..b01e3cf --- /dev/null +++ b/config/project/fields/icon--0011a64a-91b6-4aa3-98e6-be048394a2cf.yaml @@ -0,0 +1,65 @@ +columnSuffix: null +handle: icon +instructions: null +name: Icon +searchable: false +settings: + options: + - + __assoc__: + - + - label + - None + - + - value + - '' + - + - default + - '1' + - + __assoc__: + - + - label + - 'Arrow Left' + - + - value + - arrow-left + - + - default + - '' + - + __assoc__: + - + - label + - 'Arrow Right' + - + - value + - arrowRight + - + - default + - '' + - + __assoc__: + - + - label + - Clock + - + - value + - clock + - + - default + - '' + - + __assoc__: + - + - label + - Close + - + - value + - close + - + - default + - '' +translationKeyFormat: null +translationMethod: none +type: craft\fields\Dropdown diff --git a/config/project/fields/image--570fb481-ad97-46db-8bad-f7b0fd90e831.yaml b/config/project/fields/image--570fb481-ad97-46db-8bad-f7b0fd90e831.yaml new file mode 100644 index 0000000..cd51f57 --- /dev/null +++ b/config/project/fields/image--570fb481-ad97-46db-8bad-f7b0fd90e831.yaml @@ -0,0 +1,35 @@ +columnSuffix: null +handle: image +instructions: null +name: Image +searchable: false +settings: + allowSelfRelations: false + allowSubfolders: false + allowUploads: true + allowedKinds: + - image + branchLimit: null + defaultUploadLocationSource: 'volume:853413e4-e02c-487e-81a5-04e58eb18683' # Assets + defaultUploadLocationSubpath: null + maintainHierarchy: false + maxRelations: 1 + minRelations: null + previewMode: full + restrictFiles: true + restrictLocation: false + restrictedDefaultUploadSubpath: null + restrictedLocationSource: 'volume:853413e4-e02c-487e-81a5-04e58eb18683' # Assets + restrictedLocationSubpath: null + selectionLabel: 'Add image' + showCardsInGrid: false + showSiteMenu: false + showUnpermittedFiles: false + showUnpermittedVolumes: false + sources: '*' + targetSiteId: null + validateRelatedElements: false + viewMode: list +translationKeyFormat: null +translationMethod: none +type: craft\fields\Assets diff --git a/config/project/fields/pageBlocks--7bd21dd3-6b12-4163-8432-030ea6a3f8d3.yaml b/config/project/fields/pageBlocks--7bd21dd3-6b12-4163-8432-030ea6a3f8d3.yaml index 4e1ed47..e8671b4 100644 --- a/config/project/fields/pageBlocks--7bd21dd3-6b12-4163-8432-030ea6a3f8d3.yaml +++ b/config/project/fields/pageBlocks--7bd21dd3-6b12-4163-8432-030ea6a3f8d3.yaml @@ -7,6 +7,7 @@ settings: createButtonLabel: 'New Block' entryTypes: - 896b8f2a-ed0c-42c9-b5fd-ba8668fc6784 # Rich Text + - 7ced3e9d-9b54-47f6-8103-e5c3a4fbaf9c # Card Grid includeTableView: false maxEntries: null minEntries: null diff --git a/config/project/fields/primaryLink--69fe4c18-21c9-4a3d-8fce-9988d3f741e4.yaml b/config/project/fields/primaryLink--69fe4c18-21c9-4a3d-8fce-9988d3f741e4.yaml new file mode 100644 index 0000000..a35cad6 --- /dev/null +++ b/config/project/fields/primaryLink--69fe4c18-21c9-4a3d-8fce-9988d3f741e4.yaml @@ -0,0 +1,51 @@ +columnSuffix: null +handle: primaryLink +instructions: null +name: Link +searchable: false +settings: + maxLength: 255 + typeSettings: + __assoc__: + - + - url + - + __assoc__: + - + - allowRootRelativeUrls + - '1' + - + - allowAnchors + - '1' + - + - asset + - + __assoc__: + - + - sources + - '*' + - + - allowedKinds + - '*' + - + - showUnpermittedVolumes + - '' + - + - showUnpermittedFiles + - '' + - + - entry + - + __assoc__: + - + - sources + - '*' + types: + - url + - asset + - email + - entry + - tel +translationKeyFormat: null +translationMethod: none +type: craft\fields\Link diff --git a/config/project/project.yaml b/config/project/project.yaml index 636cab1..515b90f 100644 --- a/config/project/project.yaml +++ b/config/project/project.yaml @@ -1,4 +1,4 @@ -dateModified: 1727737653 +dateModified: 1727739323 email: fromEmail: $SYSTEM_EMAIL_FROM fromName: 'Viget Craft Starter' @@ -22,12 +22,20 @@ fs: meta: __names__: 0e7762a5-2553-4c0d-b8af-9b43b59524bf: Home # Home + 3f1dc0c5-f091-469a-858a-4cbd3596bab7: 'Icon Card' # Icon Card + 5e84b0b7-6851-47ed-962e-76498ac9476f: 'Card Grid' # Card Grid 7bd21dd3-6b12-4163-8432-030ea6a3f8d3: 'Page Blocks' # Page Blocks + 7ced3e9d-9b54-47f6-8103-e5c3a4fbaf9c: 'Card Grid' # Card Grid + 7d418368-91eb-4c64-8f5b-94c62cd62359: 'Image Card' # Image Card + 0011a64a-91b6-4aa3-98e6-be048394a2cf: Icon # Icon 35b563a0-4662-40b9-b885-a8450a2868d9: 'Viget Craft Starter' # Viget Craft Starter + 69fe4c18-21c9-4a3d-8fce-9988d3f741e4: Link # Link + 570fb481-ad97-46db-8bad-f7b0fd90e831: Image # Image 805d8826-faed-4186-9b88-f509eb9b07e6: 'Viget Craft Starter' # Viget Craft Starter 896b8f2a-ed0c-42c9-b5fd-ba8668fc6784: 'Rich Text' # Rich Text 969acdd6-6362-41b1-b782-6bbd43a8a6b4: Home # Home 853413e4-e02c-487e-81a5-04e58eb18683: Assets # Assets + a99edea2-f8ae-44e5-a12f-89cb9aa66738: Description # Description b7e66782-af96-4012-9e17-914134073ced: Simple # Simple cd489d3c-f914-475c-a270-ab926e4e7485: 'Rich Text' # Rich Text plugins: diff --git a/templates/_blocks/_cardGrid.twig b/templates/_blocks/_cardGrid.twig new file mode 100644 index 0000000..235ac8e --- /dev/null +++ b/templates/_blocks/_cardGrid.twig @@ -0,0 +1,23 @@ +{# @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.primaryLink, + title: card.title, + description: card.description, + }) }} + {% case 'iconCard' %} + {{ include('_components/card-icon.twig', { + href: card.primaryLink, + icon: card.icon.value, + title: card.title, + description: card.description, + }) }} + {% endswitch %} + {% endfor %} +
diff --git a/templates/_blocks/_richText.twig b/templates/_blocks/_richText.twig index dd607dd..5a25163 100644 --- a/templates/_blocks/_richText.twig +++ b/templates/_blocks/_richText.twig @@ -1,5 +1,6 @@ +{# @var \craft\elements\Entry block #} {% set block = block ?? null %} -
+
{{ block.richText }}