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

Create guidance for building flexible blocks #4330

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

leenagupte
Copy link
Contributor

@leenagupte leenagupte commented Oct 24, 2024

⚠️ This repo is Continuously Deployed: make sure you follow the guidance ⚠️

What

Documents what each of the blocks is, when they should be used and how they are configured.

Why

Trello card

Rendered version

@govuk-ci govuk-ci temporarily deployed to govuk-frontend-app-pr-4330 October 24, 2024 15:19 Inactive
@govuk-ci govuk-ci temporarily deployed to govuk-frontend-app-pr-4330 October 24, 2024 15:28 Inactive
@govuk-ci govuk-ci temporarily deployed to govuk-frontend-app-pr-4330 October 28, 2024 12:33 Inactive
@govuk-ci govuk-ci had a problem deploying to govuk-frontend-app-pr-4330 October 28, 2024 12:42 Failure
@govuk-ci govuk-ci temporarily deployed to govuk-frontend-app-pr-4330 October 28, 2024 13:39 Inactive
@govuk-ci govuk-ci temporarily deployed to govuk-frontend-app-pr-4330 October 28, 2024 17:28 Inactive
@govuk-ci govuk-ci had a problem deploying to govuk-frontend-app-pr-4330 October 29, 2024 13:57 Failure
@govuk-ci govuk-ci temporarily deployed to govuk-frontend-app-pr-4330 October 31, 2024 09:26 Inactive
@govuk-ci govuk-ci temporarily deployed to govuk-frontend-app-pr-4330 November 5, 2024 16:45 Inactive
@govuk-ci govuk-ci temporarily deployed to govuk-frontend-app-pr-4330 November 6, 2024 13:18 Inactive
Documents what each of the blocks is, when they should be used and how
they are configured.

Co-authored-by: Keith Lawrence <[email protected]>
@leenagupte leenagupte marked this pull request as ready for review November 7, 2024 14:53
@leenagupte leenagupte changed the title [WIP] Create guidance for building flexible blocks Create guidance for building flexible blocks Nov 7, 2024
Copy link
Contributor

@maxgds maxgds 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 requested and a bit of clarity sought. Some quite nitpicky so it's not as bad as it might seem at a glance.


Blocks are rendered in the order that they appear in the content item.

Blocks are added to the content item in the details hash. The landing page editor is currently a work in progress. At time of writing, the config for blocks need to be added in YAML format in Whitehall. This YAML config is then merged into `details` hash when the landing page is saved and published.
Copy link
Contributor

Choose a reason for hiding this comment

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

grammar nitpick: either "the details hash" or just "details" without "hash"


## Types of Block

Each block rendered using its own partial template. The full list of available types of block available can be found by looking at the contents of: `app/views/landing_page/blocks`
Copy link
Contributor

Choose a reason for hiding this comment

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

Grammar nitpick:
Each block is rendered
OR
Each block renders


### Simple blocks

Simple blocks general render one component or "thing". They can either be rendered directly or as the children of compound blocks.
Copy link
Contributor

Choose a reason for hiding this comment

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

Nitpick:
generally, not general

#### Govspeak

A wrapper around the [Govspeak content component](https://components.publishing.service.gov.uk/component-guide/govspeak). Note that the content item data for the component is not Govspeak, but HTML that has been converted from Govspeak. If you're editing the block data in Whitehall, though, you can use Govspeak directly by taking advantage of the publishing-api automatic conversion (see second example)

Copy link
Contributor

Choose a reason for hiding this comment

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

This reads as a bit confusing. This makes it sound like I need to go and find a tool to produce some HTML by converting it whereas in fact I can just supply any supported HTML. I don't think there's any need to mention publishing-api, just that there are two options for input: Any HTML which only uses the govspeak approved subset of tags, or govspeak. Then call out the syntax difference needed for each option as illustrated.


#### Heading

A wrapper around the [Heading component](https://components.publishing.service.gov.uk/component-guide/heading). Note, though, that the block uses `content` where the component uses `text` for the title text key. This is so that headings can be indexed (only values inside a `content` key will be indexed when being published from Whitehall - see [Indexing block content in search](#indexing-block-content-in-search))
Copy link
Contributor

Choose a reason for hiding this comment

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

This contextless reference to indexing threw me. The link to indexing helped, but I could have made more sense of this if you specified search here - I was thinking we were numbering headings for some reason as per an array index. Suggestion:
"This is so that headings can appear in search (only values..." etc

#### Blocks container

A blocks container is used as an empty unstyled parent container to
hold other elements. It is used when we don't want to want to create
Copy link
Contributor

Choose a reason for hiding this comment

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

Why/when would we not want to create a row/grid layout?

Copy link
Contributor Author

@leenagupte leenagupte Nov 7, 2024

Choose a reason for hiding this comment

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

I pilfered that explanation from the commit message. Does that explanation make sense? If so I can replicate it wholesale.

```

The left column is always populated if only one column is defined.
A blocks container applied to a column so that everying in the column can be styled relative to one and other.
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this sentence is missing some words, I don't quite follow. Also typo in "everying".


## Indexing block content in search

Only content in blocks that has a label of `content` will be indexed in site search.
Copy link
Contributor

Choose a reason for hiding this comment

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

grammar: "have a label" not has


## Extending a page (Whitehall Only)

When editing a page in Whitehall, you may wish to use data from another page. Adding the top-level key `extends`, and the path of another landing page, will cause the data from the current block to be merged over the data from the extended block before publishing. This is a shallow merge (ie only top-level values are checked), and is currently used so that navigation groups can be specified in one page and used by sub-pages.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggestion: For clarity change "you may wish to use data from another page" to "you may wish to use data from another flexible content page" as there are many things on GOV.UK called pages.


...the navigation_groups element will be copied into the child page when it is saved (allowing you to specify a shared menu in one page and simply republish all the child pages with a standard Whitehall rake task).

If the child page didn't specify any blocks, those too would be merged over from the parent. That's because `extends` does a shallow merge of everything in the `details` element of the parent. This means that it is possible to add more top-level elements that can be shared across child pages.
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm a bit confused by this bit about copying blocks over and why they are copied if empty and not copied otherwise.

I also don't really understand what I'll see in Whitehall - if I create a child page as above and save it, when I load it again will I see what I originally wrote or will it have expanded out all the links? If a navigation item changes do I need to hand edit every child or run a rake task to do so?`

Links out to running relevant rake tasks would be helpful if that's necessary - details on how to specify the right content items for the rake task etc

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