diff --git a/README.md b/README.md index 061cda02..f137c329 100644 --- a/README.md +++ b/README.md @@ -118,7 +118,7 @@ React Native v0.60 | Image | ✓ | Missing multiple sources ([#515](https://github.com/necolas/react-native-web/issues/515)) and HTTP headers ([#1019](https://github.com/necolas/react-native-web/issues/1019)). | | ImageBackground | ✓ | | | KeyboardAvoidingView | (✓) | Mock. No equivalent web APIs. | -| Modal | ✘ | Not started ([#1020](https://github.com/necolas/react-native-web/issues/1020)). | +| Modal | ✓ | | | Picker | ✓ | | | Pressable | ✓ | | | RefreshControl | ✘ | Not started ([#1027](https://github.com/necolas/react-native-web/issues/1027)). | diff --git a/packages/docs/src/components/Modal/Modal.stories.mdx b/packages/docs/src/components/Modal/Modal.stories.mdx new file mode 100644 index 00000000..31c8ef08 --- /dev/null +++ b/packages/docs/src/components/Modal/Modal.stories.mdx @@ -0,0 +1,83 @@ +import { Meta, Story, Preview } from '@storybook/addon-docs/blocks'; +import * as Stories from './examples'; + + + +# Modal + +The Modal component is a basic way to present content above an enclosing view. +Modals may be nested within other Modals. + +## Props + +| Name | Type | Default | +| ------------------------- | -------------- | ------- | +| animationType | ?AnimationType | 'none' | +| children | ?any | | +| onDismiss | ?Function | | +| onRequestClose | ?Function | | +| onShow | ?Function | | +| transparent | ?boolean | false | +| visible | ?boolean | true | + +### animationType + +The `animationType` prop can be used to add animation to the modal +being opened or dismissed. + +* `none` - the modal appears without any animation. +* `slide` - the modal slides up from the bottom of the screen. +* `fade` - the modal fades in. + +By default this is `none`. + + + + + + + +### onDismiss + +The `onDismiss` callback is called after the modal has been dismissed and is no longer visible. + +### onRequestClose + +The `onRequestClose` callback is called when the user is attempting to close the modal - +such as when they hit `Escape`. + +Only the top-most Modal responds to hitting `Escape`. + + + + + + + +### onShow + +The `onShow` callback is called once the modal has been shown and may be visible. + +### transparent + +The `transparent` prop determines if the modal is rendered with a `transparent` backdrop or +a `white` backdrop. + + + + + + + +### visible + +Whether or not the modal is visible. + +When set to `false` the contents are not rendered & the modal removes itself +from the screen. + + + + + + diff --git a/packages/docs/src/components/Modal/examples/Animated.js b/packages/docs/src/components/Modal/examples/Animated.js new file mode 100644 index 00000000..f62e9cc3 --- /dev/null +++ b/packages/docs/src/components/Modal/examples/Animated.js @@ -0,0 +1,50 @@ +import React, { useState } from 'react'; +import { Modal, Text, Button, View, StyleSheet } from 'react-native'; + +function Gap() { + return ; +} + +function AnimatedModal({ animationType }) { + const [isVisible, setIsVisible] = useState(false); + + return ( + <> +