From f53fa0c6cca5a69ea876f652793590e1c3115d96 Mon Sep 17 00:00:00 2001 From: Britney Wang Date: Fri, 30 Jan 2026 10:56:19 +0800 Subject: [PATCH 1/2] feat: add padding variants for Resources pattern --- package.json | 2 +- releases.yml | 6 ++++++ templates/_macros/vf_resources.jinja | 13 +++++++++++-- templates/docs/patterns/resources/index.md | 20 ++++++++++++++++++++ 4 files changed, 38 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 9e1e5d567..e2bbb457d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "vanilla-framework", - "version": "4.41.0", + "version": "4.42.0", "author": { "email": "webteam@canonical.com", "name": "Canonical Webteam" diff --git a/releases.yml b/releases.yml index 49206642e..84c8bce28 100644 --- a/releases.yml +++ b/releases.yml @@ -1,3 +1,9 @@ +- version: 4.42.0 + features: + - component: Resources + url: /docs/patterns/resources + status: Updated + notes: Added a new padding parameter to customize the section padding. - version: 4.41.0 features: - component: Table diff --git a/templates/_macros/vf_resources.jinja b/templates/_macros/vf_resources.jinja index 33a0ed73e..b73f74c11 100644 --- a/templates/_macros/vf_resources.jinja +++ b/templates/_macros/vf_resources.jinja @@ -319,14 +319,23 @@ } ] #} -{% macro vf_resources(title={}, blocks=[], caller=None) %} +{% macro vf_resources(title={}, blocks=[], caller=None, padding="default") %} {%- set description = blocks | selectattr("type", "equalto", "description") | first -%} {%- set cta = blocks | selectattr("type", "equalto", "cta-block") | first -%} {%- set resources = blocks | selectattr("type", "equalto", "resources") | first -%} {%- set render_images = resources.get("render_images", true) -%} {%- set render_categories = resources.get("render_categories", true) -%} {%- set is_text_only = not (render_images or render_categories) -%} -
+ {%- set padding = padding | trim -%} + {%- if padding not in ["deep", "shallow", "default"] -%} + {%- set padding = "default" -%} + {%- endif -%} + {%- if padding == "default" -%} + {%- set padding_classes = "p-section" -%} + {%- else -%} + {%- set padding_classes = "p-section--" + padding -%} + {%- endif -%} +
{{- vf_section_top_rule("default") -}}
{{- _title_block(title) -}}
diff --git a/templates/docs/patterns/resources/index.md b/templates/docs/patterns/resources/index.md index 0262ad50a..5af48721a 100644 --- a/templates/docs/patterns/resources/index.md +++ b/templates/docs/patterns/resources/index.md @@ -566,6 +566,26 @@ The Resources block allows you to specify categories and resource items to appea Time element attributes object, see attribute forwarding + + + padding + + + No + + + One of:
+ 'deep',
+ 'shallow',
+ 'default' + + + 'default' + + + Padding variant for the section + +
From 63a100b22cc7927801d1e9fac8b14e8bc964b879 Mon Sep 17 00:00:00 2001 From: Britney Wang Date: Fri, 30 Jan 2026 14:45:58 +0800 Subject: [PATCH 2/2] Address code comment --- templates/_macros/vf_resources.jinja | 1 + 1 file changed, 1 insertion(+) diff --git a/templates/_macros/vf_resources.jinja b/templates/_macros/vf_resources.jinja index b73f74c11..f96ce7168 100644 --- a/templates/_macros/vf_resources.jinja +++ b/templates/_macros/vf_resources.jinja @@ -318,6 +318,7 @@ ] } ] + @param padding (string) - Optional bottom padding for the section #} {% macro vf_resources(title={}, blocks=[], caller=None, padding="default") %} {%- set description = blocks | selectattr("type", "equalto", "description") | first -%}