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

Alt image setting #13631

Merged
merged 29 commits into from
Feb 4, 2019
Merged
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
fd7c7eb
rnmobile: Implement image settings button using InspectorControls.Slo…
etoledom Jan 30, 2019
abdfd03
rnmobile: Add missing semicolon
etoledom Jan 30, 2019
1a4e35a
rnmobile: Adding bottom-sheet component to mobile
etoledom Jan 30, 2019
4352c7a
rnmobile: Styling bottom-sheet header
etoledom Jan 30, 2019
f132158
rnmobile: Bottom-sheet clean up
etoledom Jan 30, 2019
7bd8a4f
rnmobile: Fix lint issues on bottom-sheet related code.
etoledom Jan 30, 2019
541db3b
rnmobile: Fix small lint issues
etoledom Jan 31, 2019
b8e5dcf
rnmobile: Move inline toolbar button definition out of constant.
etoledom Jan 31, 2019
92e5357
rnmobile: Remove extra white-spaces
etoledom Jan 31, 2019
b7236e0
revert package-lock.json changes
etoledom Jan 31, 2019
4828348
Merge branch 'master' into rnmobile/bottom-sheet-component
etoledom Jan 31, 2019
09582b7
rnmobile: Fix merge issue
etoledom Jan 31, 2019
a1db59a
rnmobile: Imported BaseControl and TextinputControl to be used on Alt…
etoledom Jan 31, 2019
d335a84
rnmobile: exporting component BottomSheet.Button to be used as bottom…
etoledom Jan 31, 2019
67c2ffc
rnmobile: Adding BottomSheet.Cell component as an extraction for Bott…
etoledom Jan 31, 2019
edcd79b
Fix lint issues
etoledom Jan 31, 2019
fc1043a
Reverting changes to package-lock.json
etoledom Jan 31, 2019
bfd5832
Merge branch 'master' into rnmobile/bottom-sheet-component
etoledom Jan 31, 2019
4d7a80c
Fix merge issues
etoledom Jan 31, 2019
05fee0c
Merge branch 'rnmobile/bottom-sheet-component' into rnmobile/alt-imag…
etoledom Jan 31, 2019
887fc58
Remove Done button from Image settings bottom sheet
etoledom Jan 31, 2019
a126776
Make bottom-sheet avoid being behind keyboard
etoledom Jan 31, 2019
feab6e0
Merge branch 'master' into rnmobile/alt-image-setting
etoledom Feb 1, 2019
30ed40c
Fix lint issues
etoledom Feb 1, 2019
1e45675
Merge branch 'master' into rnmobile/alt-image-setting
etoledom Feb 1, 2019
5c6cd81
Making BottomSheet.Cell value editable as textinput.
etoledom Feb 1, 2019
a3f44ba
Remove unnecesary onPress prop from Alt cell.
etoledom Feb 1, 2019
7e391ba
Fix lint issues
etoledom Feb 4, 2019
6d60a5f
Merge branch 'master' into rnmobile/alt-image-setting
etoledom Feb 4, 2019
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
24 changes: 14 additions & 10 deletions packages/block-library/src/image/edit.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
* Internal dependencies
*/
import { MediaPlaceholder, RichText, BlockControls, InspectorControls, BottomSheet } from '@wordpress/editor';
import { Toolbar, ToolbarButton, Spinner, Dashicon } from '@wordpress/components';
import { Toolbar, ToolbarButton, Spinner, Dashicon, TextareaControl } from '@wordpress/components';
import { __ } from '@wordpress/i18n';
import ImageSize from './image-size';
import { isURL } from '@wordpress/url';
Expand All @@ -44,6 +44,7 @@ export default class ImageEdit extends React.Component {
this.removeMediaUploadListener = this.removeMediaUploadListener.bind( this );
this.finishMediaUploadWithSuccess = this.finishMediaUploadWithSuccess.bind( this );
this.finishMediaUploadWithFailure = this.finishMediaUploadWithFailure.bind( this );
this.updateAlt = this.updateAlt.bind( this );
this.onImagePressed = this.onImagePressed.bind( this );
}

Expand Down Expand Up @@ -128,9 +129,13 @@ export default class ImageEdit extends React.Component {
}
}

updateAlt( newAlt ) {
this.props.setAttributes( { alt: newAlt } );
}

render() {
const { attributes, isSelected, setAttributes } = this.props;
const { url, caption, height, width } = attributes;
const { url, caption, height, width, alt } = attributes;

const onMediaLibraryButtonPressed = () => {
requestMediaPickFromMediaLibrary( ( mediaId, mediaUrl ) => {
Expand Down Expand Up @@ -191,15 +196,14 @@ export default class ImageEdit extends React.Component {
isVisible={ this.state.showSettings }
title={ __( 'Image Settings' ) }
onClose={ onImageSettingsClose }
rightButton={
<BottomSheet.Button
text={ __( 'Done' ) }
color={ '#0087be' }
onPress={ onImageSettingsClose }
/>
}
>
<BottomSheet.Cell label={ __( 'Alt Text' ) } value={ __( 'None' ) } onPress={ () => {} } />
<BottomSheet.Cell label={ __( 'Alt Text' ) } value={ alt || __( 'None' ) } onPress={ () => {} } />
<TextareaControl
label={ __( 'Alt Text (Alternative Text)' ) }
value={ alt }
onChange={ this.updateAlt }
help={ __( 'Alternative text describes your image to people who can’t see it. Add a short description with its key details.' ) }
/>
</BottomSheet>
);

Expand Down
17 changes: 17 additions & 0 deletions packages/components/src/base-control/index.native.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/**
* External dependencies
*/
import { Text, View } from 'react-native';

export default function BaseControl( { label, help, children } ) {
return (
<View
accessible={ true }
accessibilityLabel={ label }
>
{ label && <Text>{ label }</Text> }
{ children }
{ help && <Text>{ help }</Text> }
</View>
);
}
2 changes: 2 additions & 0 deletions packages/components/src/index.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ export { default as withSpokenMessages } from './higher-order/with-spoken-messag
export { default as IconButton } from './icon-button';
export { default as Spinner } from './spinner';
export { createSlotFill, Slot, Fill, Provider as SlotFillProvider } from './slot-fill';
export { default as BaseControl } from './base-control';
export { default as TextareaControl } from './textarea-control';

// Higher-Order Components
export { default as withFilters } from './higher-order/with-filters';
Expand Down
26 changes: 26 additions & 0 deletions packages/components/src/textarea-control/index.native.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/**
* External dependencies
*/
import { TextInput } from 'react-native';

/**
* Internal dependencies
*/
import BaseControl from '../base-control';

function TextareaControl( { label, value, help, onChange, rows = 4 } ) {
return (
<BaseControl label={ label } help={ help } >
<TextInput
style={ { height: 80, borderColor: 'gray', borderWidth: 1 } }
value={ value }
onChangeText={ onChange }
numberOfLines={ rows }
multiline={ rows > 1 }
textAlignVertical="top"
/>
</BaseControl>
);
}

export default TextareaControl;
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ export default function Cell( props ) {

return (
<TouchableOpacity style={ styles.cellContainer } onPress={ onPress }>
<Text style={ styles.cellLabel }>{ label }</Text>
<Text style={ styles.cellValue }>{ value }</Text>
<Text numberOfLines={ 1 } style={ styles.cellLabel }>{ label }</Text>
<Text numberOfLines={ 1 } ellipsizeMode={ 'middle' } style={ styles.cellValue }>{ value }</Text>
</TouchableOpacity>
);
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* External dependencies
*/
import { Text, View } from 'react-native';
import { Text, View, KeyboardAvoidingView, Platform } from 'react-native';
import Modal from 'react-native-modal';
import SafeArea from 'react-native-safe-area';

Expand Down Expand Up @@ -58,7 +58,10 @@ class BottomSheet extends Component {
onSwipe={ this.props.onClose }
swipeDirection="down"
>
<View style={ { ...styles.content, borderColor: 'rgba(0, 0, 0, 0.1)' } }>
<KeyboardAvoidingView
behavior={ Platform.OS === 'ios' && 'padding' }
style={ { ...styles.content, borderColor: 'rgba(0, 0, 0, 0.1)' } }
>
<View style={ styles.dragIndicator } />
<View style={ styles.head }>
<View style={ { flex: 1 } }>
Expand All @@ -78,8 +81,9 @@ class BottomSheet extends Component {
{ this.props.children }
<View style={ { flexGrow: 1 } }></View>
<View style={ { height: this.state.safeAreaBottomInset } } />
</View>
</KeyboardAvoidingView>
</Modal>

);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,15 @@
flex-direction: row;
min-height: 50;
justify-content: space-between;
padding-left: 12;
padding-right: 12;
margin-left: 12;
margin-right: 12;
align-items: center;
}

.cellLabel {
font-size: 18px;
color: #000;
margin-right: 12px;
}

.cellValue {
Expand Down