Skip to content

Commit

Permalink
Ajout du composant Tuile (#142)
Browse files Browse the repository at this point in the history
* New component: Tile

* Improve SVG rendering

* Small tile and download tile, migrations, translations

* Improve download links

* Add tile to columns

* Update migrations
  • Loading branch information
Ash-Crow authored Jun 4, 2024
1 parent 87e6d6b commit 0672ad9
Show file tree
Hide file tree
Showing 10 changed files with 22,710 additions and 136 deletions.
16,081 changes: 16,081 additions & 0 deletions blog/migrations/0014_alter_blogentrypage_body_alter_blogindexpage_body_and_more.py

Large diffs are not rendered by default.

57 changes: 50 additions & 7 deletions content_manager/blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ class Meta:
template = "content_manager/blocks/tags_list.html"


## Cards
## Cards and tiles
class CardstructValue(StructValue):
def enlarge_link(self):
"""
Expand All @@ -213,7 +213,7 @@ def enlarge_link(self):
url = self.get("url")
document = self.get("document")
top_detail_badges_tags = self.get("top_detail_badges_tags")
call_to_action = self.get("call_to_action")
call_to_action = self.get("call_to_action", "")

if not ((link and link.url()) or url or document):
return False
Expand Down Expand Up @@ -353,6 +353,47 @@ class Meta:
value_class = CardstructValue


class TileBlock(blocks.StructBlock):
title = blocks.CharBlock(label=_("Title"))
heading_tag = blocks.ChoiceBlock(
label=_("Heading level"),
choices=HEADING_CHOICES,
default="h3",
help_text=_("Adapt to the page layout. Defaults to heading 3."),
)
description = blocks.TextBlock(label=_("Content"), help_text=_("Can contain HTML."), required=False)
image = ImageChooserBlock(label=_("Image"), help_text=_("Prefer SVG files."), required=False)
link = LinkWithoutLabelBlock(
label=_("Link"),
required=False,
)
top_detail_badges_tags = blocks.StreamBlock(
[
("badges", BadgesListBlock()),
("tags", TagListBlock()),
],
label=_("Top detail: badges or tags"),
max_num=1,
required=False,
)
detail_text = blocks.CharBlock(
label=_("Detail text"),
required=False,
help_text=_("If the tile links to a downloadable document, the values are pre-filled."),
)
is_small = blocks.BooleanBlock(label=_("Small tile"), required=False)
grey_background = blocks.BooleanBlock(label=_("Tile with grey background"), required=False)
no_background = blocks.BooleanBlock(label=_("Tile without background"), required=False)
no_border = blocks.BooleanBlock(label=_("Tile without border"), required=False)
shadow = blocks.BooleanBlock(label=_("Tile with a shadow"), required=False)
is_horizontal = blocks.BooleanBlock(label=_("Horizontal tile"), required=False)

class Meta:
icon = "tablet-alt"
template = "content_manager/blocks/tile.html"
value_class = CardstructValue


## Basic blocks
class AccordionBlock(blocks.StructBlock):
title = blocks.CharBlock(label=_("Title"))
Expand Down Expand Up @@ -593,17 +634,18 @@ class CommonStreamBlock(blocks.StreamBlock):
image = ImageBlock(label=_("Image"))
video = VideoBlock(label=_("Video"))
transcription = TranscriptionBlock(label=_("Transcription"))
quote = QuoteBlock(label=_("Quote"))
quote = QuoteBlock(label=_("Quote"), group=_("DSFR components"))
text_cta = TextAndCTA(label=_("Text and call to action"))
link = SingleLinkBlock(label=_("Single link"))
iframe = IframeBlock(label=_("Iframe"))
iframe = IframeBlock(label=_("Iframe"), group=_("DSFR components"))
tile = TileBlock(label=_("Tile"), group=_("DSFR components"))

class Meta:
icon = "dots-horizontal"


class ColumnBlock(CommonStreamBlock):
card = VerticalCardBlock(label=_("Vertical card"))
card = VerticalCardBlock(label=_("Vertical card"), group=_("DSFR components"))


class AdjustableColumnBlock(blocks.StructBlock):
Expand All @@ -628,7 +670,7 @@ class Meta:


class MultiColumnsBlock(CommonStreamBlock):
card = VerticalCardBlock(label=_("Vertical card"))
card = VerticalCardBlock(label=_("Vertical card"), group=_("DSFR components"))
column = AdjustableColumnBlock(label=_("Adjustable column"), group=_("Page structure"))

class Meta:
Expand Down Expand Up @@ -668,7 +710,7 @@ class Meta:

class FullWidthBlock(CommonStreamBlock):
image_and_text = ImageAndTextBlock(label=_("Image and text"))
card = HorizontalCardBlock(label=_("Horizontal card"))
card = HorizontalCardBlock(label=_("Horizontal card"), group=_("DSFR components"))

class Meta:
icon = "minus"
Expand Down Expand Up @@ -701,6 +743,7 @@ class Meta:
("tags_list", TagListBlock(label=_("Tag list"))),
("link", SingleLinkBlock(label=_("Single link"))),
("card", HorizontalCardBlock(label=_("Horizontal card"), group=_("DSFR components"))),
("tile", TileBlock(label=_("Tile"), group=_("DSFR components"))),
("accordions", AccordionsBlock(label=_("Accordions"), group=_("DSFR components"))),
("stepper", StepperBlock(label=_("Stepper"), group=_("DSFR components"))),
("markdown", MarkdownBlock(label=_("Markdown"), group=_("Expert syntax"))),
Expand Down
Binary file modified content_manager/locale/fr/LC_MESSAGES/django.mo
Binary file not shown.
Loading

0 comments on commit 0672ad9

Please sign in to comment.