Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
260fc32
Add variatioation picker for when block is first added.
enejb Sep 4, 2020
1e3141d
Minor code cleanup
enejb Sep 4, 2020
987be10
Add Gutter Settings
enejb Sep 4, 2020
4f60830
Add Example controls that
enejb Mar 26, 2021
b8e942a
Update all the controls
enejb Apr 2, 2021
ff76727
Fix the InnerBlocks Appender logic
enejb Apr 2, 2021
810ea7d
Add background Colour settings.
enejb Apr 23, 2021
4b6a12c
Stash
enejb Apr 28, 2021
c11ebf1
Remove the background colour
enejb Apr 29, 2021
77c8557
Remove the column title
enejb Apr 29, 2021
6af5124
Add New variation control component.
enejb Apr 29, 2021
14b0f2c
Remove bottom sheet controls
enejb Apr 29, 2021
c972434
Convert grid column to functional component
enejb Apr 29, 2021
cbfb7c8
Removed un used import from grid column
enejb Apr 29, 2021
872491d
Convert to edit columns to functional component
enejb Apr 30, 2021
2698020
Refactor Variation Control so that we don't end up with a nested Bott…
enejb Apr 30, 2021
3368ba1
Use the new VariationControl
enejb Apr 30, 2021
22742d2
Add Placeholder Styles to Grid Column
enejb Apr 30, 2021
a3dee8c
Add padding settings
enejb Apr 30, 2021
949f23a
Fix bottom padding between the inserter and settings cog
enejb May 3, 2021
6188f5e
Fix the styles so that they don't produce an extra bottom space when …
enejb May 3, 2021
98d682d
Add comments about translations
enejb May 3, 2021
b579c3b
Fix comment strings
enejb May 3, 2021
0179a6d
Fix: Styling of the controls
enejb May 5, 2021
f37bdf3
Fixes for variation control, fix typo, fix memo
enejb May 5, 2021
b56a9af
Remove edit.native.scss file not needed
enejb May 5, 2021
b934d40
Refactor to use HOC
enejb May 5, 2021
a26c456
Add iPad columns
enejb May 7, 2021
77f9503
Update the size on grid column
enejb May 10, 2021
cf985cb
Fix typo
enejb May 10, 2021
bf0ac0a
Improve the appender styles
enejb May 10, 2021
b14290d
Remove not neede minus margin.
enejb May 10, 2021
9128940
Clarify the variable name
enejb May 10, 2021
b22e86b
Fine tune the spacing between settings and inserter
enejb May 10, 2021
e13809b
Fix styles when not in full width alignment
enejb May 10, 2021
99fc7f7
Minor fixes, remove unused dependencies
enejb May 10, 2021
fea7ca5
Minor fixes.
enejb May 12, 2021
a0bb417
Add Selected State to the Input Button
enejb May 12, 2021
cde6157
Use constants for getColmnStyles
enejb May 12, 2021
e5671d7
Code clean up
enejb May 12, 2021
2a19368
Minor refactor
enejb May 12, 2021
2261831
Code fixes.
enejb May 13, 2021
476b18c
Update checkmark icon.
enejb May 13, 2021
83897ad
Fix the iPhone Pro Landscape more.
enejb May 13, 2021
3ef4a45
Remove the circle checkmark
enejb May 14, 2021
831f521
Add notice
enejb May 14, 2021
d1fb1c5
Update the buttons so that 3.2 buttons show up now
enejb May 14, 2021
67f08f3
remove the side spacing.
enejb May 14, 2021
5e6919c
Icon: Add support for the size prop
enejb May 14, 2021
317aeac
Rename higher-order to hooks/with-update-alignment
enejb May 14, 2021
7af39b0
Remove package-lock.json
enejb May 14, 2021
34945d8
Fixes Android selected button.
enejb May 14, 2021
9244271
Fix 3 column layout grid on Desktop (Mobile App iPad horizontal)
enejb May 19, 2021
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
Next Next commit
Add variatioation picker for when block is first added.
  • Loading branch information
enejb authored and johngodley committed Jun 2, 2021
commit 260fc32cc30929888ed2b0df0ce2c8e4ee9454f5
44 changes: 32 additions & 12 deletions blocks/layout-grid/src/grid/edit.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,18 @@
* External dependencies
*/
import { View } from 'react-native';
import { delay, flatMap } from 'lodash';

/**
* WordPress dependencies
*/
import { InnerBlocks } from '@wordpress/block-editor';
import { Component } from '@wordpress/element';
import { InnerBlocks, BlockVariationPicker } from '@wordpress/block-editor';

import { useEffect, useState } from '@wordpress/element';
/**
* Internal dependencies
*/
import variations from './variations';

const ALLOWED_BLOCKS = [ 'jetpack/layout-grid-column' ];

Expand All @@ -16,20 +22,34 @@ const TEMPLATE = [
[ 'jetpack/layout-grid-column', {}, [] ],
];

class Edit extends Component {
constructor( props ) {
super( props );
}
const Edit = ( props ) => {
const { clientId, isSelected } = props;
const [ isVisible, setIsVisible ] = useState( false );
const isDefaultColumns = true;

useEffect( () => {
if ( isSelected && isDefaultColumns ) {
delay( () => setIsVisible( true ), 100 );
}
}, [] );

render() {
return <View>
return (
<>
<View>
<InnerBlocks
template={ TEMPLATE }
templateLock="all"
allowedBlocks={ ALLOWED_BLOCKS }
/>
</View>;
}
}
</View>
<BlockVariationPicker
variations={ variations }
onClose={ () => setIsVisible( false ) }
clientId={ clientId }
isVisible={ isVisible }
/>
</>
);
};

export default Edit;
export default Edit;
65 changes: 65 additions & 0 deletions blocks/layout-grid/src/grid/variations.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/**
* WordPress dependencies
*/
import { __ } from '@wordpress/i18n';

/** @typedef {import('@wordpress/blocks').WPBlockVariation} WPBlockVariation */

/**
* Internal dependencies
*/
import ColumnIcon from './../icons';
/**
* Template option choices for predefined columns layouts.
*
* @type {WPBlockVariation[]}
*/
const variations = [
{
name: 'one-column',
title: __( 'One' ),

Choose a reason for hiding this comment

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

I'm working on adding i18n support for the Layout Grid block and I bumped into a case where these strings One, Two, Three, and Four are being missed because they don't reference the layout-grid domain as the rest of strings.

Not sure if it's an issue because I couldn't find the translations on either of both GlotPress projects (Gutenberg / Layout Grid) or it's expected to use the default domain, @enejb I'd appreciate it if you could provide further insights regarding this, thanks!

Copy link
Member Author

Choose a reason for hiding this comment

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

I think for one reason or another I thought that in Gutenberg we had the values translated. So I left them as they were taking the value from core. Since we didn’t translate blocks that were not living outside of Gutenberg. (.
I used the columns block as an example for this code. ) Or it might have been a typo and I missed adding the domain part of the function.

Choose a reason for hiding this comment

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

Great, thank you very much for info 🙇 !

I think for one reason or another I thought that in Gutenberg we had the values translated. So I left them as they were taking the value from core.

Yep, I was also surprised that number strings like "One" / "Two" aren't translated in Gutenberg, however, I noticed that we actually have them but with a dot at the end (i.e. "One.") 😅 .

Since we didn’t translate blocks that were not living outside of Gutenberg. (.

This is part of the work I'm doing for the Translation Pipeline Improvement project, although for the strings that are used only in the native version of the editor, they are currently being translated as part of the WordPress app.

I used the columns block as an example for this code. ) Or it might have been a typo and I missed adding the domain part of the function.

Ok, it's still unclear to me whether to use a domain or not within plugins, per this documentation about plugin translations, I understand that it's recommended to use a domain but I guess it's ok to fall back to default (Gutenberg in this case) if we know that the string is present there.

In any case, with the work I'm doing for the pipeline improvements, these strings will be added to the localization strings files and translated as strings of the WordPress app (example reference).

description: __( 'One column', 'layout-grid' ),
icon: ( <ColumnIcon columns={ 1 } /> ),
isDefault: true,
innerBlocks: [ [ 'jetpack/layout-grid-column' ] ],
scope: [ 'block' ],
},
{
name: 'two-columns',
title: __( 'Two' ),
description: __( 'Two columns', 'layout-grid' ),
icon: ( <ColumnIcon columns={ 2 } /> ),
innerBlocks: [
[ 'jetpack/layout-grid-column' ],
[ 'jetpack/layout-grid-column' ],
],
scope: [ 'block' ],
},
{
name: 'three-columns',
title: __( 'Three' ),
description: __( 'Three columns', 'layout-grid' ),
icon: ( <ColumnIcon columns={ 3 } /> ),
innerBlocks: [
[ 'jetpack/layout-grid-column' ],
[ 'jetpack/layout-grid-column' ],
[ 'jetpack/layout-grid-column' ],
],
scope: [ 'block' ],
},
{
name: 'four-columns',
title: __( 'Four' ),
description: __( 'Four columns', 'layout-grid' ),
icon: ( <ColumnIcon columns={ 4 } /> ),
innerBlocks: [
[ 'jetpack/layout-grid-column' ],
[ 'jetpack/layout-grid-column' ],
[ 'jetpack/layout-grid-column' ],
[ 'jetpack/layout-grid-column' ],
],
scope: [ 'block' ],
},
];

export default variations;