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/368 improve code block #18785

Merged
merged 7 commits into from
Dec 2, 2019
Merged
Show file tree
Hide file tree
Changes from 5 commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,13 @@ export default class PlainText extends Component {
<TextInput
{ ...this.props }
ref={ ( x ) => this._input = x }
className={ [ styles[ 'block-editor-plain-text' ], this.props.className ] }
onChange={ ( event ) => {
this.props.onChange( event.nativeEvent.text );
} }
onFocus={ this.props.onFocus } // always assign onFocus as a props
onBlur={ this.props.onBlur } // always assign onBlur as a props
fontFamily={ this.props.fontFamily || ( styles[ 'block-editor-plain-text' ].fontFamily ) }
fontSize={ this.props.fontSize }
fontWeight={ this.props.fontWeight }
fontStyle={ this.props.fontStyle }
fontFamily={ ( this.props.style && this.props.style.fontFamily ) || ( styles[ 'block-editor-plain-text' ].fontFamily ) }
style={ this.props.style || styles[ 'block-editor-plain-text' ] }
/>
);
}
Expand Down
5 changes: 2 additions & 3 deletions packages/block-library/src/code/edit.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ import styles from './theme.scss';
// Note: styling is applied directly to the (nested) PlainText component. Web-side components
// apply it to the container 'div' but we don't have a proper proposal for cascading styling yet.
export function CodeEdit( props ) {
const { attributes, setAttributes, style, onFocus, onBlur, getStylesFromColorScheme } = props;
const { attributes, setAttributes, onFocus, onBlur, getStylesFromColorScheme } = props;
const codeStyle = getStylesFromColorScheme( styles.blockCode, styles.blockCodeDark );
const placeholderStyle = getStylesFromColorScheme( styles.placeholder, styles.placeholderDark );

return (
<View>
<PlainText
value={ attributes.content }
style={ [ style, codeStyle ] }
style={ codeStyle }
multiline={ true }
underlineColorAndroid="transparent"
onChange={ ( content ) => setAttributes( { content } ) }
Expand All @@ -39,7 +39,6 @@ export function CodeEdit( props ) {
isSelected={ props.isSelected }
onFocus={ onFocus }
onBlur={ onBlur }
fontFamily={ ( styles.blockCode.fontFamily ) }
placeholderTextColor={ placeholderStyle.color }
/>
</View>
Expand Down
5 changes: 5 additions & 0 deletions packages/block-library/src/code/theme.native.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,15 @@

.blockCode {
font-family: $default-monospace-font;
font-size: 14;
padding: 12px 16px;
border-radius: 4px;
background-color: $gray-light;
}

.blockCodeDark {
color: $white;
background-color: $gray-100;
}

.placeholder {
Expand Down