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

[RNMobile] Move MediaUploadPorgress to its own component folder #17392

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
1 change: 1 addition & 0 deletions packages/block-editor/src/components/index.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export {
} from './rich-text';
export { default as MediaPlaceholder } from './media-placeholder';
export { default as MediaUpload, MEDIA_TYPE_IMAGE, MEDIA_TYPE_VIDEO } from './media-upload';
export { default as MediaUploadProgress } from './media-upload-progress';
export { default as URLInput } from './url-input';
export { default as BlockInvalidWarning } from './block-list/block-invalid-warning';
export { default as Caption } from './caption';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,15 @@ import { View, Image } from 'react-native';
/**
* Internal dependencies
*/
import { calculatePreferedImageSize } from './utils';

function calculatePreferedImageSize( image, container ) {
const maxWidth = container.clientWidth;
const exceedMaxWidth = image.width > maxWidth;
const ratio = image.height / image.width;
const width = exceedMaxWidth ? maxWidth : image.width;
const height = exceedMaxWidth ? maxWidth * ratio : image.height;
return { width, height };
}

class ImageSize extends Component {
constructor() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.mediaUploadProgress {
flex: 1;
background-color: $gray-lighten-30;
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
MEDIA_UPLOAD_STATE_SUCCEEDED,
MEDIA_UPLOAD_STATE_FAILED,
MEDIA_UPLOAD_STATE_RESET,
} from '../media-upload-progress';
} from '../index';
koke marked this conversation as resolved.
Show resolved Hide resolved

jest.mock( 'react-native-gutenberg-bridge', () => {
const callUploadCallback = ( payload ) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/block-library/src/image/edit.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import {
Caption,
MediaPlaceholder,
MediaUpload,
MediaUploadProgress,
MEDIA_TYPE_IMAGE,
BlockControls,
InspectorControls,
Expand All @@ -38,7 +39,6 @@ import { doAction, hasAction } from '@wordpress/hooks';
* Internal dependencies
*/
import styles from './styles.scss';
import MediaUploadProgress from './media-upload-progress';
import SvgIcon from './icon';
import SvgIconRetry from './icon-retry';

Expand Down
5 changes: 0 additions & 5 deletions packages/block-library/src/image/styles.native.scss
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,6 @@
color: $alert-red;
}

.mediaUploadProgress {
flex: 1;
background-color: $gray-lighten-30;
}

.modalIcon {
width: 80px;
height: 80px;
Expand Down
2 changes: 1 addition & 1 deletion packages/block-library/src/video/edit.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import {
Caption,
MediaPlaceholder,
MediaUpload,
MediaUploadProgress,
MEDIA_TYPE_VIDEO,
BlockControls,
InspectorControls,
Expand All @@ -38,7 +39,6 @@ import { doAction, hasAction } from '@wordpress/hooks';
/**
* Internal dependencies
*/
import MediaUploadProgress from '../image/media-upload-progress';
import style from './style.scss';
import SvgIcon from './icon';
import SvgIconRetry from './icon-retry';
Expand Down