-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[RNMobile] Add OfflineStatus component (#56934)
* feat: Frame useNetInfo hook foundation This code is non-functioning currently. * feat: Add iOS connection status bridge utilities This bridge will be required for the planned JavaScript Hook to monitor connection status. * feat: Add `useIsConnected` hook Provides React Hook for monitoring the network connection status via the bridge to the host app. * Revert "feat: Frame useNetInfo hook foundation" This reverts commit a8d3660. * refactor: Align with project Swift syntax Semicolon is unnecessary. Co-authored-by: Tanner Stokes <[email protected]> * feat: Add Android connection status bridge utilities This bridge enables monitoring the connection status on Android. * feat: Android network connection status request utility Allow the Android platform to request the current network connection status. * fix: Add missing `requestConnectionStatus` bridge method mock The Demo editor fails to build without a mocked bridge method. * Add mobile OfflineStatus component * Add OfflineStatus component to block-list behind __DEV__ flag * Replace offline icon and update OfflineStatus text alignment * Update BEM syntax for OfflineStatus * Update OfflineStatus component colors * test: Import sole native stylesheet to fix test module resolution error The current Jest module resolution configuration will fail when there is only a native-specific file without a web-specific file, e.g. only a `style.native.scss` and no sibling `style.scss` next to it. Explicitly importing the native-specific file avoids the error as Jest does not attempt to seek the non-suffixed file. * test: Mock `useIsConnected` native bridge method The native implementation is not available within the JavaScript testing environment. --------- Co-authored-by: David Calhoun <[email protected]> Co-authored-by: Tanner Stokes <[email protected]>
- Loading branch information
1 parent
80281d1
commit 57052f3
Showing
6 changed files
with
103 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
packages/block-editor/src/components/offline-status/index.native.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import { Text, View } from 'react-native'; | ||
|
||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { usePreferredColorSchemeStyle } from '@wordpress/compose'; | ||
import { Icon } from '@wordpress/components'; | ||
import { offline as offlineIcon } from '@wordpress/icons'; | ||
import { __ } from '@wordpress/i18n'; | ||
import { useIsConnected } from '@wordpress/react-native-bridge'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import styles from './style.native.scss'; | ||
|
||
const OfflineStatus = () => { | ||
const { isConnected } = useIsConnected(); | ||
|
||
const containerStyle = usePreferredColorSchemeStyle( | ||
styles.offline, | ||
styles.offline__dark | ||
); | ||
|
||
const textStyle = usePreferredColorSchemeStyle( | ||
styles[ 'offline--text' ], | ||
styles[ 'offline--text__dark' ] | ||
); | ||
|
||
const iconStyle = usePreferredColorSchemeStyle( | ||
styles[ 'offline--icon' ], | ||
styles[ 'offline--icon__dark' ] | ||
); | ||
|
||
return ! isConnected ? ( | ||
<View style={ containerStyle }> | ||
<Icon fill={ iconStyle.fill } icon={ offlineIcon } /> | ||
<Text style={ textStyle }>{ __( 'Working Offline' ) }</Text> | ||
</View> | ||
) : null; | ||
}; | ||
|
||
export default OfflineStatus; |
28 changes: 28 additions & 0 deletions
28
packages/block-editor/src/components/offline-status/style.native.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
.offline { | ||
background-color: $gray-lighten-30; | ||
padding: $grid-unit; | ||
justify-content: center; | ||
align-items: center; | ||
flex-direction: row; | ||
} | ||
|
||
.offline__dark { | ||
background-color: $gray-70; | ||
} | ||
|
||
.offline--text { | ||
color: $black; | ||
padding-left: 3; | ||
} | ||
|
||
.offline--text__dark { | ||
color: $white; | ||
} | ||
|
||
.offline--icon { | ||
fill: $gray-70; | ||
} | ||
|
||
.offline--icon__dark { | ||
fill: $gray-10; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { SVG, Path } from '@wordpress/primitives'; | ||
|
||
const offline = ( | ||
<SVG | ||
width="16" | ||
height="16" | ||
viewBox="0 0 16 16" | ||
fill="none" | ||
xmlns="http://www.w3.org/2000/svg" | ||
> | ||
<Path | ||
fill-rule="evenodd" | ||
clip-rule="evenodd" | ||
d="M1.36605 2.81332L2.30144 1.87332L13.5592 13.1867L12.6239 14.1267L7.92702 9.40666C6.74618 9.41999 5.57861 9.87999 4.68302 10.78L3.35623 9.44665C4.19874 8.60665 5.2071 8.03999 6.2818 7.75332L4.7958 6.25999C3.78744 6.67332 2.84542 7.29332 2.02944 8.11332L0.702656 6.77999C1.512 5.97332 2.42085 5.33332 3.3894 4.84665L1.36605 2.81332ZM15.2973 6.77999L13.9705 8.11332C12.3054 6.43999 10.1096 5.61332 7.92039 5.62666L6.20883 3.90665C9.41303 3.34665 12.8229 4.29332 15.2973 6.77999ZM10.1759 7.89332C11.0781 8.21332 11.9273 8.72665 12.6438 9.44665L12.1794 9.90665L10.1759 7.89332ZM6.00981 12.1133L8 14.1133L9.99018 12.1133C8.89558 11.0067 7.11105 11.0067 6.00981 12.1133Z" | ||
/> | ||
</SVG> | ||
); | ||
|
||
export default offline; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57052f3
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.
Flaky tests detected in 57052f3.
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/7201469108
📝 Reported issues:
/test/e2e/specs/site-editor/navigation-editor.spec.js
/test/e2e/specs/site-editor/font-library.spec.js