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

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

Closed

Conversation

gzark1
Copy link
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
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.

details_block = DetailsBlock()


# StreamBlocks for Details
Copy link
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
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
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
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>
Copy link
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
Member

lb- commented Jul 1, 2023

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

@thibaudcolas
Copy link
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