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 all 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
19 changes: 9 additions & 10 deletions packages/block-library/src/image/edit.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,19 +196,13 @@ export default class ImageEdit extends React.Component {
isVisible={ this.state.showSettings }
onClose={ onImageSettingsClose }
hideHeader
rightButton={
<BottomSheet.Button
text={ __( 'Done' ) }
color={ '#0087be' }
onPress={ onImageSettingsClose }
/>
}
>
<BottomSheet.Cell
icon={ 'editor-textcolor' }
label={ __( 'Alt Text' ) }
value={ __( 'None' ) }
onPress={ () => {} }
value={ alt || '' }
valuePlaceholder={ __( 'None' ) }
onChangeValue={ this.updateAlt }
/>
<BottomSheet.Cell
label={ __( 'Reset to original' ) }
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;
35 changes: 29 additions & 6 deletions packages/editor/src/components/mobile/bottom-sheet/cell.native.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* External dependencies
*/
import { TouchableOpacity, Text, View } from 'react-native';
import { TouchableOpacity, Text, View, TextInput } from 'react-native';

/**
* WordPress dependencies
Expand All @@ -18,16 +18,29 @@ export default function Cell( props ) {
onPress,
label,
value,
valuePlaceholder = '',
drawSeparator = true,
icon,
labelStyle = {},
valueStyle = {},
onChangeValue,
} = props;

const defaultLabelStyle = value ? styles.cellLabel : styles.cellLabelCentered;
const showValue = value !== undefined;
const isValueEditable = onChangeValue !== undefined;
const defaultLabelStyle = showValue ? styles.cellLabel : styles.cellLabelCentered;
let valueTextInput;

const onCellPress = () => {
if ( isValueEditable ) {
valueTextInput.focus();
} else {
onPress();
}
};

return (
<TouchableOpacity onPress={ onPress }>
<TouchableOpacity onPress={ onCellPress }>
<View style={ styles.cellContainer }>
<View style={ styles.cellRowContainer }>
{ icon && (
Expand All @@ -36,10 +49,20 @@ export default function Cell( props ) {
<View style={ { width: 12 } } />
</View>
) }
<Text style={ { ...defaultLabelStyle, ...labelStyle } }>{ label }</Text>
<Text numberOfLines={ 1 } style={ { ...defaultLabelStyle, ...labelStyle } }>
{ label }
</Text>
</View>
{ value && (
<Text style={ { ...styles.cellValue, ...valueStyle } }>{ value }</Text>
{ showValue && (
<TextInput
ref={ ( c ) => valueTextInput = c }
numberOfLines={ 1 }
style={ { ...styles.cellValue, ...valueStyle } }
value={ value }
placeholder={ valuePlaceholder }
onChangeText={ onChangeValue }
editable={ isValueEditable }
/>
) }
</View>
{ drawSeparator && (
Expand Down
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 } />
{ hideHeader || (
<View>
Expand All @@ -78,12 +81,12 @@ class BottomSheet extends Component {
<View style={ styles.separator } />
</View>
) }

{ 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 @@ -65,8 +65,8 @@
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;
}

Expand All @@ -82,6 +82,7 @@
.cellLabel {
font-size: 18px;
color: #000;
margin-right: 12px;
}

.cellLabelCentered {
Expand All @@ -94,4 +95,5 @@
.cellValue {
font-size: 18px;
color: $dark-gray-400;
text-align: right;
}