Skip to content

Commit

Permalink
[RNMobile] Social Icons: Ensure inactive icons are visible with block…
Browse files Browse the repository at this point in the history
…-based themes (#55398)

Ensure inactive icons are visible with block-based themes.
  • Loading branch information
Siobhan Bamber authored Oct 25, 2023
1 parent 67bfa0a commit 377b81d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 35 deletions.
38 changes: 12 additions & 26 deletions packages/block-library/src/social-link/edit.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
ToolbarButton,
LinkSettingsNavigation,
} from '@wordpress/components';
import { compose, usePreferredColorSchemeStyle } from '@wordpress/compose';
import { compose } from '@wordpress/compose';
import { __, sprintf } from '@wordpress/i18n';
import { link, Icon } from '@wordpress/icons';
import { withSelect } from '@wordpress/data';
Expand All @@ -30,10 +30,6 @@ const DEFAULT_ACTIVE_ICON_STYLES = {
backgroundColor: '#f0f0f0',
color: '#444',
};
const DEFAULT_INACTIVE_ICON_STYLES = {
backgroundColor: '#0000003f',
color: '#fff',
};
const ANIMATION_DELAY = 300;
const ANIMATION_DURATION = 400;

Expand Down Expand Up @@ -66,12 +62,6 @@ const SocialLinkEdit = ( {
styles[ `wp-social-link-${ service }` ] ||
styles[ `wp-social-link` ] ||
DEFAULT_ACTIVE_ICON_STYLES;
const inactiveIcon =
usePreferredColorSchemeStyle(
styles.inactiveIcon,
styles.inactiveIconDark
) || DEFAULT_INACTIVE_ICON_STYLES;

const animatedValue = useRef( new Animated.Value( 0 ) ).current;

const IconComponent = getIconBySite( service )();
Expand All @@ -94,23 +84,13 @@ const SocialLinkEdit = ( {
}, [ url ] );

const interpolationColors = {
backgroundColor: animatedValue.interpolate( {
inputRange: [ 0, 1 ],
outputRange: [
inactiveIcon.backgroundColor,
activeIcon.backgroundColor,
],
} ),
color: animatedValue.interpolate( {
opacity: animatedValue.interpolate( {
inputRange: [ 0, 1 ],
outputRange: [ inactiveIcon.color, activeIcon.color ],
outputRange: [ 0.3, 1 ],
} ),
stroke: '',
};

const { backgroundColor, color, stroke } = hasUrl
? activeIcon
: interpolationColors;
const { opacity } = hasUrl ? activeIcon : interpolationColors;

function animateColors() {
Animated.sequence( [
Expand Down Expand Up @@ -200,12 +180,18 @@ const SocialLinkEdit = ( {
accessibilityHint={ accessibilityHint }
>
<Animated.View
style={ [ styles.iconContainer, { backgroundColor } ] }
style={ [
styles.iconContainer,
{
backgroundColor: activeIcon.backgroundColor,
opacity,
},
] }
>
<Icon
animated
icon={ IconComponent }
style={ { stroke, color } }
style={ { color: activeIcon.color } }
/>
</Animated.View>
</TouchableWithoutFeedback>
Expand Down
9 changes: 0 additions & 9 deletions packages/block-library/src/social-link/editor.native.scss
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,6 @@
justify-content: center;
}

.inactiveIcon {
background-color: $light-quaternary;
color: $white;
}

.inactiveIconDark {
background-color: $dark-quaternary;
}

.container {
margin: $block-selected-margin;
}
1 change: 1 addition & 0 deletions packages/react-native-editor/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ For each user feature we should also add a importance categorization label to i
-->

## Unreleased
- [*] Social Icons: Fix visibility of inactive icons when used with block based themes in dark mode [#55398]
- [*] Synced Patterns: Fix visibility of heading section when used with block based themes in dark mode [#55399]
- [*] Classic block: Add option to convert to blocks [#55461]

Expand Down

1 comment on commit 377b81d

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flaky tests detected in 377b81d.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/6639350658
📝 Reported issues:

Please sign in to comment.