Skip to content
Snippets Groups Projects
Commit 0d7f859b authored by Alexa Valentová's avatar Alexa Valentová
Browse files

WIP - migrate & merge blocks

parent df251ca6
No related branches found
No related tags found
2 merge requests!1047Uniweb redesign,!1045Uniweb redesign, minor district redesign fixes
Pipeline #18726 passed
Source diff could not be displayed: it is too large. Options to address this: view the blob.
This diff is collapsed.
This diff is collapsed.
......@@ -18,11 +18,44 @@ from wagtail.images.models import Image
from wagtail.models import Collection
from maps_utils.blocks import MapFeatureCollectionBlock, MapPointBlock
from shared.const import RICH_TEXT_DEFAULT_FEATURES
from shared.const import (
RICH_TEXT_DEFAULT_FEATURES, COLOR_CHOICES, BLACK_ON_WHITE, COLOR_CSS,
ALIGN_CHOICES, LEFT, ALIGN_CSS
)
logger = logging.getLogger(__name__)
class ColorBlock(blocks.StructBlock):
"""
Intended as parent class for blocks with color option.
"""
color = blocks.ChoiceBlock(COLOR_CHOICES, label="barva", default=BLACK_ON_WHITE)
def get_context(self, value, parent_context=None):
context = super().get_context(value, parent_context=parent_context)
if "css_class" not in context:
context["css_class"] = []
context["css_class"] += COLOR_CSS[value["color"]]
return context
class AlignBlock(blocks.StructBlock):
"""
Intended as parent class for blocks with align option.
"""
align = blocks.ChoiceBlock(ALIGN_CHOICES, label="zarovnání", default=LEFT)
def get_context(self, value, parent_context=None):
context = super().get_context(value, parent_context=parent_context)
if "css_class" not in context:
context["css_class"] = []
context["css_class"] += ALIGN_CSS[value["align"]]
return context
class GalleryBlock(blocks.StructBlock):
gallery_items = blocks.ListBlock(
ImageChooserBlock(label="obrázek", required=True),
......@@ -1065,6 +1098,18 @@ class NewsletterSubscriptionBlock(blocks.StructBlock):
template = "styleguide2/includes/organisms/main_section/newsletter_section.html"
class AdvancedTextBlock(ColorBlock, AlignBlock):
text = blocks.RichTextBlock(
label="Textový editor",
features=RICH_TEXT_DEFAULT_FEATURES,
)
class Meta:
label = "Textový editor (pokročilý)"
icon = "doc-full"
template = "styleguide2/includes/atoms/text/prose_advanced_richtext.html"
DEFAULT_CONTENT_BLOCKS = [
(
"text",
......@@ -1074,6 +1119,10 @@ DEFAULT_CONTENT_BLOCKS = [
template="styleguide2/includes/atoms/text/prose_richtext.html",
),
),
(
"advanced_text",
AdvancedTextBlock()
),
("headline", HeadlineBlock()),
(
"table",
......
BLACK_ON_WHITE = "black_on_white"
WHITE_ON_BLACK = "white_on_black"
WHITE_ON_BLUE = "white_on_blue"
WHITE_ON_CYAN = "white_on_cyan"
WHITE_ON_VIOLET = "white_on_violet"
BLACK_ON_YELLOW = "black_on_yellow"
LEFT = "left"
CENTER = "center"
RIGHT = "right"
RICH_TEXT_DEFAULT_FEATURES = [
"h2",
"h3",
......@@ -32,3 +43,34 @@ MONTH_NAMES = [
"Listopad",
"Prosinec",
]
COLOR_CHOICES = (
(BLACK_ON_WHITE, "černá na bílé"),
(BLACK_ON_YELLOW, "černá na žluté"),
(WHITE_ON_BLACK, "bílá na černé"),
(WHITE_ON_BLUE, "bílá na modré"),
(WHITE_ON_CYAN, "bílá na tyrkysové"),
(WHITE_ON_VIOLET, "bílá na fialové"),
)
# TODO
COLOR_CSS = {
BLACK_ON_WHITE: ["text-black", "bg-white"],
BLACK_ON_YELLOW: ["text-black", "bg-pirati-yellow"],
WHITE_ON_BLACK: ["text-white", "bg-black"],
WHITE_ON_BLUE: ["text-white", "bg-blue-300"],
WHITE_ON_CYAN: ["text-white", "bg-cyan-300"],
WHITE_ON_VIOLET: ["text-white", "bg-violet-300"],
}
ALIGN_CHOICES = (
(LEFT, "vlevo"),
(CENTER, "uprostřed"),
(RIGHT, "vpravo"),
)
ALIGN_CSS = {
LEFT: ["text-left", "w-full", "[&_*]:mr-auto"],
CENTER: ["text-center", "w-full", "[&_*]:mx-auto"],
RIGHT: ["text-right", "w-full", "[&_*]:ml-auto"],
}
\ No newline at end of file
Source diff could not be displayed: it is too large. Options to address this: view the blob.
{% load wagtailcore_tags %}
<div class="{{ css_class|join:" " }}">
{% include "styleguide2/includes/atoms/text/prose_richtext.html" with text=self.text %}
</div>
......@@ -7,5 +7,9 @@
>
{% endif %}
{% if not text %}
{{ self }}
{% else %}
{{ text }}
{% endif %}
</div>
This diff is collapsed.
......@@ -42,7 +42,7 @@ from shared.models import (
CalendarMixin,
MainSearchPageMixin,
)
from shared.blocks import HeadlineBlock, NewsletterSubscriptionBlock, ChartBlock, GalleryBlock
from shared.blocks import HeadlineBlock, NewsletterSubscriptionBlock, ChartBlock, GalleryBlock, AdvancedTextBlock
from shared_legacy.models import FooterMixin as LegacyFooterMixin
from shared.const import RICH_TEXT_DEFAULT_FEATURES
from shared_legacy.utils import make_promote_panels, strip_all_html_tags, trim_to_length
......@@ -143,16 +143,6 @@ class PictureTitleBlock(ColorBlock):
template = "uniweb/blocks/picture_title.html"
class AdvancedTextBlock(ColorBlock, AlignBlock):
text = blocks.RichTextBlock(label="text", features=RICH_TEXT_DEFAULT_FEATURES)
class Meta:
label = "text (pokročilý)"
icon = "doc-full"
group = "texty"
template = "uniweb/blocks/advanced_text.html"
class PictureListBlock(ColorBlock):
items = blocks.ListBlock(
blocks.RichTextBlock(label="odstavec", features=RICH_TEXT_DEFAULT_FEATURES),
......@@ -295,6 +285,7 @@ CONTENT_STREAM_BLOCKS = [
),
# advanced_text
("advanced_text", AdvancedTextBlock()),
# text_columns
......@@ -371,7 +362,6 @@ CONTENT_STREAM_BLOCKS = [
# ),
# ),
("advanced_text", AdvancedTextBlock()),
("text_columns", ColumnsTextBlock()),
("advanced_text_columns", AdvancedColumnsTextBlock()),
(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment