-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add "details" block * Add variation, fix stylesheet loading on front, change font size * Remove the link option from the summary heading, update aria label * Update edit.js * Keep the details open in the editor * Add toolbar control for collapsing and expanding the details, remove border * Update fixtures * Update style.scss * re-add the font size for the heading * Remove font size limitations * Update cursor to pointer. * Add aria label that announces the expanded or collapsed state * Remove transcript variation, add keywords * Open the details when the block is selected * Update edit.js * Add a basic unwrap * Update edit.js * Try using separate blocks * Update summary text, descriptions and fixtures * Update edit.js * remove transform and editor style. * update icons. * Limit the inner blocks to one inside the Details block * Remove the alignments from the inner blocks, and prevent them from being used as reusable blocks. * Update index.js * Add the icon * Try to apply font size to the heading inside summary * Update fixtures * Remove the allowed formatting from the RichText * Try the experimentalSelector and skipSerialization again * Remove heading from Summary * Rename the block, update CSS. * Update style.scss * Change the category to text * Remove unsupported marker CSS * fix background clipping and update description * Replace inner div with View primitive * Remove View from save.js * Remove translation from save.js * Make the block opt-in, available from the Experiments page. * remove fixtures
- Loading branch information
Showing
25 changed files
with
487 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
{ | ||
"$schema": "https://schemas.wp.org/trunk/block.json", | ||
"apiVersion": 2, | ||
"__experimental": true, | ||
"name": "core/details-content", | ||
"title": "Details Content", | ||
"category": "text", | ||
"parent": [ "core/details" ], | ||
"description": "Add content that may be shown or hidden via a Details block.", | ||
"textdomain": "default", | ||
"supports": { | ||
"align": false, | ||
"color": { | ||
"gradients": true, | ||
"link": true, | ||
"__experimentalDefaultControls": { | ||
"background": true, | ||
"text": true, | ||
"link": true | ||
} | ||
}, | ||
"__experimentalBorder": { | ||
"radius": true, | ||
"color": true, | ||
"width": true, | ||
"style": true | ||
}, | ||
"html": false, | ||
"lock": false, | ||
"multiple": false, | ||
"reusable": false, | ||
"spacing": { | ||
"margin": true, | ||
"padding": true | ||
}, | ||
"typography": { | ||
"fontSize": true, | ||
"lineHeight": true, | ||
"__experimentalFontFamily": true, | ||
"__experimentalFontWeight": true, | ||
"__experimentalFontStyle": true, | ||
"__experimentalTextTransform": true, | ||
"__experimentalTextDecoration": true, | ||
"__experimentalLetterSpacing": true, | ||
"__experimentalDefaultControls": { | ||
"fontSize": true | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { useBlockProps, useInnerBlocksProps } from '@wordpress/block-editor'; | ||
import { __ } from '@wordpress/i18n'; | ||
import { View } from '@wordpress/primitives'; | ||
|
||
const TEMPLATE = [ | ||
[ | ||
'core/paragraph', | ||
{ | ||
placeholder: __( | ||
'Add text or blocks that will display when the details block is opened.' | ||
), | ||
}, | ||
], | ||
]; | ||
|
||
function DetailsContentEdit() { | ||
const blockProps = useBlockProps(); | ||
const innerBlocksProps = useInnerBlocksProps( blockProps, { | ||
template: TEMPLATE, | ||
templateLock: false, | ||
} ); | ||
|
||
return <View { ...innerBlocksProps }></View>; | ||
} | ||
|
||
export default DetailsContentEdit; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { postContent as icon } from '@wordpress/icons'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import initBlock from '../utils/init-block'; | ||
import metadata from './block.json'; | ||
import edit from './edit'; | ||
import save from './save'; | ||
|
||
const { name } = metadata; | ||
export { metadata, name }; | ||
|
||
export const settings = { | ||
icon, | ||
save, | ||
edit, | ||
}; | ||
|
||
export const init = () => initBlock( { name, metadata, settings } ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { useBlockProps, InnerBlocks } from '@wordpress/block-editor'; | ||
export default function save() { | ||
const blockProps = useBlockProps.save(); | ||
return ( | ||
<div { ...blockProps }> | ||
<InnerBlocks.Content /> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
{ | ||
"$schema": "https://schemas.wp.org/trunk/block.json", | ||
"apiVersion": 2, | ||
"__experimental": true, | ||
"name": "core/details-summary", | ||
"title": "Details Summary", | ||
"category": "text", | ||
"parent": [ "core/details" ], | ||
"description": "Provide summary text used to toggle the display of content inside a Details block.", | ||
"textdomain": "default", | ||
"attributes": { | ||
"summary": { | ||
"type": "string" | ||
} | ||
}, | ||
"supports": { | ||
"align": false, | ||
"color": { | ||
"gradients": true, | ||
"__experimentalDefaultControls": { | ||
"background": true, | ||
"text": true | ||
} | ||
}, | ||
"__experimentalBorder": { | ||
"radius": true, | ||
"color": true, | ||
"width": true, | ||
"style": true | ||
}, | ||
"html": false, | ||
"lock": false, | ||
"multiple": false, | ||
"reusable": false, | ||
"spacing": { | ||
"margin": true, | ||
"padding": true | ||
}, | ||
"typography": { | ||
"fontSize": true, | ||
"lineHeight": true, | ||
"__experimentalFontFamily": true, | ||
"__experimentalFontWeight": true, | ||
"__experimentalFontStyle": true, | ||
"__experimentalTextTransform": true, | ||
"__experimentalTextDecoration": true, | ||
"__experimentalLetterSpacing": true, | ||
"__experimentalDefaultControls": { | ||
"fontSize": true | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { RichText, useBlockProps } from '@wordpress/block-editor'; | ||
import { __ } from '@wordpress/i18n'; | ||
|
||
function DetailsSummaryEdit( { attributes, setAttributes } ) { | ||
const summary = attributes.summary ? attributes.summary : __( 'Details' ); | ||
return ( | ||
<summary | ||
{ ...useBlockProps() } | ||
onClick={ ( event ) => event.preventDefault() } | ||
> | ||
<RichText | ||
aria-label={ __( 'Add summary' ) } | ||
allowedFormats={ [] } | ||
withoutInteractiveFormatting | ||
value={ summary } | ||
onChange={ ( newSummary ) => | ||
setAttributes( { summary: newSummary } ) | ||
} | ||
/> | ||
</summary> | ||
); | ||
} | ||
|
||
export default DetailsSummaryEdit; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.wp-block-details-summary div { | ||
display: inline; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { heading as icon } from '@wordpress/icons'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import initBlock from '../utils/init-block'; | ||
import metadata from './block.json'; | ||
import edit from './edit'; | ||
import save from './save'; | ||
|
||
const { name } = metadata; | ||
export { metadata, name }; | ||
|
||
export const settings = { | ||
icon, | ||
save, | ||
edit, | ||
}; | ||
|
||
export const init = () => initBlock( { name, metadata, settings } ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { RichText, useBlockProps } from '@wordpress/block-editor'; | ||
|
||
export default function save( { attributes } ) { | ||
const summary = attributes.summary ? attributes.summary : 'Details'; | ||
return ( | ||
<summary { ...useBlockProps.save() }> | ||
<RichText.Content value={ summary } /> | ||
</summary> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.wp-block-details-summary { | ||
cursor: pointer; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
{ | ||
"$schema": "https://schemas.wp.org/trunk/block.json", | ||
"apiVersion": 2, | ||
"__experimental": true, | ||
"name": "core/details", | ||
"title": "Details", | ||
"category": "text", | ||
"description": "A block that displays a summary and shows or hides additional content.", | ||
"keywords": [ "disclosure", "summary", "hide", "transcript" ], | ||
"textdomain": "default", | ||
"attributes": { | ||
"showContent": { | ||
"type": "boolean", | ||
"default": false | ||
} | ||
}, | ||
"supports": { | ||
"align": true, | ||
"color": { | ||
"gradients": true, | ||
"link": true, | ||
"__experimentalDefaultControls": { | ||
"background": true, | ||
"text": true, | ||
"link": true | ||
} | ||
}, | ||
"__experimentalBorder": { | ||
"radius": true, | ||
"color": true, | ||
"width": true, | ||
"style": true | ||
}, | ||
"html": false, | ||
"spacing": { | ||
"margin": true, | ||
"padding": true | ||
}, | ||
"typography": { | ||
"fontSize": true, | ||
"lineHeight": true, | ||
"__experimentalFontFamily": true, | ||
"__experimentalFontWeight": true, | ||
"__experimentalFontStyle": true, | ||
"__experimentalTextTransform": true, | ||
"__experimentalTextDecoration": true, | ||
"__experimentalLetterSpacing": true, | ||
"__experimentalDefaultControls": { | ||
"fontSize": true | ||
} | ||
} | ||
}, | ||
"style": "wp-block-details" | ||
} |
Oops, something went wrong.
b23e214
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.
Flaky tests detected in b23e214.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.
🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/4624851511
📝 Reported issues:
/test/e2e/specs/site-editor/template-part.spec.js
/test/e2e/specs/site-editor/template-part.spec.js
/test/e2e/specs/editor/blocks/columns.spec.js