Skip to content

Commit

Permalink
refactor: add missing component using example
Browse files Browse the repository at this point in the history
  • Loading branch information
lukewalczak committed Feb 6, 2022
1 parent 6d4a2d4 commit b679de6
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 3 deletions.
39 changes: 39 additions & 0 deletions src/components/Dialog/DialogIcon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,43 @@ type Props = {
*/
size?: number;
};

/**
* A component to show an icon in a Dialog.
*
* ## Usage
* ```js
* import * as React from 'react';
* import { StyleSheet } from 'react-native';
* import { Paragraph, Dialog, Portal } from 'react-native-paper';
*
* const MyComponent = () => {
* const [visible, setVisible] = React.useState(false);
*
* const hideDialog = () => setVisible(false);
*
* return (
* <Portal>
* <Dialog visible={visible} onDismiss={hideDialog}>
* <Dialog.Icon icon="alert" />
* <Dialog.Title style={styles.title}>This is a title</Dialog.Title>
* <Dialog.Content>
* <Paragraph>This is simple dialog</Paragraph>
* </Dialog.Content>
* </Dialog>
* </Portal>
* );
* };
*
* const styles = StyleSheet.create({
* title: {
* textAlign: 'center',
* },
* })
*
* export default MyComponent;
* ```
*/
const DialogIcon = ({ size = 24, color, icon }: Props) => {
const { md } = useTheme();
return (
Expand All @@ -30,6 +67,8 @@ const DialogIcon = ({ size = 24, color, icon }: Props) => {
);
};

DialogIcon.displayName = 'Dialog.Icon';

const styles = StyleSheet.create({
wrapper: {
alignItems: 'center',
Expand Down
7 changes: 4 additions & 3 deletions src/components/Modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { useTheme } from '../core/theming';
import useAnimatedValue from '../utils/useAnimatedValue';
import { addEventListener } from '../utils/addEventListener';
import color from 'color';
import { tokens } from '../styles/themes/v3/tokens';

type Props = {
/**
Expand Down Expand Up @@ -110,7 +111,7 @@ export default function Modal({
visibleRef.current = visible;
});

const { colors, animation, isV3, md } = useTheme();
const { colors, animation, isV3 } = useTheme();

const opacity = useAnimatedValue(visible ? 1 : 0);

Expand Down Expand Up @@ -222,8 +223,8 @@ export default function Modal({
styles.backdrop,
{
backgroundColor: isV3
? color(md('md.sys.color.background') as string)
.alpha(0.8)
? color(tokens.md.ref.palette['neutral-variant20'])
.alpha(0.4)
.rgb()
.string()
: colors?.backdrop,
Expand Down

0 comments on commit b679de6

Please sign in to comment.