-
Notifications
You must be signed in to change notification settings - Fork 846
Paid Blocks Nudge: Fix Border by Injecting has-warning Style #13019
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
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
1e2edcc
Paid Blocks Nudge: Fix Border by Injecting has-warning Style
ockham e2e917d
wrapPaidBlock: Move out of directory
ockham 89f1d44
Add explanatory comment
ockham dc630d9
Apply class only to paid blocks
ockham 15adebb
Fix filter name
ockham 0c60443
Make Blocks Interactive Again
ockham 5f9b77a
Add a note to styles
simison File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
21 changes: 21 additions & 0 deletions
21
extensions/shared/with-has-warning-is-interactive-class-names/index.jsx
This file contains hidden or 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,21 @@ | ||
| /** | ||
| * External dependencies | ||
| */ | ||
| import { createHigherOrderComponent } from '@wordpress/compose'; | ||
|
|
||
| import './style.scss'; | ||
|
|
||
| // Injecting the `has-warning` class into the block wrapper component gives us | ||
| // the right kind of borders around the block, both visually and conceptually. | ||
| // However, it also adds styling to prevent user interaction with that block. | ||
| // We thus add a new `is-interactive` class to be able to override that behavior. | ||
| export default name => | ||
| createHigherOrderComponent( | ||
| BlockListBlock => props => ( | ||
| <BlockListBlock | ||
| { ...props } | ||
| className={ props.name === name ? 'has-warning is-interactive' : '' } | ||
|
Member
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.
|
||
| /> | ||
| ), | ||
| 'withHasWarningIsInteractiveClassNames' | ||
| ); | ||
14 changes: 14 additions & 0 deletions
14
extensions/shared/with-has-warning-is-interactive-class-names/style.scss
This file contains hidden or 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,14 @@ | ||
| .block-editor-block-list__layout | ||
simison marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| // Override core styles inherited from `.has-warning`: | ||
| // we do want blocks with upgrade nudge warning to be interactive | ||
| .block-editor-block-list__block.has-warning.is-interactive | ||
| .block-editor-block-list__block-edit { | ||
| > * { | ||
| pointer-events: auto; | ||
| user-select: auto; | ||
| } | ||
|
|
||
| &:after { | ||
| content: none; | ||
| } | ||
| } | ||
14 changes: 4 additions & 10 deletions
14
extensions/shared/wrap-paid-block/index.jsx → extensions/shared/wrap-paid-block.jsx
This file contains hidden or 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 |
|---|---|---|
| @@ -1,28 +1,22 @@ | ||
| /** | ||
| * External dependencies | ||
| */ | ||
| import classNames from 'classnames'; | ||
| import { Fragment } from '@wordpress/element'; | ||
| import { createHigherOrderComponent } from '@wordpress/compose'; | ||
|
|
||
| /** | ||
| * Internal dependencies | ||
| */ | ||
| import UpgradeNudge from '../upgrade-nudge'; | ||
|
|
||
| import './style.scss'; | ||
| import UpgradeNudge from './upgrade-nudge'; | ||
|
|
||
| export default ( { requiredPlan } ) => | ||
| createHigherOrderComponent( | ||
| WrappedComponent => props => ( | ||
| // Wraps the input component in a container, without mutating it. Good! | ||
| <div | ||
| className={ classNames( 'jetpack-paid-block__wrapper', { | ||
| 'is-selected': props.isSelected, | ||
| } ) } | ||
| > | ||
| <Fragment> | ||
| <UpgradeNudge plan={ requiredPlan } /> | ||
| <WrappedComponent { ...props } /> | ||
| </div> | ||
| </Fragment> | ||
| ), | ||
| 'wrapPaidBlock' | ||
| ); |
This file was deleted.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Haha that's a mouthful!
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.
Yeah, same for the component name 😬 Happy to change it something more palatable!