Skip to content

Commit

Permalink
DSRC-3: Accordion Block (#1639)
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesbiggs authored Jul 17, 2024
1 parent b244eee commit 5b8a650
Show file tree
Hide file tree
Showing 4 changed files with 750 additions and 0 deletions.
2 changes: 2 additions & 0 deletions etna/core/blocks/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from .accordion import AccordionsBlock
from .base import SectionDepthAwareStructBlock
from .cta import ButtonBlock, CallToActionBlock, LargeCardLinksBlock
from .document import DocumentsBlock
Expand Down Expand Up @@ -25,6 +26,7 @@
from .video import YouTubeBlock

__all__ = [
"AccordionsBlock",
"APIPageChooserBlock",
"AuthorPromotedPagesBlock",
"ButtonBlock",
Expand Down
32 changes: 32 additions & 0 deletions etna/core/blocks/accordion.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
from django.conf import settings

from wagtail import blocks

from .document import DocumentsBlock
from .paragraph import APIRichTextBlock
from .tables import TableBlock


class AccordionContentBlock(blocks.StreamBlock):
text = APIRichTextBlock(
required=True, features=settings.RESTRICTED_RICH_TEXT_FEATURES
)
table = TableBlock()
documents = DocumentsBlock()

class Meta:
icon = "list-ul"
label = "Body"


class AccordionBlock(blocks.StructBlock):
title = blocks.CharBlock(required=True)
body = AccordionContentBlock()

class Meta:
icon = "list-ul"
label = "Accordion Item"


class AccordionsBlock(blocks.StructBlock):
items = blocks.ListBlock(AccordionBlock())
2 changes: 2 additions & 0 deletions etna/generic_pages/blocks.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from wagtail import blocks

from etna.core.blocks import (
AccordionsBlock,
ButtonBlock,
CallToActionBlock,
ContentImageBlock,
Expand All @@ -24,6 +25,7 @@


class SectionContentBlock(blocks.StreamBlock):
accordions = AccordionsBlock()
button = ButtonBlock()
call_to_action = CallToActionBlock()
document = DocumentsBlock()
Expand Down
Loading

0 comments on commit 5b8a650

Please sign in to comment.