Skip to content
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

List Block: Add custom spacing to the list block #27511

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,7 @@ These are the current color properties supported by blocks:
| --- | --- |
| Cover | Yes |
| Group | Yes |
| List | Yes |
| Verse | Yes |

#### Typography Properties
Expand Down
17 changes: 16 additions & 1 deletion packages/block-library/src/list/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,18 @@
},
"reversed": {
"type": "boolean"
},
"style": {
"default": {
"spacing": {
"padding": {
"top": 0,
"right": 0,
"bottom": 0,
"left": 40
}
}
}
}
},
"supports": {
Expand All @@ -32,6 +44,9 @@
"color": {
"gradients": true
},
"__unstablePasteTextInline": true
"__unstablePasteTextInline": true,
"spacing": {
"padding": true
}
}
}
3 changes: 1 addition & 2 deletions packages/components/src/box-control/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,9 @@ export default function BoxControl( {
} );
const inputValues = values || DEFAULT_VALUES;
const hasInitialValue = isValuesDefined( valuesProp );

const [ isDirty, setIsDirty ] = useState( hasInitialValue );
const [ isLinked, setIsLinked ] = useState(
! hasInitialValue || ! isValuesMixed( inputValues )
! hasInitialValue || ( ! isValuesMixed( inputValues ) && Object.keys(inputValues).length === 4 )
);

const [ side, setSide ] = useState( isLinked ? 'all' : 'top' );
Expand Down
2 changes: 1 addition & 1 deletion packages/e2e-tests/fixtures/blocks/core__list__ul.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<!-- wp:core/list -->
<ul><li>Text & Headings</li><li>Images & Videos</li><li>Galleries</li><li>Embeds, like YouTube, Tweets, or other WordPress posts.</li><li>Layout blocks, like Buttons, Hero Images, Separators, etc.</li><li>And <em>Lists</em> like this one of course :)</li></ul>
<ul style="padding-bottom:0;padding-left:40px;padding-right:0;padding-top:0"><li>Text & Headings</li><li>Images & Videos</li><li>Galleries</li><li>Embeds, like YouTube, Tweets, or other WordPress posts.</li><li>Layout blocks, like Buttons, Hero Images, Separators, etc.</li><li>And <em>Lists</em> like this one of course :)</li></ul>
<!-- /wp:core/list -->
14 changes: 12 additions & 2 deletions packages/e2e-tests/fixtures/blocks/core__list__ul.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,19 @@
"isValid": true,
"attributes": {
"ordered": false,
"values": "<li>Text &amp; Headings</li><li>Images &amp; Videos</li><li>Galleries</li><li>Embeds, like YouTube, Tweets, or other WordPress posts.</li><li>Layout blocks, like Buttons, Hero Images, Separators, etc.</li><li>And <em>Lists</em> like this one of course :)</li>"
"values": "<li>Text &amp; Headings</li><li>Images &amp; Videos</li><li>Galleries</li><li>Embeds, like YouTube, Tweets, or other WordPress posts.</li><li>Layout blocks, like Buttons, Hero Images, Separators, etc.</li><li>And <em>Lists</em> like this one of course :)</li>",
"style": {
"spacing": {
"padding": {
"top": 0,
"right": 0,
"bottom": 0,
"left": 40
}
}
}
},
"innerBlocks": [],
"originalContent": "<ul><li>Text & Headings</li><li>Images & Videos</li><li>Galleries</li><li>Embeds, like YouTube, Tweets, or other WordPress posts.</li><li>Layout blocks, like Buttons, Hero Images, Separators, etc.</li><li>And <em>Lists</em> like this one of course :)</li></ul>"
"originalContent": "<ul style=\"padding-bottom:0;padding-left:40px;padding-right:0;padding-top:0\"><li>Text & Headings</li><li>Images & Videos</li><li>Galleries</li><li>Embeds, like YouTube, Tweets, or other WordPress posts.</li><li>Layout blocks, like Buttons, Hero Images, Separators, etc.</li><li>And <em>Lists</em> like this one of course :)</li></ul>"
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
"blockName": "core/list",
"attrs": {},
"innerBlocks": [],
"innerHTML": "\n<ul><li>Text & Headings</li><li>Images & Videos</li><li>Galleries</li><li>Embeds, like YouTube, Tweets, or other WordPress posts.</li><li>Layout blocks, like Buttons, Hero Images, Separators, etc.</li><li>And <em>Lists</em> like this one of course :)</li></ul>\n",
"innerHTML": "\n<ul style=\"padding-bottom:0;padding-left:40px;padding-right:0;padding-top:0\"><li>Text & Headings</li><li>Images & Videos</li><li>Galleries</li><li>Embeds, like YouTube, Tweets, or other WordPress posts.</li><li>Layout blocks, like Buttons, Hero Images, Separators, etc.</li><li>And <em>Lists</em> like this one of course :)</li></ul>\n",
"innerContent": [
"\n<ul><li>Text & Headings</li><li>Images & Videos</li><li>Galleries</li><li>Embeds, like YouTube, Tweets, or other WordPress posts.</li><li>Layout blocks, like Buttons, Hero Images, Separators, etc.</li><li>And <em>Lists</em> like this one of course :)</li></ul>\n"
"\n<ul style=\"padding-bottom:0;padding-left:40px;padding-right:0;padding-top:0\"><li>Text & Headings</li><li>Images & Videos</li><li>Galleries</li><li>Embeds, like YouTube, Tweets, or other WordPress posts.</li><li>Layout blocks, like Buttons, Hero Images, Separators, etc.</li><li>And <em>Lists</em> like this one of course :)</li></ul>\n"
]
},
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<!-- wp:list -->
<ul><li>Text &amp; Headings</li><li>Images &amp; Videos</li><li>Galleries</li><li>Embeds, like YouTube, Tweets, or other WordPress posts.</li><li>Layout blocks, like Buttons, Hero Images, Separators, etc.</li><li>And <em>Lists</em> like this one of course :)</li></ul>
<ul style="padding-bottom:0;padding-left:40px;padding-right:0;padding-top:0"><li>Text &amp; Headings</li><li>Images &amp; Videos</li><li>Galleries</li><li>Embeds, like YouTube, Tweets, or other WordPress posts.</li><li>Layout blocks, like Buttons, Hero Images, Separators, etc.</li><li>And <em>Lists</em> like this one of course :)</li></ul>
<!-- /wp:list -->
1 change: 0 additions & 1 deletion packages/editor/src/editor-styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ p {
ul,
ol {
margin-bottom: $default-block-margin;
padding-left: 1.3em;
margin-left: 1.3em;

// Remove bottom margin from nested lists.
Expand Down