add fact box block
This commit is contained in:
+43
-19
@@ -8,6 +8,15 @@ from grapple.models import (
|
||||
from wagtail import blocks
|
||||
from wagtail.images.blocks import ImageChooserBlock
|
||||
|
||||
BACKGROUND_COLOR_CHOICES = (
|
||||
("betongGray", "Betonggrå"),
|
||||
("deepBrick", "Dyp tegl"),
|
||||
("neufPink", "Griserosa"),
|
||||
("goldenOrange", "Gyllen oransje"),
|
||||
("goldenBeige", "Gyllen beige"),
|
||||
("chateauBlue", "Slottsblå"),
|
||||
)
|
||||
|
||||
|
||||
@register_streamfield_block
|
||||
class ImageWithTextBlock(blocks.StructBlock):
|
||||
@@ -103,15 +112,6 @@ class FeaturedBlock(blocks.StructBlock):
|
||||
("right", "Høyre"),
|
||||
)
|
||||
|
||||
COLOR_CHOICES = (
|
||||
("betongGray", "Betonggrå"),
|
||||
("deepBrick", "Dyp tegl"),
|
||||
("neufPink", "Griserosa"),
|
||||
("goldenOrange", "Gyllen oransje"),
|
||||
("goldenBeige", "Gyllen beige"),
|
||||
("chateauBlue", "Slottsblå"),
|
||||
)
|
||||
|
||||
title = blocks.CharBlock(max_length=64, required=True, label="Tittel")
|
||||
text = blocks.RichTextBlock(features=["bold", "italic", "link"], required=True, label="Tekst")
|
||||
featured_page = blocks.PageChooserBlock(header="Fremhevet side", required=True)
|
||||
@@ -126,7 +126,7 @@ class FeaturedBlock(blocks.StructBlock):
|
||||
label="Bakgrunnsfarge",
|
||||
required=True,
|
||||
default="betongGray",
|
||||
choices=COLOR_CHOICES,
|
||||
choices=BACKGROUND_COLOR_CHOICES,
|
||||
)
|
||||
image_position = blocks.ChoiceBlock(
|
||||
required=True,
|
||||
@@ -200,6 +200,37 @@ class AccordionBlock(blocks.StructBlock):
|
||||
label = "Trekkspill"
|
||||
|
||||
|
||||
@register_streamfield_block
|
||||
class FactBoxBlock(blocks.StructBlock):
|
||||
heading = blocks.CharBlock(max_length=64, required=True, label="Overskrift")
|
||||
background_color = blocks.ChoiceBlock(
|
||||
label="Bakgrunnsfarge",
|
||||
required=False,
|
||||
choices=BACKGROUND_COLOR_CHOICES,
|
||||
)
|
||||
body = blocks.StreamBlock(
|
||||
[
|
||||
(
|
||||
"paragraph",
|
||||
blocks.RichTextBlock(
|
||||
features=["bold", "italic", "link", "ol", "ul", "h2", "h3", "h4", "h5", "h6"],
|
||||
label="Tekst",
|
||||
),
|
||||
),
|
||||
]
|
||||
)
|
||||
|
||||
graphql_fields = [
|
||||
GraphQLString("heading", required=True),
|
||||
GraphQLStreamfield("body", required=True),
|
||||
GraphQLString("background_color", required=False),
|
||||
]
|
||||
|
||||
class Meta:
|
||||
icon = "info-circle"
|
||||
label = "Faktaboks"
|
||||
|
||||
|
||||
BASE_BLOCKS = [
|
||||
("paragraph", blocks.RichTextBlock(label="Rik tekst")),
|
||||
("image", ImageWithTextBlock()),
|
||||
@@ -208,24 +239,17 @@ BASE_BLOCKS = [
|
||||
("featured", FeaturedBlock()),
|
||||
("page_section_navigation", PageSectionNavigationBlock()),
|
||||
("accordion", AccordionBlock()),
|
||||
("fact_box", FactBoxBlock()),
|
||||
]
|
||||
|
||||
|
||||
@register_streamfield_block
|
||||
class PageSectionBlock(blocks.StructBlock):
|
||||
COLOR_CHOICES = (
|
||||
("deepBrick", "Dyp tegl"),
|
||||
("neufPink", "Griserosa"),
|
||||
("goldenOrange", "Gyllen oransje"),
|
||||
("goldenBeige", "Gyllen beige"),
|
||||
("chateauBlue", "Slottsblå"),
|
||||
)
|
||||
|
||||
title = blocks.CharBlock(max_length=64, required=True, label="Tittel")
|
||||
background_color = blocks.ChoiceBlock(
|
||||
label="Bakgrunnsfarge",
|
||||
required=False,
|
||||
choices=COLOR_CHOICES,
|
||||
choices=BACKGROUND_COLOR_CHOICES,
|
||||
)
|
||||
body = blocks.StreamBlock(
|
||||
[block for block in BASE_BLOCKS if block[0] != "page_section_navigation"]
|
||||
|
||||
Reference in New Issue
Block a user