Skip to content
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
Prev Previous commit
Next Next commit
Use experimental version of PlainText in Shortcode block
  • Loading branch information
fluiddot committed May 19, 2022
commit 9df81c0d26e2776f0ab64d62949283193f3432b1
42 changes: 27 additions & 15 deletions packages/block-library/src/shortcode/edit.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,16 @@ export function ShortcodeEdit( props ) {
onFocus,
onBlur,
getStylesFromColorScheme,
blockWidth,
} = props;
const titleStyle = getStylesFromColorScheme(
styles.blockTitle,
styles.blockTitleDark
);
const shortcodeContainerStyle = getStylesFromColorScheme(
styles.blockShortcodeContainer,
styles.blockShortcodeContainerDark
);
const shortcodeStyle = getStylesFromColorScheme(
styles.blockShortcode,
styles.blockShortcodeDark
Expand All @@ -40,21 +45,28 @@ export function ShortcodeEdit( props ) {
return (
<View>
<Text style={ titleStyle }>{ __( 'Shortcode' ) }</Text>
<PlainText
value={ attributes.text }
style={ shortcodeStyle }
multiline={ true }
underlineColorAndroid="transparent"
onChange={ ( text ) => setAttributes( { text } ) }
placeholder={ __( 'Add a shortcode…' ) }
aria-label={ __( 'Shortcode' ) }
isSelected={ props.isSelected }
onFocus={ onFocus }
onBlur={ onBlur }
autoCorrect={ false }
autoComplete="off"
placeholderTextColor={ placeholderStyle.color }
/>
<View style={ shortcodeContainerStyle }>
<PlainText
__experimentalVersion={ 2 }
value={ attributes.text }
style={ shortcodeStyle }
onChange={ ( text ) => setAttributes( { text } ) }
placeholder={ __( 'Add a shortcode…' ) }
aria-label={ __( 'Shortcode' ) }
isSelected={ props.isSelected }
onFocus={ onFocus }
onBlur={ onBlur }
placeholderTextColor={ placeholderStyle.color }
maxWidth={
blockWidth -
styles.blockShortcodeContainer.paddingLeft +
styles.blockShortcodeContainer.paddingRight
}
// TODO: Add autocorrect and autocomplete options
// autoCorrect={ false }
// autoComplete="off"
/>
</View>
</View>
);
}
Expand Down
14 changes: 10 additions & 4 deletions packages/block-library/src/shortcode/style.native.scss
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,24 @@
color: $gray-50;
}

.blockShortcodeContainer {
padding: 12px;
border-radius: 4px;
background-color: $gray-light;
}

.blockShortcodeContainerDark {
background-color: $gray-100;
}

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

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

.placeholder {
Expand Down