add colored horizontal rule block

This commit is contained in:
2024-05-21 01:00:22 +02:00
parent 4d9796fbe7
commit 82f18dd24a
8 changed files with 101 additions and 20 deletions

View File

@ -68,3 +68,25 @@ class ImageSliderBlock(blocks.StructBlock):
class Meta:
icon = "image"
@register_streamfield_block
class HorizontalRuleBlock(blocks.StructBlock):
COLOR_CHOICES = (
("deepBrick", "Dyp tegl"),
("neufPink", "Griserosa"),
("goldenOrange", "Gyllen oransje"),
("goldenBeige", "Gyllen beige"),
("chateauBlue", "Slottsblå"),
)
color = blocks.ChoiceBlock(
label="Farge",
required=False,
choices=COLOR_CHOICES,
)
graphql_fields = [GraphQLString("color", required=False)]
class Meta:
icon = "minus"

View File

@ -1,13 +1,14 @@
from wagtail import blocks
from wagtail.fields import StreamField
from dnscms.blocks import ImageSliderBlock, ImageWithTextBlock
from dnscms.blocks import HorizontalRuleBlock, ImageSliderBlock, ImageWithTextBlock
CommonStreamField = StreamField(
[
("paragraph", blocks.RichTextBlock(label="Rik tekst")),
("image", ImageWithTextBlock(label="Bilde")),
("image_slider", ImageSliderBlock(label="Bildegalleri")),
("horizontal_rule", HorizontalRuleBlock(label="Skillelinje")),
],
default=[("paragraph", "")],
)