-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Properly apply styles and classes to the experimental form block #55755
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 1 commit
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
887c31f
Properly apply styles and classes to the form block
aristath cd9b0a7
CS fix
aristath 568083a
apply changes in the editor - fixes typography issue
aristath 5121b86
A better method to save styles & classes
aristath 8283769
revert index.php changes
aristath 926570e
remove className: false
aristath a1037d0
Remove unnecessary styles and classes
t-hamano 996f280
Merge branch 'trunk' into try/fix-form-styles
aristath b8474c8
Add deprecation
aristath 6e7c287
Merge branch 'trunk' into try/fix-form-styles
aristath f612d4e
Merge branch 'trunk' into try/fix-form-styles
aristath c6cdda0
WIP - fix deprecation
aristath de8f0e1
Merge branch 'trunk' into try/fix-form-styles
aristath abb69b9
Add anchor attribute to deprecated.js
aristath 9f2b296
Merge branch 'trunk' into try/fix-form-styles
aristath 3f4f6cc
Update core-blocks.md
aristath b0645e0
add fixture for deprecated version of block
aristath eb62475
Revert "add fixture for deprecated version of block"
aristath 77efc02
remove deprecation
aristath f4c3f0e
Merge branch 'trunk' into try/fix-form-styles
t-hamano b2734fa
Add deprecation
t-hamano 9c38985
Merge branch 'trunk' into try/fix-form-styles
t-hamano 006337e
Merge branch 'trunk' into try/fix-form-styles
t-hamano 3e9c06a
Explicitly add props and add fixtures
t-hamano 87e931a
Merge branch 'trunk' into try/fix-form-styles
t-hamano 8be747e
Split fixture file
t-hamano 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
Explicitly add props and add fixtures
- Loading branch information
commit 3e9c06acd8391dc92fc2c24f1680b3687541f1b9
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
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
7 changes: 7 additions & 0 deletions
7
test/integration/fixtures/blocks/core__form__deprecated-v1.html
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,7 @@ | ||
| <!-- wp:form {"className":"custom-class","style":{"elements":{"link":{"color":{"text":"#ff0000"}}},"color":{"text":"#ff0000","background":"#00ffff"},"typography":{"fontSize":"30px"},"spacing":{"padding":{"top":"1px","bottom":"1px","left":"2px","right":"2px"},"margin":{"top":"3px","bottom":"3px","left":"4px","right":"4px"}}}} --> | ||
| <form id="anchor" class="wp-block-form" style="color:#ff0000;background-color:#00ffff;margin-top:3px;margin-right:4px;margin-bottom:3px;margin-left:4px;padding-top:1px;padding-right:2px;padding-bottom:1px;padding-left:2px;font-size:30px" enctype="text/plain"></form> | ||
| <!-- /wp:form --> | ||
|
|
||
| <!-- wp:form {"className":"custom-class","style":{"elements":{"link":{"color":{"text":"var:preset|color|contrast"}}},"spacing":{"padding":{"top":"var:preset|spacing|40","bottom":"var:preset|spacing|40","left":"var:preset|spacing|40","right":"var:preset|spacing|40"},"margin":{"top":"var:preset|spacing|40","bottom":"var:preset|spacing|40","left":"var:preset|spacing|40","right":"var:preset|spacing|40"}}},"backgroundColor":"accent-1","textColor":"contrast","fontSize":"x-large"} --> | ||
| <form id="anchor" class="wp-block-form" style="margin-top:var(--wp--preset--spacing--40);margin-right:var(--wp--preset--spacing--40);margin-bottom:var(--wp--preset--spacing--40);margin-left:var(--wp--preset--spacing--40);padding-top:var(--wp--preset--spacing--40);padding-right:var(--wp--preset--spacing--40);padding-bottom:var(--wp--preset--spacing--40);padding-left:var(--wp--preset--spacing--40)" enctype="text/plain"></form> | ||
| <!-- /wp:form --> | ||
78 changes: 78 additions & 0 deletions
78
test/integration/fixtures/blocks/core__form__deprecated-v1.json
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,78 @@ | ||
| [ | ||
| { | ||
| "name": "core/form", | ||
| "isValid": true, | ||
| "attributes": { | ||
| "submissionMethod": "email", | ||
| "method": "post", | ||
| "anchor": "anchor", | ||
| "style": { | ||
| "elements": { | ||
| "link": { | ||
| "color": { | ||
| "text": "#ff0000" | ||
| } | ||
| } | ||
| }, | ||
| "color": { | ||
| "text": "#ff0000", | ||
| "background": "#00ffff" | ||
| }, | ||
| "typography": { | ||
| "fontSize": "30px" | ||
| }, | ||
| "spacing": { | ||
| "padding": { | ||
| "top": "1px", | ||
| "bottom": "1px", | ||
| "left": "2px", | ||
| "right": "2px" | ||
| }, | ||
| "margin": { | ||
| "top": "3px", | ||
| "bottom": "3px", | ||
| "left": "4px", | ||
| "right": "4px" | ||
| } | ||
| } | ||
| } | ||
| }, | ||
| "innerBlocks": [] | ||
| }, | ||
| { | ||
| "name": "core/form", | ||
| "isValid": true, | ||
| "attributes": { | ||
| "submissionMethod": "email", | ||
| "method": "post", | ||
| "anchor": "anchor", | ||
| "backgroundColor": "accent-1", | ||
| "textColor": "contrast", | ||
| "style": { | ||
| "elements": { | ||
| "link": { | ||
| "color": { | ||
| "text": "var:preset|color|contrast" | ||
| } | ||
| } | ||
| }, | ||
| "spacing": { | ||
| "padding": { | ||
| "top": "var:preset|spacing|40", | ||
| "bottom": "var:preset|spacing|40", | ||
| "left": "var:preset|spacing|40", | ||
| "right": "var:preset|spacing|40" | ||
| }, | ||
| "margin": { | ||
| "top": "var:preset|spacing|40", | ||
| "bottom": "var:preset|spacing|40", | ||
| "left": "var:preset|spacing|40", | ||
| "right": "var:preset|spacing|40" | ||
| } | ||
| } | ||
| }, | ||
| "fontSize": "x-large" | ||
| }, | ||
| "innerBlocks": [] | ||
| } | ||
| ] |
87 changes: 87 additions & 0 deletions
87
test/integration/fixtures/blocks/core__form__deprecated-v1.parsed.json
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,87 @@ | ||
| [ | ||
| { | ||
| "blockName": "core/form", | ||
| "attrs": { | ||
| "className": "custom-class", | ||
| "style": { | ||
| "elements": { | ||
| "link": { | ||
| "color": { | ||
| "text": "#ff0000" | ||
| } | ||
| } | ||
| }, | ||
| "color": { | ||
| "text": "#ff0000", | ||
| "background": "#00ffff" | ||
| }, | ||
| "typography": { | ||
| "fontSize": "30px" | ||
| }, | ||
| "spacing": { | ||
| "padding": { | ||
| "top": "1px", | ||
| "bottom": "1px", | ||
| "left": "2px", | ||
| "right": "2px" | ||
| }, | ||
| "margin": { | ||
| "top": "3px", | ||
| "bottom": "3px", | ||
| "left": "4px", | ||
| "right": "4px" | ||
| } | ||
| } | ||
| } | ||
| }, | ||
| "innerBlocks": [], | ||
| "innerHTML": "\n<form id=\"anchor\" class=\"wp-block-form\" style=\"color:#ff0000;background-color:#00ffff;margin-top:3px;margin-right:4px;margin-bottom:3px;margin-left:4px;padding-top:1px;padding-right:2px;padding-bottom:1px;padding-left:2px;font-size:30px\" enctype=\"text/plain\"></form>\n", | ||
| "innerContent": [ | ||
| "\n<form id=\"anchor\" class=\"wp-block-form\" style=\"color:#ff0000;background-color:#00ffff;margin-top:3px;margin-right:4px;margin-bottom:3px;margin-left:4px;padding-top:1px;padding-right:2px;padding-bottom:1px;padding-left:2px;font-size:30px\" enctype=\"text/plain\"></form>\n" | ||
| ] | ||
| }, | ||
| { | ||
| "blockName": null, | ||
| "attrs": {}, | ||
| "innerBlocks": [], | ||
| "innerHTML": "\n\n", | ||
| "innerContent": [ "\n\n" ] | ||
| }, | ||
| { | ||
| "blockName": "core/form", | ||
| "attrs": { | ||
| "className": "custom-class", | ||
| "style": { | ||
| "elements": { | ||
| "link": { | ||
| "color": { | ||
| "text": "var:preset|color|contrast" | ||
| } | ||
| } | ||
| }, | ||
| "spacing": { | ||
| "padding": { | ||
| "top": "var:preset|spacing|40", | ||
| "bottom": "var:preset|spacing|40", | ||
| "left": "var:preset|spacing|40", | ||
| "right": "var:preset|spacing|40" | ||
| }, | ||
| "margin": { | ||
| "top": "var:preset|spacing|40", | ||
| "bottom": "var:preset|spacing|40", | ||
| "left": "var:preset|spacing|40", | ||
| "right": "var:preset|spacing|40" | ||
| } | ||
| } | ||
| }, | ||
| "backgroundColor": "accent-1", | ||
| "textColor": "contrast", | ||
| "fontSize": "x-large" | ||
| }, | ||
| "innerBlocks": [], | ||
| "innerHTML": "\n<form id=\"anchor\" class=\"wp-block-form\" style=\"margin-top:var(--wp--preset--spacing--40);margin-right:var(--wp--preset--spacing--40);margin-bottom:var(--wp--preset--spacing--40);margin-left:var(--wp--preset--spacing--40);padding-top:var(--wp--preset--spacing--40);padding-right:var(--wp--preset--spacing--40);padding-bottom:var(--wp--preset--spacing--40);padding-left:var(--wp--preset--spacing--40)\" enctype=\"text/plain\"></form>\n", | ||
| "innerContent": [ | ||
| "\n<form id=\"anchor\" class=\"wp-block-form\" style=\"margin-top:var(--wp--preset--spacing--40);margin-right:var(--wp--preset--spacing--40);margin-bottom:var(--wp--preset--spacing--40);margin-left:var(--wp--preset--spacing--40);padding-top:var(--wp--preset--spacing--40);padding-right:var(--wp--preset--spacing--40);padding-bottom:var(--wp--preset--spacing--40);padding-left:var(--wp--preset--spacing--40)\" enctype=\"text/plain\"></form>\n" | ||
| ] | ||
| } | ||
| ] |
7 changes: 7 additions & 0 deletions
7
test/integration/fixtures/blocks/core__form__deprecated-v1.serialized.html
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,7 @@ | ||
| <!-- wp:form {"style":{"elements":{"link":{"color":{"text":"#ff0000"}}},"color":{"text":"#ff0000","background":"#00ffff"},"typography":{"fontSize":"30px"},"spacing":{"padding":{"top":"1px","bottom":"1px","left":"2px","right":"2px"},"margin":{"top":"3px","bottom":"3px","left":"4px","right":"4px"}}}} --> | ||
| <form id="anchor" class="wp-block-form has-text-color has-background has-link-color" style="color:#ff0000;background-color:#00ffff;margin-top:3px;margin-right:4px;margin-bottom:3px;margin-left:4px;padding-top:1px;padding-right:2px;padding-bottom:1px;padding-left:2px;font-size:30px" enctype="text/plain"></form> | ||
| <!-- /wp:form --> | ||
|
|
||
| <!-- wp:form {"backgroundColor":"accent-1","textColor":"contrast","fontSize":"x-large","style":{"elements":{"link":{"color":{"text":"var:preset|color|contrast"}}},"spacing":{"padding":{"top":"var:preset|spacing|40","bottom":"var:preset|spacing|40","left":"var:preset|spacing|40","right":"var:preset|spacing|40"},"margin":{"top":"var:preset|spacing|40","bottom":"var:preset|spacing|40","left":"var:preset|spacing|40","right":"var:preset|spacing|40"}}}} --> | ||
| <form id="anchor" class="wp-block-form has-contrast-color has-accent-1-background-color has-text-color has-background has-link-color has-x-large-font-size" style="margin-top:var(--wp--preset--spacing--40);margin-right:var(--wp--preset--spacing--40);margin-bottom:var(--wp--preset--spacing--40);margin-left:var(--wp--preset--spacing--40);padding-top:var(--wp--preset--spacing--40);padding-right:var(--wp--preset--spacing--40);padding-bottom:var(--wp--preset--spacing--40);padding-left:var(--wp--preset--spacing--40)" enctype="text/plain"></form> | ||
| <!-- /wp:form --> |
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.
I have prepared two types of HTML: The first block has custom values, and the second block has preset values.
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 I prefer the approach other blocks have taken where individual use cases are split into separate fixtures. It makes what the fixture represents and what you're testing clearer.
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.
Updated: 8be747e