Skip to content

Add new custom block "DetailsBlock" with expanding answers and demonstrate it in a BreadPage and in a new FAQ page.#422

Closed
gzark1 wants to merge 11 commits intowagtail:mainfrom
gzark1:feature/details-block-implementation
Closed

Add new custom block "DetailsBlock" with expanding answers and demonstrate it in a BreadPage and in a new FAQ page.#422
gzark1 wants to merge 11 commits intowagtail:mainfrom
gzark1:feature/details-block-implementation

Conversation

@gzark1
Copy link
Copy Markdown
Contributor

@gzark1 gzark1 commented Jun 26, 2023

@lb- suggested adding a DetailsBlock to showcase a custom block with its own HTML template. The DetailsBlock includes three fields: summary (CharField), content (RichTextField), and open (BooleanField, defaulting to open). This block is ideal for creating an FAQ page with expanding answers and allows for the use of semantic and modern HTML.

Changes Made:

  1. Created a DetailsBlock class inheriting from StructBlock with the specified fields.
  2. Added the DetailsBlock to the StreamField used by other pages for their content, providing them with the option to include a details block.

image

  1. Created a template, details_block.html, for rendering the DetailsBlock.
  2. Added CSS selectors for the DetailsBlock summary and content in the main CSS file.
  3. Demonstrated the usage of the DetailsBlock in a bread page.

image

  1. Implemented a standalone StreamField with only the DetailsBlock option, showcased in a new FAQ page of the StandardPage type.

image

image

  1. Created sample data for both the bread page and the FAQ page, stored in bakerydemo/base/fixtures/bakerydemo.json.

  2. Added the FAQ page to the navigation menu.

image

Copy link
Copy Markdown
Member

@lb- lb- left a comment

Choose a reason for hiding this comment

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

A few changes, I think the way the fixtures have been changed needs some work.

Comment thread bakerydemo/base/blocks.py
details_block = DetailsBlock()


# StreamBlocks for Details
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is probably not needed, you can use a single block easily with StreamField

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

So you suggest not adding the DetailsBlock option to the "old" BaseStreamBlock , just to the "new" DetailsStreamBlock that I created?

"organisation_url": "https://wagtail.org/"
"twitter_url": "",
"github_url": "",
"organisation_url": ""
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I don't think this removal is intentional.

}
},
{
"model": "wagtailsearchpromotions.querydailyhits",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I don't think we need to add these to the fixtures

<div class="details-content">
{{ self.content }}
</div>
</details> No newline at end of file
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please add a line break at the end of this file.

@lb-
Copy link
Copy Markdown
Member

lb- commented Jul 1, 2023

@gzark1 can you close this PR if the newer one is preferred

@thibaudcolas
Copy link
Copy Markdown
Member

Closing in favour of #425.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants