Skip to content

Commit 523166b

Browse files
committed
feat: add SafeAreaView and InputAccessoryView
1 parent c012923 commit 523166b

17 files changed

Lines changed: 330 additions & 32 deletions

File tree

‎docs/docs/expo.md‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,8 @@ Expo's libraries import `UIManager`, `NativeModules`, `LogBox`, `DeviceEventEmit
8181

8282
`@expo/html-elements` doesn't work with the package. It imports internal files of react-native-web's `View`, which the package doesn't have, so the bundle fails. Give `View` and `Text` a `role` instead: see [Semantic HTML](/semantic-html).
8383

84-
## Names that aren't there yet
84+
## Names that load as stubs
8585

86-
A name of `react-native` that `@rootnative/web` doesn't have yet loads as a stub. The import works, so a library that imports the name and doesn't use it still loads. A use throws an error that names it, such as `ImageBackground is not in @rootnative/web yet`.
86+
A name that Expo's bundler asks for and `@rootnative/web` doesn't have loads as a stub. The import works, so a library that imports the name and doesn't use it still loads. A use throws an error that names it, such as `Picker is not in @rootnative/web yet`.
8787

88-
The largest ones today are `SafeAreaView` and `InputAccessoryView`. The file `expo-exports.json` of the package lists all of them under `missing`: `node_modules/@rootnative/web-expo/expo-exports.json`, or `node_modules/react-native-web/expo-exports.json` with the alias.
88+
These names aren't in React Native 0.88: `CheckBox`, `Picker`, `ProgressBar`, and the others come from react-native-web, and React Native removed `InteractionManager`. The file `expo-exports.json` of the package lists all of them under `missing`: `node_modules/@rootnative/web-expo/expo-exports.json`, or `node_modules/react-native-web/expo-exports.json` with the alias.

‎docs/docs/inputaccessoryview.md‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
id: inputaccessoryview
3+
title: InputAccessoryView
4+
description: InputAccessoryView on the web. It renders nothing, as on Android.
5+
---
6+
7+
# `InputAccessoryView`
8+
9+
On iOS, a view that shows above the keyboard of a text field. React Native has it on iOS only. On the web, as on Android, it renders nothing, and in development the first render warns once: `<InputAccessoryView> is only supported on iOS.`
10+
11+
The import works, so code for iOS that renders it still runs on the web. For a bar above the keyboard on the web, put a view at the bottom of a [`KeyboardAvoidingView`](/keyboardavoidingview).

‎docs/docs/safeareaview.md‎

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
---
2+
id: safeareaview
3+
title: SafeAreaView
4+
description: SafeAreaView on the web. A View with padding from the safe-area insets of the browser. Deprecated, as in React Native.
5+
---
6+
7+
# `SafeAreaView`
8+
9+
:::warning Deprecated
10+
React Native deprecates `SafeAreaView`, and so does this package. Use `react-native-safe-area-context`, which works on the web too. In development, the first render warns once, as React Native does.
11+
:::
12+
13+
A [`View`](/view) with padding that keeps its content out of the notch and the home bar, as on iOS.
14+
15+
```tsx
16+
import { SafeAreaView, Text } from 'react-native'
17+
18+
export function Screen() {
19+
return (
20+
<SafeAreaView style={{ flex: 1 }}>
21+
<Text>Content</Text>
22+
</SafeAreaView>
23+
)
24+
}
25+
```
26+
27+
The padding is the safe-area inset of the browser on each side: `env(safe-area-inset-top)` and the others. A phone browser has insets only for a page with `viewport-fit=cover` in its viewport tag:
28+
29+
```html
30+
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover" />
31+
```
32+
33+
Without it, and on a desktop, the insets are 0, and the view is a plain `View`, as on Android.
34+
35+
- A padding in `style` wins: `paddingTop` replaces the top inset, and `padding` replaces all four.
36+
- The insets stay on their physical sides, also in a right-to-left layout.

‎docs/docs/status.md‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ The latest release is [`0.0.4`](https://www.npmjs.com/package/@rootnative/web) o
1212

1313
## What ships today
1414

15-
| Group | Exports |
16-
| ---------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
17-
| Components | [`View`](/view), [`Text`](/text), [`Image`](/image), [`ImageBackground`](/imagebackground), [`Pressable`](/pressable), [`TouchableHighlight`](/touchablehighlight), [`TouchableNativeFeedback`](/touchablenativefeedback), [`TouchableOpacity`](/touchableopacity), [`TouchableWithoutFeedback`](/touchablewithoutfeedback), [`Button`](/button), [`ScrollView`](/scrollview), [`FlatList`](/flatlist), [`VirtualizedList`](/virtualizedlist), [`SectionList`](/sectionlist), [`VirtualizedSectionList`](/sectionlist#virtualizedsectionlist), [`RefreshControl`](/refreshcontrol), [`TextInput`](/textinput), [`Switch`](/switch), [`ActivityIndicator`](/activityindicator), [`Modal`](/modal), [`KeyboardAvoidingView`](/keyboardavoidingview), [`StatusBar`](/statusbar) |
18-
| APIs | [`StyleSheet`](/stylesheet), [`Platform`](/platform), [`Dimensions`](/dimensions), [`useWindowDimensions`](/dimensions), [`Appearance`](/appearance), [`useColorScheme`](/appearance), [`AppState`](/appstate), [`Keyboard`](/keyboard), [`Linking`](/linking), [`Alert`](/alert), [`Share`](/share), [`Vibration`](/vibration), [`Clipboard`](/clipboard), [`AccessibilityInfo`](/accessibilityinfo), [`I18nManager`](/i18nmanager), [`BackHandler`](/backhandler), [`PixelRatio`](/pixelratio), [`processColor`](/processcolor), [`PanResponder`](/panresponder), [`Animated`](/animated), [`useAnimatedValue`](/animated), [`useAnimatedValueXY`](/animated), [`useAnimatedColor`](/animated), [`Easing`](/easing), [`LayoutAnimation`](/layoutanimation), [`usePressability`](/usepressability) |
19-
| Compat | [`unstable_createElement`](/compat), [`findNodeHandle`](/compat), [`TurboModuleRegistry`](/compat), and the entries `@rootnative/web/assets-registry` and `@rootnative/web/style`. Libraries import them, your app doesn't. Also the react-native-web props [`hrefAttrs` and `dataSet`](/compat#props-from-react-native-web), which libraries send. |
20-
| Web layer | [`Head`](/seo), from `@rootnative/web/dom` |
21-
| Tooling | [`rootnative()`](/vite-plugin), the Vite plugin, from `@rootnative/web/vite`, and [`@rootnative/web-expo`](/expo), for an Expo app, also with Expo Router |
15+
| Group | Exports |
16+
| ---------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
17+
| Components | [`View`](/view), [`Text`](/text), [`Image`](/image), [`ImageBackground`](/imagebackground), [`Pressable`](/pressable), [`TouchableHighlight`](/touchablehighlight), [`TouchableNativeFeedback`](/touchablenativefeedback), [`TouchableOpacity`](/touchableopacity), [`TouchableWithoutFeedback`](/touchablewithoutfeedback), [`Button`](/button), [`ScrollView`](/scrollview), [`FlatList`](/flatlist), [`VirtualizedList`](/virtualizedlist), [`SectionList`](/sectionlist), [`VirtualizedSectionList`](/sectionlist#virtualizedsectionlist), [`RefreshControl`](/refreshcontrol), [`TextInput`](/textinput), [`Switch`](/switch), [`ActivityIndicator`](/activityindicator), [`Modal`](/modal), [`KeyboardAvoidingView`](/keyboardavoidingview), [`SafeAreaView`](/safeareaview) (deprecated, as in React Native), [`InputAccessoryView`](/inputaccessoryview) (renders nothing, as on Android), [`StatusBar`](/statusbar) |
18+
| APIs | [`StyleSheet`](/stylesheet), [`Platform`](/platform), [`Dimensions`](/dimensions), [`useWindowDimensions`](/dimensions), [`Appearance`](/appearance), [`useColorScheme`](/appearance), [`AppState`](/appstate), [`Keyboard`](/keyboard), [`Linking`](/linking), [`Alert`](/alert), [`Share`](/share), [`Vibration`](/vibration), [`Clipboard`](/clipboard), [`AccessibilityInfo`](/accessibilityinfo), [`I18nManager`](/i18nmanager), [`BackHandler`](/backhandler), [`PixelRatio`](/pixelratio), [`processColor`](/processcolor), [`PanResponder`](/panresponder), [`Animated`](/animated), [`useAnimatedValue`](/animated), [`useAnimatedValueXY`](/animated), [`useAnimatedColor`](/animated), [`Easing`](/easing), [`LayoutAnimation`](/layoutanimation), [`usePressability`](/usepressability) |
19+
| Compat | [`unstable_createElement`](/compat), [`findNodeHandle`](/compat), [`TurboModuleRegistry`](/compat), and the entries `@rootnative/web/assets-registry` and `@rootnative/web/style`. Libraries import them, your app doesn't. Also the react-native-web props [`hrefAttrs` and `dataSet`](/compat#props-from-react-native-web), which libraries send. |
20+
| Web layer | [`Head`](/seo), from `@rootnative/web/dom` |
21+
| Tooling | [`rootnative()`](/vite-plugin), the Vite plugin, from `@rootnative/web/vite`, and [`@rootnative/web-expo`](/expo), for an Expo app, also with Expo Router |
2222

2323
## Planned, not written
2424

‎docs/sidebars.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ const sidebars: SidebarsConfig = {
3838
'activityindicator',
3939
'modal',
4040
'keyboardavoidingview',
41+
'inputaccessoryview',
42+
'safeareaview',
4143
'statusbar',
4244
],
4345
},

0 commit comments

Comments
 (0)