From 189c9dbeab7a37a50d0c51e074607461abb89c4e Mon Sep 17 00:00:00 2001 From: codescientist703 Date: Mon, 3 May 2021 16:45:28 +0530 Subject: [PATCH 1/4] feat: Added image field to the section_with_cards template --- .../section_with_cards.html | 11 +++- .../section_with_cards.json | 56 ++++++++++++++++++- 2 files changed, 64 insertions(+), 3 deletions(-) diff --git a/frappe/website/web_template/section_with_cards/section_with_cards.html b/frappe/website/web_template/section_with_cards/section_with_cards.html index 647923c9b1..9d804ba6ec 100644 --- a/frappe/website/web_template/section_with_cards/section_with_cards.html +++ b/frappe/website/web_template/section_with_cards/section_with_cards.html @@ -1,4 +1,4 @@ -{%- macro card(title, content, url) -%} +{%- macro card(title, content, url, image) -%} {%- set col_classes = resolve_class({ 'col-12 col-sm-6 col-lg-3': card_size == 'Small', 'col-12 col-sm-6 col-lg-4': card_size == 'Medium', @@ -11,6 +11,12 @@ }) -%}
+ {%- if image -%} + {{ frappe.render_template('templates/includes/image_with_blur.html', { + "src": image, + "class": ["card-img-top p-2"] + }) }} + {%- endif -%}

{{ title or '' }}

{{ content or '' }}

@@ -34,8 +40,9 @@ {%- set title = values['card_' + index + '_title'] -%} {%- set content = values['card_' + index + '_content'] -%} {%- set url = values['card_' + index + '_url'] -%} + {%- set image = values['card_' + index + '_image'] -%} {%- if title -%} - {{ card(title, content, url) }} + {{ card(title, content, url, image) }} {%- endif -%} {%- endfor -%}
diff --git a/frappe/website/web_template/section_with_cards/section_with_cards.json b/frappe/website/web_template/section_with_cards/section_with_cards.json index 7c2c256396..c891119f97 100644 --- a/frappe/website/web_template/section_with_cards/section_with_cards.json +++ b/frappe/website/web_template/section_with_cards/section_with_cards.json @@ -41,6 +41,12 @@ "label": "Content", "reqd": 0 }, + { + "fieldname": "card_1_image", + "fieldtype": "Attach Image", + "label": "Image", + "reqd": 0 + }, { "fieldname": "card_1_url", "fieldtype": "Data", @@ -65,6 +71,12 @@ "label": "Content", "reqd": 0 }, + { + "fieldname": "card_2_image", + "fieldtype": "Attach Image", + "label": "Image", + "reqd": 0 + }, { "fieldname": "card_2_url", "fieldtype": "Data", @@ -89,6 +101,12 @@ "label": "Content", "reqd": 0 }, + { + "fieldname": "card_3_image", + "fieldtype": "Attach Image", + "label": "Image", + "reqd": 0 + }, { "fieldname": "card_3_url", "fieldtype": "Data", @@ -113,6 +131,12 @@ "label": "Content", "reqd": 0 }, + { + "fieldname": "card_4_image", + "fieldtype": "Attach Image", + "label": "Image", + "reqd": 0 + }, { "fieldname": "card_4_url", "fieldtype": "Data", @@ -137,6 +161,12 @@ "label": "Content", "reqd": 0 }, + { + "fieldname": "card_5_image", + "fieldtype": "Attach Image", + "label": "Image", + "reqd": 0 + }, { "fieldname": "card_5_url", "fieldtype": "Data", @@ -161,6 +191,12 @@ "label": "Content", "reqd": 0 }, + { + "fieldname": "card_6_image", + "fieldtype": "Attach Image", + "label": "Image", + "reqd": 0 + }, { "fieldname": "card_6_url", "fieldtype": "Data", @@ -185,6 +221,12 @@ "label": "Content", "reqd": 0 }, + { + "fieldname": "card_7_image", + "fieldtype": "Attach Image", + "label": "Image", + "reqd": 0 + }, { "fieldname": "card_7_url", "fieldtype": "Data", @@ -209,6 +251,12 @@ "label": "Content", "reqd": 0 }, + { + "fieldname": "card_8_image", + "fieldtype": "Attach Image", + "label": "Image", + "reqd": 0 + }, { "fieldname": "card_8_url", "fieldtype": "Data", @@ -233,6 +281,12 @@ "label": "Content", "reqd": 0 }, + { + "fieldname": "card_9_image", + "fieldtype": "Attach Image", + "label": "Image", + "reqd": 0 + }, { "fieldname": "card_9_url", "fieldtype": "Data", @@ -241,7 +295,7 @@ } ], "idx": 0, - "modified": "2020-10-26 17:42:53.356024", + "modified": "2021-05-03 13:26:34.470232", "modified_by": "Administrator", "module": "Website", "name": "Section with Cards", From 008a72e92a23540b21f4a94b7e6e32520f0e033f Mon Sep 17 00:00:00 2001 From: codescientist703 Date: Thu, 6 May 2021 13:33:48 +0530 Subject: [PATCH 2/4] fix: added padding in scss file and fixed indentation --- frappe/public/scss/website/page_builder.scss | 4 ++++ .../web_template/section_with_cards/section_with_cards.html | 5 ++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/frappe/public/scss/website/page_builder.scss b/frappe/public/scss/website/page_builder.scss index 6eb6dae5d2..f629a01b1b 100644 --- a/frappe/public/scss/website/page_builder.scss +++ b/frappe/public/scss/website/page_builder.scss @@ -154,6 +154,10 @@ line-height: 1; } + img { + padding: 1rem; + } + &.card-sm { .card-body { padding: 1.5rem; diff --git a/frappe/website/web_template/section_with_cards/section_with_cards.html b/frappe/website/web_template/section_with_cards/section_with_cards.html index 9d804ba6ec..1b094fbd8e 100644 --- a/frappe/website/web_template/section_with_cards/section_with_cards.html +++ b/frappe/website/web_template/section_with_cards/section_with_cards.html @@ -11,10 +11,9 @@ }) -%}
- {%- if image -%} - {{ frappe.render_template('templates/includes/image_with_blur.html', { + {%- if image -%} + {{ frappe.render_template('templates/includes/image_with_blur.html', { "src": image, - "class": ["card-img-top p-2"] }) }} {%- endif -%}
From 32127606a926b39e493e3a37235bcb8f0d98c7a0 Mon Sep 17 00:00:00 2001 From: codescientist703 Date: Sat, 29 May 2021 15:12:30 +0530 Subject: [PATCH 3/4] fix: added card img top class --- .../web_template/section_with_cards/section_with_cards.html | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/frappe/website/web_template/section_with_cards/section_with_cards.html b/frappe/website/web_template/section_with_cards/section_with_cards.html index 1b094fbd8e..d0eb164288 100644 --- a/frappe/website/web_template/section_with_cards/section_with_cards.html +++ b/frappe/website/web_template/section_with_cards/section_with_cards.html @@ -11,9 +11,10 @@ }) -%}
- {%- if image -%} - {{ frappe.render_template('templates/includes/image_with_blur.html', { + {%- if image -%} + {{ frappe.render_template('templates/includes/image_with_blur.html', { "src": image, + "class": ["card-img-top"] }) }} {%- endif -%}
From 78cdfe4dd3d3b3d643a6506f192be51ff5cb05a3 Mon Sep 17 00:00:00 2001 From: Faris Ansari Date: Fri, 18 Jun 2021 13:28:16 +0530 Subject: [PATCH 4/4] fix: Remove card image padding --- frappe/public/scss/website/page_builder.scss | 4 ---- 1 file changed, 4 deletions(-) diff --git a/frappe/public/scss/website/page_builder.scss b/frappe/public/scss/website/page_builder.scss index f629a01b1b..6eb6dae5d2 100644 --- a/frappe/public/scss/website/page_builder.scss +++ b/frappe/public/scss/website/page_builder.scss @@ -154,10 +154,6 @@ line-height: 1; } - img { - padding: 1rem; - } - &.card-sm { .card-body { padding: 1.5rem;