-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Try: Preact #2734
Try: Preact #2734
Changes from 1 commit
a9b4e07
f45e4ba
b699cf5
3379e61
acf0b64
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -94,19 +94,19 @@ registerBlockType( 'core/paragraph', { | |
const toggleDropCap = () => setAttributes( { dropCap: ! dropCap } ); | ||
const className = dropCap ? 'has-drop-cap' : null; | ||
|
||
return [ | ||
focus && ( | ||
<BlockControls key="controls"> | ||
return <div> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For consistency, should this be parenthesis-wrapped? |
||
{ focus && ( | ||
<BlockControls> | ||
<AlignmentToolbar | ||
value={ align } | ||
onChange={ ( nextAlign ) => { | ||
setAttributes( { align: nextAlign } ); | ||
} } | ||
/> | ||
</BlockControls> | ||
), | ||
focus && ( | ||
<InspectorControls key="inspector"> | ||
) } | ||
{ focus && ( | ||
<InspectorControls> | ||
<BlockDescription> | ||
<p>{ __( 'Text. Great things start here.' ) }</p> | ||
</BlockDescription> | ||
|
@@ -142,8 +142,8 @@ registerBlockType( 'core/paragraph', { | |
onChange={ ( nextWidth ) => setAttributes( { width: nextWidth } ) } | ||
/> | ||
</InspectorControls> | ||
), | ||
<BlockAutocomplete key="editable" onReplace={ onReplace }> | ||
) } | ||
<BlockAutocomplete onReplace={ onReplace }> | ||
<Editable | ||
tagName="p" | ||
className={ classnames( 'wp-block-paragraph', className, { | ||
|
@@ -162,21 +162,21 @@ registerBlockType( 'core/paragraph', { | |
content: nextContent, | ||
} ); | ||
} } | ||
focus={ focus } | ||
onFocus={ setFocus } | ||
onSplit={ ( before, after, ...blocks ) => { | ||
setAttributes( { content: before } ); | ||
insertBlocksAfter( [ | ||
...blocks, | ||
createBlock( 'core/paragraph', { content: after } ), | ||
] ); | ||
} } | ||
focus={ focus } | ||
onFocus={ setFocus } | ||
onMerge={ mergeBlocks } | ||
onReplace={ onReplace } | ||
placeholder={ placeholder || __( 'New Paragraph' ) } | ||
/> | ||
</BlockAutocomplete>, | ||
]; | ||
</BlockAutocomplete> | ||
</div>; | ||
}, | ||
|
||
save( { attributes } ) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,22 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import { noop } from 'lodash'; | ||
import { Slot } from 'react-slot-fill'; | ||
|
||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { Component } from '@wordpress/element'; | ||
|
||
class PopoverProvider extends Component { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Without context, this doesn't need to be a component class. I also don't think it needs to be a provider in the sense of having children, but rather a slot rendered directly in the layout component. Something like: |
||
getChildContext() { | ||
return { | ||
popoverTarget: this.props.target, | ||
}; | ||
} | ||
|
||
render() { | ||
return this.props.children; | ||
return ( | ||
<div> | ||
<div><Slot name="Popover" /></div> | ||
<div>{ this.props.children }</div> | ||
</div> | ||
); | ||
} | ||
} | ||
|
||
PopoverProvider.childContextTypes = { | ||
popoverTarget: noop, | ||
}; | ||
|
||
export default PopoverProvider; |
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.
Can we avoid the
Children
utility and instead leverage the fact thatchildren
is an array in Preact, i.e.I think it would be good if we avoid
Children
altogether.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.
That's the exact same thing, the inner implementation is the same, but I can see that this enables to drop
preact-compat
at some moment.