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

Use div in text columns and create responsive grid. #3438

Merged
merged 2 commits into from
Jan 4, 2018
Merged
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
8 changes: 4 additions & 4 deletions blocks/library/text-columns/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ registerBlockType( 'core/text-columns', {
/>
</InspectorControls>
),
<section className={ `${ className } align${ width } columns-${ columns }` } key="block">
<div className={ `${ className } align${ width } columns-${ columns }` } key="block">
{ times( columns, ( index ) =>
<div className="wp-block-column" key={ `column-${ index }` }>
<Editable
Expand All @@ -102,20 +102,20 @@ registerBlockType( 'core/text-columns', {
/>
</div>
) }
</section>,
</div>,
];
},

save( { attributes } ) {
Copy link
Contributor

@youknowriad youknowriad Jan 4, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we change the save I guess we need a deprecated version here unless we're ok showing a warning for old text-columns blocks considering this block as not a block that is used that much? cc @jasmussen

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general I think all these sorts of semi-breaking changes we should make as fast as we can in this phase, and not worry too much. We have great tools to help users "fix" the blocks when they are updated, so I think we should just do it.

If we are going to do something different once nested blocks come into play, then we'd need to do further changes regardless.

const { width, content, columns } = attributes;
return (
<section className={ `align${ width } columns-${ columns }` }>
<div className={ `align${ width } columns-${ columns }` }>
{ times( columns, ( index ) =>
<div className="wp-block-column" key={ `column-${ index }` }>
<p>{ content && content[ index ].children }</p>
</div>
) }
</section>
</div>
);
},
} );
4 changes: 2 additions & 2 deletions blocks/test/fixtures/core__text-columns.html
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<!-- wp:core/text-columns {"width":"center"} -->
<section class="wp-block-text-columns aligncenter columns-2">
<div class="wp-block-text-columns aligncenter columns-2">
<div class="wp-block-column">
<p>One</p>
</div>
<div class="wp-block-column">
<p>Two</p>
</div>
</section>
</div>
<!-- /wp:core/text-columns -->
2 changes: 1 addition & 1 deletion blocks/test/fixtures/core__text-columns.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@
"columns": 2,
"width": "center"
},
"originalContent": "<section class=\"wp-block-text-columns aligncenter columns-2\">\n <div class=\"wp-block-column\">\n <p>One</p>\n </div>\n <div class=\"wp-block-column\">\n <p>Two</p>\n </div>\n</section>"
"originalContent": "<div class=\"wp-block-text-columns aligncenter columns-2\">\n <div class=\"wp-block-column\">\n <p>One</p>\n </div>\n <div class=\"wp-block-column\">\n <p>Two</p>\n </div>\n</div>"
}
]
2 changes: 1 addition & 1 deletion blocks/test/fixtures/core__text-columns.parsed.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"width": "center"
},
"innerBlocks": [],
"innerHTML": "\n<section class=\"wp-block-text-columns aligncenter columns-2\">\n <div class=\"wp-block-column\">\n <p>One</p>\n </div>\n <div class=\"wp-block-column\">\n <p>Two</p>\n </div>\n</section>\n"
"innerHTML": "\n<div class=\"wp-block-text-columns aligncenter columns-2\">\n <div class=\"wp-block-column\">\n <p>One</p>\n </div>\n <div class=\"wp-block-column\">\n <p>Two</p>\n </div>\n</div>\n"
},
{
"attrs": {},
Expand Down
4 changes: 2 additions & 2 deletions blocks/test/fixtures/core__text-columns.serialized.html
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<!-- wp:text-columns {"width":"center"} -->
<section class="wp-block-text-columns aligncenter columns-2">
<div class="wp-block-text-columns aligncenter columns-2">
<div class="wp-block-column">
<p>One</p>
</div>
<div class="wp-block-column">
<p>Two</p>
</div>
</section>
</div>
<!-- /wp:text-columns -->