Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
a64ecd8
Release script: Update react-native-editor version to 1.81.0
derekblank Aug 4, 2022
29d06a6
Release script: Update with changes from 'npm run core preios'
derekblank Aug 4, 2022
4d1ca7e
Release script: Update react-native-editor version to 1.81.1
dcalhoun Aug 24, 2022
78fc8f4
Release script: Update with changes from 'npm run core preios'
dcalhoun Aug 24, 2022
9edbebe
[Mobile] - Add BlockListCompact (#43431)
Aug 25, 2022
201e83a
[RNMobile] List block v2: Fix text color inconsistencies with list it…
derekblank Aug 19, 2022
f41577e
Mobile - Disable FastImage on Android (#43322)
Aug 18, 2022
a439a53
[Mobile] - Fix dynamic React Native version (#43058)
Aug 8, 2022
94b8447
[RNMobile] Use default placeholder text color for native List Item (#…
derekblank Aug 25, 2022
8599e8c
Mobile - Update CHANGELOG
Aug 25, 2022
10fef38
Release script: Update react-native-editor version to 1.82.0
SiobhyB Sep 1, 2022
4e2512c
Release script: Update with changes from 'npm run core preios'
SiobhyB Sep 1, 2022
60199dc
[RNMobile] Set tintColor for ActionSheetIOS (#42996)
SiobhyB Aug 8, 2022
7fe980b
Update picker's .scss to follow BEM convention (#43036)
SiobhyB Aug 22, 2022
5157b3d
Update CHANGELOG with 1.82.0 changes
SiobhyB Sep 1, 2022
570fd2d
Release script: Update react-native-editor version to 1.82.1
SiobhyB Sep 6, 2022
059e5c1
Release script: Update with changes from 'npm run core preios'
SiobhyB Sep 6, 2022
59dd5de
Mobile - List V2 - Prevent error when list is empty (#43861)
Sep 5, 2022
f761037
[Mobile] List V2 - Fixes split issues (#43949)
Sep 7, 2022
0ef2c30
Update CHANGELOG to include 1.82.1 changes
SiobhyB Sep 8, 2022
b32d772
Merge branch into trunk
SiobhyB Sep 8, 2022
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
[RNMobile] Use default placeholder text color for native List Item (#…
…43353)

* Use default placeholder text color for native List Item

* Move list item placeholder hex value to stylesheet

* Resolve test failure

* Add opacity to list block placeholder color styles

* Update List block v2 placholder currentTextColor

* Mobile - List Item - Check if currentTextColor is not undefined and moves opacity value into a const

* Mobile - List Item - Add optional chaining for style.color

Co-authored-by: Gerardo <[email protected]>
  • Loading branch information
derekblank and Gerardo authored Aug 25, 2022
commit 94b8447887f4dd7e3897baa9f849a1898877abb4
32 changes: 31 additions & 1 deletion packages/block-library/src/list-item/edit.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
store as blockEditorStore,
} from '@wordpress/block-editor';
import { __ } from '@wordpress/i18n';
import { usePreferredColorSchemeStyle } from '@wordpress/compose';
import { useSelect } from '@wordpress/data';
import { useState, useCallback } from '@wordpress/element';

Expand All @@ -26,6 +27,8 @@ import { IndentUI } from './edit.js';
import styles from './style.scss';
import ListStyleType from './list-style-type';

const OPACITY = '9e';

export default function ListItemEdit( {
attributes,
setAttributes,
Expand Down Expand Up @@ -84,11 +87,35 @@ export default function ListItemEdit( {
const blockProps = useBlockProps( {
...( hasInnerBlocks && styles[ 'wp-block-list-item__nested-blocks' ] ),
} );

const innerBlocksProps = useInnerBlocksProps( blockProps, {
allowedBlocks: [ 'core/list' ],
useCompactList: true,
} );

// Set default placeholder text color from light/dark scheme or base colors
const defaultPlaceholderFromScheme = usePreferredColorSchemeStyle(
styles[ 'wp-block-list-item__list-item-placeholder' ],
styles[ 'wp-block-list-item__list-item-placeholder--dark' ]
);

const currentTextColor = style?.color || style?.baseColors?.color?.text;

const defaultPlaceholderTextColor = currentTextColor
? currentTextColor
: defaultPlaceholderFromScheme?.color;

// Add hex opacity to default placeholder text color and style object
const defaultPlaceholderTextColorWithOpacity =
defaultPlaceholderTextColor + OPACITY;

const styleWithPlaceholderOpacity = {
...style,
...( style?.color && {
placeholderColor: style.color + OPACITY,
} ),
};

const onSplit = useSplit( clientId );
const onMerge = useMerge( clientId );
const onLayout = useCallback( ( { nativeEvent } ) => {
Expand Down Expand Up @@ -128,12 +155,15 @@ export default function ListItemEdit( {
}
value={ content }
placeholder={ placeholder || __( 'List' ) }
placeholderTextColor={
defaultPlaceholderTextColorWithOpacity
}
onSplit={ onSplit }
onMerge={ onMerge }
onReplace={ ( blocks, ...args ) => {
onReplace( convertToListItems( blocks ), ...args );
} }
style={ style }
style={ styleWithPlaceholderOpacity }
deleteEnter={ true }
containerWidth={ contentWidth }
/>
Expand Down
8 changes: 8 additions & 0 deletions packages/block-library/src/list-item/style.native.scss
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,11 @@
.wp-block-list-item__list-item-container {
margin-right: 8;
}

.wp-block-list-item__list-item-placeholder {
color: $gray;
}

.wp-block-list-item__list-item-placeholder--dark {
color: $gray-50;
}