-
Notifications
You must be signed in to change notification settings - Fork 0
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
feature: add grouping block #257
base: main
Are you sure you want to change the base?
Conversation
7d88d5e
to
77771c2
Compare
Deploying head-start with
|
Latest commit: |
1ef7394
|
Status: | ✅ Deploy successful! |
Preview URL: | https://04c6e922.head-start.pages.dev |
Branch Preview URL: | https://256-add-groupingblock.head-start.pages.dev |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jurgenbelien Could you have a look at this PR? It is non breaking and add the GroupingBlock
only
import GroupingBlock, { type Props } from './GroupingBlock.astro'; | ||
|
||
describe('GroupingBlock', () => { | ||
test('renders a stack layout without a title when layout is "stack-untitled"', async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same layout tests as done previously on Page Partial
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's not duplicate it. Remove the PagePartial tests that are about rendering it with a certain layout, and let the PagePartialBlock use the GroupingBlock to render.
type GroupingItem = { | ||
title: string; | ||
blocks: AnyBlock[]; | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GroupingItem
is only used inside GroupingBlock and does not exsist as a separate Block the content editor can add.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that you do have a Fragment for this that you can import...
77771c2
to
c042538
Compare
c042538
to
d6feeb6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's make sure the grouping logic is only in grouping block, and PagePartial uses the logic in GroupingBlock to render it (for the time being)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can move this out of it's containing folder, and put the whole fragment definition inside of the other block's fragment file
import GroupingBlock, { type Props } from './GroupingBlock.astro'; | ||
|
||
describe('GroupingBlock', () => { | ||
test('renders a stack layout without a title when layout is "stack-untitled"', async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's not duplicate it. Remove the PagePartial tests that are about rendering it with a certain layout, and let the PagePartialBlock use the GroupingBlock to render.
type GroupingItem = { | ||
title: string; | ||
blocks: AnyBlock[]; | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that you do have a Fragment for this that you can import...
'BRbU6VwTRgmG5SbwUs0rBg', | ||
'F60ZY1wFSW2qbvh99poj3g', | ||
'PAk40zGjQJCcDXXPgygUrA', | ||
'QYfZyBzIRWKxA1MinIR0aQ', | ||
'TBuD6qQOSDy6i9dM3T_XEA', | ||
'VZvVfu52RZK81WG0Dxp-FQ', | ||
'V80liDVtRC-UYgd3Sm-dXg', | ||
'ZdBokLsWRgKKjHrKeJzdpw', | ||
'gezG9nO7SfaiWcWnp-HNqw', | ||
'0SxYNS2CR1it_5LHYWuEQg', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider writing this in a nondestructive way. See #245
For this migration I'd say do the following for pages and homepage:
const homePageBodyBlocks = (await client.fields.find("home_page::body_blocks"))
.validators?.rich_text_blocks?.item_types || [];
await client.fields.update('pUj2PObgTyC-8X4lvZLMBA', {
validators: {
rich_text_blocks: {
item_types: [
...homePageBodyBlocks,
// grouping block.
9f2c445
to
1ef7394
Compare
...block, | ||
__typename: 'GroupingBlockRecord', | ||
items: block.items.map(item => ({ | ||
title: item.title, | ||
blocks: item.blocks as GroupingBlockFragment['items'][number]['blocks'], | ||
__typename: 'GroupingItemBlockRecord' | ||
})) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a very elegant way of typing, but mind that this is temporary
); | ||
|
||
console.log( | ||
'Create block model "\uD83D\uDDC2\uFE0F Grouping Item Block" (`grouping_item_block`)', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we maybe name it GroupingItem
instead of GroupingItemBlock
? It should only be used inside the GroupingBlock
, and should not be in AnyBlock
.
block: GroupingBlockFragment | ||
} | ||
export type GroupingItem = GroupingItemBlockFragment & { | ||
blocks: AnyBlock[]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would not expect AnyBlock
here, the definition of blocks is in GroupItem(Block)Fragment
@@ -0,0 +1,12 @@ | |||
#import './GroupingItemBlock.fragment.graphql' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Paste the contents of this fragment underneath the GroupingBlock
fragment
Changes
PagePartialBlock
into component to group content and component to reuse content #256 , adds aGroupingBlock
withGroupingItemBlock
.This is meant to replace a part of the
Page Partial Block
functions, but since the editing of thePage Partial Block
is a breaking change that will impact already existingPage Partial Block
s, this change will be dealt with in a different PR.This PR only adds a
GroupingBlock
which is a non-breaking change.Associated issue
#256 (non breaking half)
How to test
Checklist