-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(exoflex): modal component (#178)
* fix(exoflex): export Portal * feat(exoflex): modal component * chore(exoflex): add modal example * fix(exoflex): omit theme prop from modal * docs(exoflex): modal docs
- Loading branch information
1 parent
c174299
commit 415de7a
Showing
9 changed files
with
102 additions
and
1 deletion.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,39 @@ | ||
# Modal | ||
|
||
The Modal component is a simple way to present content above an enclosing view. | ||
|
||
### Preview | ||
|
||
<p align="center"> | ||
<img src="../assets/modal_mobile_preview.png" alt="modal_mobile_preview" width="320"> | ||
<img src="../assets/modal_web_preview.png" alt="modal_web_preview"> | ||
</p> | ||
|
||
### Props | ||
|
||
| Name | Type | Default | Description | | ||
| --------------------- | :--------------------: | :-----: | ---------------------------------------------------------- | | ||
| children \* | `ReactNode` | | Content of the Modal. | | ||
| dismissable | `boolean` | `true` | Determines whether clicking outside the modal dismiss it. | | ||
| onDismiss | `() => void` | | Callback that is called when the user dismisses the modal. | | ||
| visible | `boolean` | `false` | Determines whether the modal is visible. | | ||
| contentContainerStyle | `StyleProp<ViewStyle>` | | Style for the content of the modal. | | ||
|
||
Props marked with \* are required. | ||
|
||
### Example | ||
|
||
```tsx | ||
<Provider> | ||
<Portal> | ||
<Modal | ||
visible={isVisible} | ||
onDismiss={toggleModal} | ||
contentContainerStyle={styles.modal} | ||
> | ||
<Text>Howdy, Modal!</Text> | ||
<Text>You can click the overlay to close this modal.</Text> | ||
</Modal> | ||
</Portal> | ||
</Provider> | ||
``` |
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 @@ | ||
import React, { useState } from 'react'; | ||
import { View, StyleSheet } from 'react-native'; | ||
import { Portal, Text, Modal, Button } from 'exoflex'; | ||
|
||
function ModalExample() { | ||
let [isVisible, setVisible] = useState(false); | ||
|
||
let toggleModal = () => setVisible(!isVisible); | ||
|
||
return ( | ||
<> | ||
<View style={styles.container}> | ||
<Button onPress={toggleModal}>Open Modal</Button> | ||
</View> | ||
<Portal> | ||
<Modal | ||
visible={isVisible} | ||
onDismiss={toggleModal} | ||
contentContainerStyle={styles.modal} | ||
> | ||
<Text>Howdy, Modal!</Text> | ||
<Text>You can click the overlay to close this modal.</Text> | ||
</Modal> | ||
</Portal> | ||
</> | ||
); | ||
} | ||
|
||
let styles = StyleSheet.create({ | ||
container: { | ||
flex: 1, | ||
justifyContent: 'center', | ||
alignItems: 'center', | ||
}, | ||
modal: { | ||
padding: 16, | ||
backgroundColor: 'white', | ||
margin: 16, | ||
alignItems: 'center', | ||
height: 150, | ||
}, | ||
}); | ||
|
||
ModalExample.title = 'Modal'; | ||
|
||
export default ModalExample; |
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
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,11 @@ | ||
import React from 'react'; | ||
import { | ||
Modal as PaperModal, | ||
ModalProps as PaperModalProps, | ||
} from 'react-native-paper'; | ||
|
||
type ModalProps = Omit<PaperModalProps, 'theme'>; | ||
|
||
export default function Modal(props: ModalProps) { | ||
return <PaperModal {...props} />; | ||
} |
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 |
---|---|---|
|
@@ -18,6 +18,8 @@ export { | |
DateTimePicker, | ||
Drawer, | ||
IconButton, | ||
Modal, | ||
Portal, | ||
ProgressBar, | ||
Provider, | ||
RadioButton, | ||
|