Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More padding options #1578

Merged
merged 5 commits into from
Aug 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 59 additions & 0 deletions news/migrations/0051_alter_pressindex_faqs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# Generated by Django 5.0.7 on 2024-08-19 19:29

import wagtail.blocks
import wagtail.documents.blocks
import wagtail.fields
from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
("news", "0050_newsindex_display_footer_and_more"),
]

operations = [
migrations.AlterField(
model_name="pressindex",
name="faqs",
field=wagtail.fields.StreamField(
[
(
"faq",
wagtail.blocks.StructBlock(
[
(
"question",
wagtail.blocks.RichTextBlock(
help_text="The visible text of the question (does not collapse).", required=True
),
),
(
"slug",
wagtail.blocks.CharBlock(
help_text="Not visible to user, must be unique in this FAQ.", required=True
),
),
(
"answer",
wagtail.blocks.RichTextBlock(
help_text="The answer to the question, is hidden until the question is expanded.",
required=True,
),
),
(
"document",
wagtail.documents.blocks.DocumentChooserBlock(
help_text="Not sure this does anything.", required=False
),
),
]
),
)
],
blank=True,
null=True,
use_json_field=True,
),
),
]
64 changes: 34 additions & 30 deletions pages/custom_blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ class Meta:


class LinkBlock(blocks.StreamBlock):
external = blocks.URLBlock(required=False)
external = blocks.URLBlock(required=False, help_text='External links are full urls that can go anywhere')
internal = blocks.PageChooserBlock(required=False)
document = DocumentChooserBlock(required=False)
anchor = blocks.CharBlock(required=False)
anchor = blocks.CharBlock(required=False, help_text='Anchor links reference the ID of an element on the page, and scroll the page there.')

class Meta:
icon = 'link'
Expand Down Expand Up @@ -57,25 +57,25 @@ def get_api_representation(self, value, context=None):


class LinkInfoBlock(blocks.StructBlock):
text = blocks.CharBlock(required=True)
aria_label = blocks.CharBlock(required=False)
text = blocks.CharBlock(required=True, help_text='Visible text of the link or button.')
aria_label = blocks.CharBlock(required=False, help_text='Accessible label for the link or button. if provided, must begin with the visible text.')
target = LinkBlock(required=True)

class Meta:
icon = 'placeholder'
label = "Link"

class CTALinkBlock(LinkInfoBlock):
text = blocks.CharBlock(required=True)
aria_label = blocks.CharBlock(required=False)
text = blocks.CharBlock(required=True, help_text='Visible text of the link or button.')
aria_label = blocks.CharBlock(required=False, help_text='Accessible label for the link or button. if provided, must begin with the visible text.')
target = LinkBlock(required=True)
config = blocks.StreamBlock([
('style', blocks.ChoiceBlock(choices=[
('orange', 'Orange'),
('white', 'White'),
('blue_outline', 'Blue Outline'),
('deep_green_outline', 'Deep Green Outline'),
], default='descending')),
], help_text='Specifies the button style. Default unspecified, meaning the first button in the block is orange and the second is white.')),
], block_counts={
'style': {'max_num': 1},
}, required=False)
Expand All @@ -95,8 +95,8 @@ class LinksGroupBlock(blocks.StructBlock):
('white', 'White'),
('blue', 'Blue'),
('deep-green', 'Deep Green'),
], default='descending')),
('analytics_label', blocks.CharBlock(required=False)),
], help_text="The color of the link buttons. Default white.")),
('analytics_label', blocks.CharBlock(required=False, help_text='Sets the "analytics nav" field for links within this group.')),
], block_counts={
'color': {'max_num': 1},
'analytics_label': {'max_num': 1},
Expand All @@ -112,7 +112,7 @@ class CTAButtonBarBlock(blocks.StructBlock):
default=[], max_num=2, label='Actions'
)
config = blocks.StreamBlock([
('analytics_label', blocks.CharBlock(required=False)),
('analytics_label', blocks.CharBlock(required=False, help_text='Sets the "analytics nav" field for links within this group.')),
], block_counts={
'analytics_label': {'max_num': 1},
}, required=False)
Expand Down Expand Up @@ -140,9 +140,9 @@ def get_api_representation(self, value, context=None):

class QuoteBlock(StructBlock):
image = APIImageChooserBlock()
content = blocks.RichTextBlock()
name = blocks.CharBlock()
title = blocks.CharBlock(requred=False)
content = blocks.RichTextBlock(help_text="The quote content.")
name = blocks.CharBlock(help_text="The name of the person or entity to attribute the quote to.")
title = blocks.CharBlock(requred=False, help_text="Additional title or label about the quotee.")

class DividerBlock(StructBlock):
image = APIImageChooserBlock()
Expand All @@ -153,19 +153,23 @@ class DividerBlock(StructBlock):
('content_right', 'Right side of content.'),
('body_left', 'Left side of window.'),
('body_right', 'Right side of window.'),
], default='center')),
('width', blocks.RegexBlock(regex=r'^[0-9]+(px|%|rem)$', required=False, error_messages={
'invalid': "must be valid css measurement. eg: 30px, 50%, 10rem"
})),
('height', blocks.RegexBlock(regex=r'^[0-9]+(px|%|rem)$', required=False, error_messages={
'invalid': "must be valid css measurement. eg: 30px, 50%, 10rem"
})),
('offset_vertical', blocks.RegexBlock(regex=r'^\-?[0-9]+(px|%|rem)$', required=False, error_messages={
'invalid': "must be valid css measurement. eg: 30px, 50%, 10rem"
})),
('offset_horizontal', blocks.RegexBlock(regex=r'^\-?[0-9]+(px|%|rem)$', required=False, error_messages={
'invalid': "must be valid css measurement. eg: 30px, 50%, 10rem"
}))
], default='center', help_text='Sets the horizontal alignment of the image. can be further customized with the "Offset..." configurations. Default is Left side of window.')),
('width', blocks.RegexBlock(regex=r'^[0-9]+(px|%|rem)$', required=False,
help_text="Specifies the width of the image. Percentages are relative to the container (body or content, depending on alignment option). Must be valid css measurement. eg: 30px, 50%, 10rem. Default is the size of the image.",
error_mssages={'invalid': 'not a valid size.'}
)),
('height', blocks.RegexBlock(regex=r'^[0-9]+(px|%|rem)$', required=False,
help_text="Specifies the height of the image. Percentages are relative to the container (body or content, depending on alignment option). Must be valid css measurement. eg: 30px, 50%, 10rem. Default is the size of the image.",
error_mssages={'invalid': 'not a valid size.'}
)),
('offset_vertical', blocks.RegexBlock(regex=r'^\-?[0-9]+(px|%|rem)$', required=False,
help_text="Moves the image up or down. Percentages are relative to the image size. Must be valid css measurement. eg: 30px, 50%, 10rem. Default is -50%, which moves the image up by half its width (centering it vertically on the divider).",
error_mssages={'invalid': 'not a valid size.'}
)),
('offset_horizontal', blocks.RegexBlock(regex=r'^\-?[0-9]+(px|%|rem)$', required=False,
help_text="Moves the image left or right. Percentages are relative to the image size. Must be valid css measurement. eg: 30px, 50%, 10rem. Default is no offset, which means the image's outer edge will align with the container's edge for left and right alignment. or it'll be perfectly centered for centered alignment.",
error_mssages={'invalid': 'not a valid size.'}
))
], block_counts={
'alignment': {'max_num': 1},
'width': {'max_num': 1},
Expand Down Expand Up @@ -196,10 +200,10 @@ class Meta:


class FAQBlock(blocks.StructBlock):
question = blocks.RichTextBlock(required=True)
slug = blocks.CharBlock(required=True)
answer = blocks.RichTextBlock(required=True)
document = DocumentChooserBlock(required=False)
question = blocks.RichTextBlock(required=True, help_text='The visible text of the question (does not collapse).')
slug = blocks.CharBlock(required=True, help_text='Not visible to user, must be unique in this FAQ.')
answer = blocks.RichTextBlock(required=True, help_text='The answer to the question, is hidden until the question is expanded.')
document = DocumentChooserBlock(required=False, help_text='Not sure this does anything.')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this originally was so you could link to a PDF, but yeah, not sure if it still works


class Meta:
icon = 'bars'
Expand Down
Loading
Loading