From 860ac0d9b6852e5d8c0c34839a6b6519517ff666 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Bedna=C5=99=C3=ADk?= <jan.bednarik@gmail.com> Date: Thu, 26 Nov 2020 14:10:38 +0100 Subject: [PATCH] uniweb: List with image --- uniweb/models.py | 19 +++++++++++++++++++ uniweb/templates/uniweb/base.html | 9 +++++++++ .../templates/uniweb/blocks/picture_list.html | 9 +++++++++ 3 files changed, 37 insertions(+) create mode 100644 uniweb/templates/uniweb/blocks/picture_list.html diff --git a/uniweb/models.py b/uniweb/models.py index 9d86e9c8..267201a2 100644 --- a/uniweb/models.py +++ b/uniweb/models.py @@ -121,6 +121,24 @@ class AdvancedTextBlock(ColorBlock, AlignBlock): template = "uniweb/blocks/advanced_text.html" +class PictureListBlock(ColorBlock): + items = blocks.ListBlock( + blocks.RichTextBlock(label="odstavec", features=RICH_TEXT_FEATURES), + label="odstavce", + ) + picture = ImageChooserBlock( + label="obrázek", + # TODO rozmÄ›ry v helpu + help_text="rozmÄ›r 25x25px nebo vĂce (obrázek bude zmenšen na 25x25px)", + ) + + class Meta: + label = "seznam z obrázkovĂ˝mi odrážkami" + icon = "list-ul" + group = "texty" + template = "uniweb/blocks/picture_list.html" + + class MenuItemBlock(blocks.StructBlock): name = blocks.CharBlock(label="název") page = blocks.PageChooserBlock( @@ -181,6 +199,7 @@ class UniwebContentMixin(models.Model): template="uniweb/blocks/gallery.html", ), ), + ("picture_list", PictureListBlock()), ( "table", TableBlock( diff --git a/uniweb/templates/uniweb/base.html b/uniweb/templates/uniweb/base.html index cdb254e7..e718e0e9 100644 --- a/uniweb/templates/uniweb/base.html +++ b/uniweb/templates/uniweb/base.html @@ -25,6 +25,15 @@ .head-alt-md, .head-alt-lg { line-height: 1.25; } + .ul-picture li:before { + content: none !important; + } + .ul-picture li { + background-repeat: no-repeat; + background-position: 0 0; + padding: 0 0 1em 35px !important; + } + </style> {% if page.root_page.matomo_id %} diff --git a/uniweb/templates/uniweb/blocks/picture_list.html b/uniweb/templates/uniweb/blocks/picture_list.html new file mode 100644 index 00000000..92b4102e --- /dev/null +++ b/uniweb/templates/uniweb/blocks/picture_list.html @@ -0,0 +1,9 @@ +{% load wagtailcore_tags wagtailimages_tags %} +{% image block.value.picture max-25x25 as img %} +<div class="content-block px-4 py-2 clearfix{% if first %} mt-8 lg:mt-12{% endif %} {{ css_class|join:" " }}"> + <ul class="ul-picture"> + {% for text in block.value.items %} + <li style="background-image: url('{{ img.url }}');">{{ text|richtext }}</li> + {% endfor %} + </ul> +</div> -- GitLab