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

Mobile Stories block (part 5): add empty placeholder #17539

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
7022a2d
Revert "Revert "added new component StoryUpdateProgress", not belongi…
mzorz Sep 21, 2020
af32096
added mediaSave statuses listeners definitions
mzorz Sep 24, 2020
eb6908f
moved StoryEdit to a React.Component class and implemented StoryUpdat…
mzorz Sep 25, 2020
f3b6316
added onStorySaveResult handling to Story block
mzorz Sep 25, 2020
d4d4f91
edit mode: replacing urls by id for saving process
mzorz Sep 28, 2020
cd93dd8
added onMediaModelCreated() callback so we can re-assign the mediaID …
mzorz Sep 28, 2020
6b0addc
update the mediaFile id and URL of a given story frame when finished …
mzorz Sep 29, 2020
92d04e1
removed commented imports
mzorz Sep 29, 2020
a0d35ff
added explicit TODO comments to make sure to follow up on them for er…
mzorz Sep 30, 2020
3f9c638
make sure to call mediaUploadSync and storySaveSync if any of the med…
mzorz Oct 1, 2020
645fa9c
fixed merge conflict
mzorz Oct 1, 2020
5e255c4
Merge branch 'try/jetpack-stories-block-mobile' into try/jetpack-stor…
mzorz Oct 9, 2020
e9e6757
using BlockMediaUpdateProgress
mzorz Oct 10, 2020
b30589f
method rename
mzorz Oct 10, 2020
766ce49
updated story block to represent error state
mzorz Oct 11, 2020
5b613c0
added cancel and retry bridge methods specific for mediaFiles collect…
mzorz Oct 12, 2020
333b06f
using a deep copy of mediaFiles when replacing ids and mediaUrl, give…
mzorz Oct 12, 2020
15fe14e
added requestMediaFilesSaveCancelDialog bridge method
mzorz Oct 12, 2020
f30449c
changed props name onMediaModelCreated to more generic onMediaIdChanged
mzorz Oct 13, 2020
51134e4
removed commented code
mzorz Oct 14, 2020
caea14f
fixed merge conflicts
mzorz Oct 16, 2020
de87b01
added MediaPlaceholder, wrapped in a pointerEvents=none View so we ca…
mzorz Oct 20, 2020
b885029
replaced for loops with map
mzorz Oct 20, 2020
aec512f
Merge branch 'try/jetpack-stories-block-error-handling' into try/jetp…
mzorz Oct 20, 2020
8b7ab6d
fixed merge conflict
mzorz Oct 23, 2020
deb66b9
importing defined const MEDIA_TYPE_IMAGE, MEDIA_TYPE_VIDEO instead of…
mzorz Oct 27, 2020
fc24451
made placeholder container look as per any other media placeholder, r…
mzorz Oct 27, 2020
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
35 changes: 27 additions & 8 deletions extensions/blocks/story/edit.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,13 @@ import { Text, View, TouchableWithoutFeedback } from 'react-native';
* WordPress dependencies
*/
import { Image } from '@wordpress/components';
import { BlockMediaUpdateProgress } from '@wordpress/block-editor';
import {
BlockIcon,
MediaPlaceholder,
BlockMediaUpdateProgress,
MEDIA_TYPE_IMAGE,
MEDIA_TYPE_VIDEO,
} from '@wordpress/block-editor';
import { __, sprintf } from '@wordpress/i18n';
import { getProtocol } from '@wordpress/url';
import { doAction, hasAction } from '@wordpress/hooks';
Expand All @@ -23,6 +29,7 @@ import {
/**
* Internal dependencies
*/
import { icon } from '.';
import styles from './editor.scss';
import StoryEditingButton from './story-editing-button';

Expand Down Expand Up @@ -227,20 +234,32 @@ class StoryEdit extends React.Component {
const hasContent = !! mediaFiles.length;
const { isUploadInProgress, isSaveInProgress, didUploadFail, didSaveFail } = this.state;

const mediaPlaceholder = (
// TODO this we are wrapping in a pointerEvents=none because we don't want to
// trigger the ADD MEDIA bottom sheet just yet, but only give the placedholder the right appearance.
<View pointerEvents="none" style={ styles[ 'content-placeholder' ] }>
<MediaPlaceholder
icon={ <BlockIcon icon={ icon } /> }
labels={ {
title: __( 'Story' ),
instructions: __( 'ADD MEDIA' ),
} }
allowedTypes={ [ MEDIA_TYPE_IMAGE, MEDIA_TYPE_VIDEO ] }
onFocus={ this.props.onFocus }
/>
</View>
);

return (
<TouchableWithoutFeedback
accessible={ ! isSelected }
onPress={ this.onStoryPressed }
disabled={ ! isSelected }
>
<View style={ styles[ 'wp-story-container' ] }>
{ ! hasContent && (
<Text style={ styles[ 'wp-story-wrapper' ] }>
This Story is empty. Tap to add media.
</Text>
) }
<View style={ styles[ 'content-placeholder' ] }>
{ ! hasContent && mediaPlaceholder }
{ hasContent && (
<View style={ { flex: 1 } }>
<View style={ styles[ 'wp-story-container' ] }>
{ ! isUploadInProgress && ! isSaveInProgress && isSelected && (
<StoryEditingButton onEditButtonTapped={ this.onEditButtonTapped } />
) }
Expand Down
4 changes: 4 additions & 0 deletions extensions/blocks/story/editor.native.scss
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,7 @@
top: 7px;
left: 7px;
}

.content-placeholder {
flex: 1;
}