From 1ef744924f7ec9b686ab251ec0406856a4a8ff1d Mon Sep 17 00:00:00 2001 From: Chris Sewell Date: Mon, 22 Aug 2022 22:04:07 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=91=8C=20IMPROVE:=20Add=20card=20options?= =?UTF-8?q?=20`class-img-top`/`class-img-bottom`=20(#92)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/cards.md | 6 ++++++ sphinx_design/cards.py | 6 ++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/docs/cards.md b/docs/cards.md index 5adf49a..6c30d54 100644 --- a/docs/cards.md +++ b/docs/cards.md @@ -283,3 +283,9 @@ class-title class-footer : Additional CSS classes for the footer element. + +class-img-top +: Additional CSS classes for the top image (if present). + +class-img-bottom +: Additional CSS classes for the bottom image (if present). diff --git a/sphinx_design/cards.py b/sphinx_design/cards.py index d097fed..96d0e33 100644 --- a/sphinx_design/cards.py +++ b/sphinx_design/cards.py @@ -68,6 +68,8 @@ class CardDirective(SphinxDirective): "class-body": directives.class_option, "class-title": directives.class_option, "class-footer": directives.class_option, + "class-img-top": directives.class_option, + "class-img-bottom": directives.class_option, } def run(self) -> List[nodes.Node]: @@ -113,7 +115,7 @@ def create_card( "", uri=options["img-top"], alt="card-img-top", - classes=["sd-card-img-top"], + classes=["sd-card-img-top"] + options.get("class-img-top", []), ) container.append(image_top) @@ -154,7 +156,7 @@ def create_card( "", uri=options["img-bottom"], alt="card-img-bottom", - classes=["sd-card-img-bottom"], + classes=["sd-card-img-bottom"] + options.get("class-img-bottom", []), ) container.append(image_bottom)