Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🚚 SORD-657 replace dialog to modal #301

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@ import type { Meta, StoryObj } from '@storybook/react-native';
import React from 'react';
import { StyleSheet, View } from 'react-native';

import { Body, Dialog } from 'smartway-react-native-ui';
import { Body, Modal } from 'smartway-react-native-ui';
import { IconsName } from '../config/IconList';

type DialogPropsAndCustomArgs = React.ComponentProps<typeof Dialog> & {
type ModalPropsAndCustomArgs = React.ComponentProps<typeof Modal> & {
haveSecondButton?: boolean;
};

export default {
title: 'components/Dialog',
component: Dialog,
component: Modal,
args: {
variant: 'left',
haveSecondButton: false,
Expand Down Expand Up @@ -65,9 +65,9 @@ export default {
\`\`\`
`,
},
} as Meta<DialogPropsAndCustomArgs>;
} as Meta<ModalPropsAndCustomArgs>;

type Story = StoryObj<DialogPropsAndCustomArgs>;
type Story = StoryObj<ModalPropsAndCustomArgs>;

const InsideDialog = ({ variantBody }: { variantBody?: 'left' | 'center' }) => {
const styles = StyleSheet.create({
Expand All @@ -90,7 +90,7 @@ export const Default: Story = {
color: args.color ?? undefined,
};
return (
<Dialog
<Modal
icon={iconprops ?? undefined}
{...args}
visible={true}
Expand All @@ -112,7 +112,7 @@ export const Default: Story = {
}}
>
<InsideDialog variantBody={args?.variant ?? 'left'} />
</Dialog>
</Modal>
);
},
};
Expand Down
4 changes: 2 additions & 2 deletions src/components/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Logo } from './logos/Logo';
import { Screen } from './Screen';
import { Headline } from './typography/Headline';
import { Body } from './typography/Body';
import { Dialog } from './dialogs/Dialog';
import { Modal } from './modals/Modal';
import { TextField } from './fields/TextField';
import { Icon } from './icons/Icon';
import { TopAppBar } from './topAppBar/TopAppBar';
Expand All @@ -25,7 +25,7 @@ export {
Body,
Button,
IconButton,
Dialog,
Modal,
Headline,
Icon,
Logo,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Dimensions, StyleSheet, TextStyle, View, ViewStyle } from 'react-native
import { Dialog as BaseDialog, Portal } from 'react-native-paper';
import { Button } from '../buttons/Button';
import { Headline } from '../typography/Headline';
import { DialogIcon, DialogIconProps } from './DialogIcon';
import { DialogIcon, DialogIconProps } from './ModalIcon';
import { useTheme } from '../../styles/themes';
import DeviceInfo from 'react-native-device-info';

Expand All @@ -14,12 +14,12 @@ interface Action {
onPress: () => void;
}

interface DialogActions {
interface ModalActions {
confirm: Action;
cancel?: Action;
}

export interface DialogProps extends PropsWithChildren {
export interface ModalProps extends PropsWithChildren {
visible: boolean;
style?: ViewStyle;
titleStyle?: TextStyle;
Expand All @@ -31,10 +31,10 @@ export interface DialogProps extends PropsWithChildren {
variant?: 'left' | 'center';
dismissable?: boolean;
onDismiss?: () => void;
actions: DialogActions;
actions: ModalActions;
}

export const Dialog = (props: DialogProps) => {
export const Modal = (props: ModalProps) => {
const { style, actionsStyle, leftActionsStyle, rightActionsStyle, actions, variant } = props;

const styles = useStyles({
Expand Down Expand Up @@ -98,10 +98,10 @@ export const Dialog = (props: DialogProps) => {
};

type UseStylesProps = Pick<
DialogProps,
ModalProps,
'style' | 'actionsStyle' | 'leftActionsStyle' | 'rightActionsStyle' | 'variant'
> & {
cancel: DialogProps['actions']['cancel'];
cancel: ModalProps['actions']['cancel'];
};

function useStyles({
Expand Down
2 changes: 1 addition & 1 deletion src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ export {
Body,
Button,
IconButton,
Dialog,
Modal,
Headline,
Icon,
Logo,
Expand Down
Loading