-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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] Update Editor block inserter button styles and default text input placeholder/selection styles #52269
Changes from 5 commits
586c241
bff8162
76f065e
f751610
cb2b361
94701c8
85c9f6e
ea5e1d4
bcef9ac
14d5695
ba326e0
c641dc1
6ed81c7
3b4c5c2
9ca90ad
df3a2f7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,11 @@ import { | |
findTransform, | ||
isUnmodifiedDefaultBlock, | ||
} from '@wordpress/blocks'; | ||
import { useInstanceId, useMergeRefs } from '@wordpress/compose'; | ||
import { | ||
useInstanceId, | ||
useMergeRefs, | ||
usePreferredColorSchemeStyle, | ||
} from '@wordpress/compose'; | ||
import { | ||
__experimentalRichText as RichText, | ||
__unstableCreateElement, | ||
|
@@ -203,6 +207,11 @@ function RichTextWrapper( | |
); | ||
} | ||
|
||
const defaultSelectionColor = usePreferredColorSchemeStyle( | ||
'black', | ||
'white' | ||
); | ||
|
||
const onSelectionChange = useCallback( | ||
( selectionChangeStart, selectionChangeEnd ) => { | ||
selectionChange( | ||
|
@@ -619,7 +628,9 @@ function RichTextWrapper( | |
deleteEnter={ deleteEnter } | ||
placeholderTextColor={ placeholderTextColor } | ||
textAlign={ textAlign } | ||
selectionColor={ selectionColor } | ||
selectionColor={ | ||
selectionColor ? selectionColor : defaultSelectionColor | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @geriux I was trying to make updating the cursor/caret/selection color as simple and non-disruptive as possible. Since There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This approach sounds good to me, having a default value in case it is not set, just a few cases would set a custom I've moved this logic to the RichText component though so that it would work for other cases like the PostTitle component. I also added a case to take into account block-based theme colors and color contrast detection, since I've encountered issues in light/dark mode using different block-based themes. These changes were applied in 14d5695 |
||
tagsToEliminate={ tagsToEliminate } | ||
disableEditingMenu={ disableEditingMenu } | ||
fontSize={ fontSize } | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,8 +43,14 @@ function HeaderToolbar( { | |
noContentSelected, | ||
} ) { | ||
const wasNoContentSelected = useRef( noContentSelected ); | ||
// eslint-disable-next-line no-unused-vars | ||
const [ isInserterOpen, setIsInserterOpen ] = useState( false ); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Although There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've removed this code in 3b4c5c2 👍 |
||
|
||
const containerStyle = getStylesFromColorScheme( | ||
styles[ 'header-toolbar__container' ], | ||
styles[ 'header-toolbar__container--dark' ] | ||
); | ||
|
||
const scrollViewRef = useRef( null ); | ||
const scrollToStart = () => { | ||
// scrollview doesn't seem to automatically adjust to RTL on Android so, scroll to end when Android | ||
|
@@ -93,27 +99,14 @@ function HeaderToolbar( { | |
[ noContentSelected ] | ||
); | ||
|
||
// Expanded mode should be preserved while the inserter is open. | ||
// This way we prevent style updates during the opening transition. | ||
const useExpandedMode = isInserterOpen | ||
? wasNoContentSelected.current | ||
: noContentSelected; | ||
|
||
/* translators: accessibility text for the editor toolbar */ | ||
const toolbarAriaLabel = __( 'Document tools' ); | ||
|
||
return ( | ||
<View | ||
testID={ toolbarAriaLabel } | ||
accessibilityLabel={ toolbarAriaLabel } | ||
style={ [ | ||
getStylesFromColorScheme( | ||
styles[ 'header-toolbar__container' ], | ||
styles[ 'header-toolbar__container--dark' ] | ||
), | ||
useExpandedMode && | ||
styles[ 'header-toolbar__container--expanded' ], | ||
] } | ||
style={ containerStyle } | ||
> | ||
<ScrollView | ||
ref={ scrollViewRef } | ||
|
@@ -128,7 +121,6 @@ function HeaderToolbar( { | |
> | ||
<Inserter | ||
disabled={ ! showInserter } | ||
useExpandedMode={ useExpandedMode } | ||
onToggle={ onToggleInserter } | ||
/> | ||
{ renderHistoryButtons() } | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,7 +12,7 @@ | |
} | ||
|
||
.richTextPlaceholder { | ||
color: $gray; | ||
color: $gray-20; | ||
} | ||
|
||
.richTextPlaceholderDark { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By testing it a bit, I think we should add some
hitSlop
to this button, currently, this is not implemented but it should be easy to do and it will improve the UX of tapping on this button. What do you think?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea, updated.