Skip to content

Commit

Permalink
Allow pop-overs to be dismissed from the content of the pop-over.
Browse files Browse the repository at this point in the history
  • Loading branch information
jameswilddev committed Nov 18, 2021
1 parent 0095e82 commit 098b387
Show file tree
Hide file tree
Showing 2 changed files with 233 additions and 113 deletions.
23 changes: 15 additions & 8 deletions components/createFullHeightPopoverComponent/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,13 @@ export const createFullHeightPopoverComponent = (
* styles as though it is invalid.
*/
readonly valid: boolean;

/**
* Describes the contents of the pop-over.
* @param close Invoke to close the pop-over.
* @returns The contents of the pop-over.
*/
children(close: () => void): null | JSX.Element;
}> => {
const styles = StyleSheet.create({
validHitbox: createControlStyleInstance(
Expand Down Expand Up @@ -194,23 +201,23 @@ export const createFullHeightPopoverComponent = (
if (additionalModalViewStyle === null) {
return inline;
} else {
const onClose = () => {
state.current.open = false;

refresh();
};

return (
<React.Fragment>
{inline}
<SimpleModal
onClose={() => {
state.current.open = false;

refresh();
}}
>
<SimpleModal onClose={onClose}>
<View
style={[
valid ? styles.validView : styles.invalidView,
additionalModalViewStyle,
]}
>
{children}
{children(onClose)}
</View>
</SimpleModal>
</React.Fragment>
Expand Down
Loading

0 comments on commit 098b387

Please sign in to comment.