Skip to content

Commit

Permalink
passing sx prop
Browse files Browse the repository at this point in the history
  • Loading branch information
manojleaton committed Aug 5, 2024
1 parent 78a00d3 commit 521f43f
Show file tree
Hide file tree
Showing 19 changed files with 95 additions and 65 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -123,4 +123,8 @@ export type WorkflowCardProps = {
* Props for WorkflowCardActions component
*/
WorkflowCardActionsProps?: WorkflowCardActionsProps;
/**
* The system prop that allows defining system overrides as well as additional CSS styles.
*/
sx?: BoxProps['sx']; // or SxProps<Theme>
};
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ export const AccountDetailsScreen: React.FC<AccountDetailsScreenProps> = (props)
lastNameTextFieldProps,
initialFirstName = screenData.AccountDetails.firstName,
initialLastName = screenData.AccountDetails.lastName,
...otherProps
} = props;

const workflowCardHeaderProps = {
Expand Down Expand Up @@ -134,6 +135,7 @@ export const AccountDetailsScreen: React.FC<AccountDetailsScreenProps> = (props)
lastNameValidator={lastNameValidator}
WorkflowCardActionsProps={workflowCardActionsProps}
errorDisplayConfig={errorDisplayConfig}
{...otherProps}
/>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export const AccountDetailsScreenBase: React.FC<AccountDetailsScreenProps> = (pr
lastNameValidator = (): void => {},
lastNameTextFieldProps,
errorDisplayConfig,
...otherProps
} = props;

const cardBaseProps = props.WorkflowCardBaseProps || {};
Expand Down Expand Up @@ -87,7 +88,7 @@ export const AccountDetailsScreenBase: React.FC<AccountDetailsScreenProps> = (pr
}, []);

return (
<WorkflowCard {...cardBaseProps}>
<WorkflowCard {...cardBaseProps} {...otherProps}>
<WorkflowCardHeader {...headerProps} />
<WorkflowCardInstructions {...instructionsProps} />
<WorkflowCardBody>
Expand Down
105 changes: 52 additions & 53 deletions login-workflow/src/screens/AccountDetailsScreen/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,56 +2,55 @@ import { BoxProps, TextFieldProps } from '@mui/material';
import { WorkflowCardProps } from '../../components/WorkflowCard/WorkflowCard.types';
import { ErrorManagerProps } from '../../components/Error/types';

export type AccountDetailsScreenProps = WorkflowCardProps &
BoxProps & {
/**
* The label for the first name text field
*/
firstNameLabel?: string;

/**
* The initial value for the first name text field
*/
initialFirstName?: string;

/**
* The function that validates the first name text field
* @param {string} firstName - validates first name input length
* @returns boolean | string
*/
firstNameValidator?: (firstName: string) => boolean | string;

/**
* The props to pass to the first name field.
* See [MUI's TextFieldProps API](https://mui.com/material-ui/api/text-field/) for more details.
*/
firstNameTextFieldProps?: TextFieldProps;

/**
* The label for the last name text field
*/
lastNameLabel?: string;

/**
* The initial value for the last name text field
*/
initialLastName?: string;

/**
* The function that validates the last name text field
* @param {string} lastName - validates last name input length
* @returns boolean | string
*/
lastNameValidator?: (lastName: string) => boolean | string;

/**
* The props to pass to the last name field.
* See [MUI's TextFieldProps API](https://mui.com/material-ui/api/text-field/) for more details.
*/
lastNameTextFieldProps?: TextFieldProps;

/**
* The configuration for customizing how errors are displayed
*/
errorDisplayConfig?: ErrorManagerProps;
};
export type AccountDetailsScreenProps = WorkflowCardProps & {
/**
* The label for the first name text field
*/
firstNameLabel?: string;

/**
* The initial value for the first name text field
*/
initialFirstName?: string;

/**
* The function that validates the first name text field
* @param {string} firstName - validates first name input length
* @returns boolean | string
*/
firstNameValidator?: (firstName: string) => boolean | string;

/**
* The props to pass to the first name field.
* See [MUI's TextFieldProps API](https://mui.com/material-ui/api/text-field/) for more details.
*/
firstNameTextFieldProps?: TextFieldProps;

/**
* The label for the last name text field
*/
lastNameLabel?: string;

/**
* The initial value for the last name text field
*/
initialLastName?: string;

/**
* The function that validates the last name text field
* @param {string} lastName - validates last name input length
* @returns boolean | string
*/
lastNameValidator?: (lastName: string) => boolean | string;

/**
* The props to pass to the last name field.
* See [MUI's TextFieldProps API](https://mui.com/material-ui/api/text-field/) for more details.
*/
lastNameTextFieldProps?: TextFieldProps;

/**
* The configuration for customizing how errors are displayed
*/
errorDisplayConfig?: ErrorManagerProps;
};
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export const ContactSupportScreenBase: React.FC<ContactSupportScreenProps> = (pr
contactPhone,
dismissButtonLabel,
onDismiss,
...otherProps
} = props;

const defaultClasses = useUtilityClasses(props);
Expand All @@ -61,7 +62,12 @@ export const ContactSupportScreenBase: React.FC<ContactSupportScreenProps> = (pr
const actionsProps = props.WorkflowCardActionsProps || {};

return (
<WorkflowCard {...cardBaseProps} className={defaultClasses.root} data-testid={defaultClasses.root}>
<WorkflowCard
{...cardBaseProps}
className={defaultClasses.root}
data-testid={defaultClasses.root}
{...otherProps}
>
<WorkflowCardHeader {...headerProps} className={defaultClasses.title} data-testid={defaultClasses.title} />
{Object.keys(instructionsProps).length !== 0 && <WorkflowCardInstructions {...instructionsProps} />}
{icon && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ export const CreateAccountScreen: React.FC<CreateAccountScreenProps> = (props) =
return true;
},
emailTextFieldProps,
...otherProps
} = props;

const workflowCardBaseProps = {
Expand Down Expand Up @@ -123,6 +124,7 @@ export const CreateAccountScreen: React.FC<CreateAccountScreenProps> = (props) =
emailValidator={emailValidator}
WorkflowCardActionsProps={workflowCardActionsProps}
errorDisplayConfig={errorDisplayConfig}
{...otherProps}
/>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export const CreateAccountScreenBase: React.FC<
emailTextFieldProps,
inputRef,
errorDisplayConfig,
...otherProps
} = props;

const cardBaseProps = props.WorkflowCardBaseProps || {};
Expand Down Expand Up @@ -59,7 +60,7 @@ export const CreateAccountScreenBase: React.FC<
}, []);

return (
<WorkflowCard {...cardBaseProps}>
<WorkflowCard {...cardBaseProps} {...otherProps}>
<WorkflowCardHeader {...headerProps} />
<WorkflowCardInstructions {...instructionsProps} />
<WorkflowCardBody>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export const CreatePasswordScreen: React.FC<CreatePasswordScreenProps> = (props)
WorkflowCardInstructionProps,
WorkflowCardActionsProps,
PasswordProps,
...otherProps
} = props;

const passwordRef = useRef(null);
Expand Down Expand Up @@ -162,6 +163,7 @@ export const CreatePasswordScreen: React.FC<CreatePasswordScreenProps> = (props)
WorkflowCardInstructionProps={workflowCardInstructionProps}
PasswordProps={passwordProps}
errorDisplayConfig={errorDisplayConfig}
{...otherProps}
/>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ export const CreatePasswordScreenBase: React.FC<React.PropsWithChildren<CreatePa
const instructionsProps = props.WorkflowCardInstructionProps || {};
const actionsProps = props.WorkflowCardActionsProps || {};
const passwordProps = props.PasswordProps || { onPasswordChange: () => ({}) };
const { errorDisplayConfig } = props;
const { errorDisplayConfig, ...otherProps } = props;

return (
<WorkflowCard {...cardBaseProps}>
<WorkflowCard {...cardBaseProps} {...otherProps}>
<WorkflowCardHeader {...headerProps} />
<WorkflowCardInstructions {...instructionsProps} />
<WorkflowCardBody>
Expand Down
3 changes: 2 additions & 1 deletion login-workflow/src/screens/EulaScreen/EulaScreenBase.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export const EulaScreenBase: React.FC<EulaScreenProps> = (props) => {
checkboxProps,
errorDisplayConfig,
refreshConfig,
...otherProps
} = props;

const { t } = useTranslation();
Expand All @@ -58,7 +59,7 @@ export const EulaScreenBase: React.FC<EulaScreenProps> = (props) => {
};

return (
<WorkflowCard {...cardBaseProps}>
<WorkflowCard {...cardBaseProps} {...otherProps}>
<WorkflowCardHeader {...headerProps} />
{Object.keys(instructionsProps).length !== 0 && <WorkflowCardInstructions {...instructionsProps} />}
<WorkflowCardBody sx={{ pt: 2 }}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ export const ForgotPasswordScreen: React.FC<ForgotPasswordScreenProps> = (props)
slots = {},
slotProps = {},
emailTextFieldProps,
...otherProps
} = props;

const workflowCardBaseProps = {
Expand Down Expand Up @@ -174,6 +175,7 @@ export const ForgotPasswordScreen: React.FC<ForgotPasswordScreenProps> = (props)
},
}}
errorDisplayConfig={errorDisplayConfig}
{...otherProps}
/>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export const ForgotPasswordScreenBase: React.FC<React.PropsWithChildren<ForgotPa
showSuccessScreen,
errorDisplayConfig,
emailTextFieldProps,
...otherProps
} = props;

const cardBaseProps = props.WorkflowCardBaseProps || {};
Expand Down Expand Up @@ -73,7 +74,7 @@ export const ForgotPasswordScreenBase: React.FC<React.PropsWithChildren<ForgotPa
{showSuccessScreen ? (
getSuccessScreen(slotProps?.SuccessScreen || {}, slots?.SuccessScreen)
) : (
<WorkflowCard {...cardBaseProps}>
<WorkflowCard {...cardBaseProps} {...otherProps}>
<WorkflowCardHeader {...headerProps} />
<WorkflowCardInstructions {...instructionsProps} />
<WorkflowCardBody>
Expand Down
2 changes: 2 additions & 0 deletions login-workflow/src/screens/LoginScreen/LoginScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ export const LoginScreen: React.FC<React.PropsWithChildren<LoginScreenProps>> =
projectImage,
header,
footer,
...otherProps
} = props;

return (
Expand Down Expand Up @@ -119,6 +120,7 @@ export const LoginScreen: React.FC<React.PropsWithChildren<LoginScreenProps>> =
projectImage={projectImage}
header={header}
footer={footer}
{...otherProps}
/>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export const OktaLoginScreen: React.FC<OktaLoginScreenProps> = (props) => {
projectImage,
header,
footer,
...otherProps
} = props;

useEffect(() => {
Expand Down Expand Up @@ -83,6 +84,7 @@ export const OktaLoginScreen: React.FC<OktaLoginScreenProps> = (props) => {
projectImage={projectImage}
header={header}
footer={footer}
{...otherProps}
/>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export const ResetPasswordScreen: React.FC<ResetPasswordScreenProps> = (props) =
PasswordProps,
slots = {},
slotProps = {},
...otherProps
} = props;

const [passwordInput, setPasswordInput] = useState(PasswordProps?.initialNewPasswordValue ?? '');
Expand Down Expand Up @@ -199,6 +200,7 @@ export const ResetPasswordScreen: React.FC<ResetPasswordScreenProps> = (props) =
}
: errorDisplayConfig.onClose,
}}
{...otherProps}
/>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export const ResetPasswordScreenBase: React.FC<React.PropsWithChildren<ResetPass
const instructionsProps = props.WorkflowCardInstructionProps || {};
const actionsProps = props.WorkflowCardActionsProps || {};
const passwordProps = props.PasswordProps || { onPasswordChange: () => ({}) };
const { showSuccessScreen, slots, slotProps = {}, errorDisplayConfig } = props;
const { showSuccessScreen, slots, slotProps = {}, errorDisplayConfig, ...otherProps } = props;

const getSuccessScreen = (
_props?: SuccessScreenProps,
Expand All @@ -39,7 +39,7 @@ export const ResetPasswordScreenBase: React.FC<React.PropsWithChildren<ResetPass
{showSuccessScreen ? (
getSuccessScreen(slotProps?.SuccessScreen, slots?.SuccessScreen)
) : (
<WorkflowCard {...cardBaseProps}>
<WorkflowCard {...cardBaseProps} {...otherProps}>
<WorkflowCardHeader {...headerProps} />
<WorkflowCardInstructions {...instructionsProps} divider />
<WorkflowCardBody>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ import Box from '@mui/material/Box';
*/

export const SuccessScreenBase: React.FC<SuccessScreenProps> = (props) => {
const { EmptyStateProps, dismissButtonLabel = '', canDismiss, onDismiss } = props;
const { EmptyStateProps, dismissButtonLabel = '', canDismiss, onDismiss, ...otherProps } = props;

const cardBaseProps = props.WorkflowCardBaseProps || {};
const headerProps = props.WorkflowCardHeaderProps || {};
const instructionsProps = props.WorkflowCardInstructionProps || {};
const actionsProps = props.WorkflowCardActionsProps || {};

return (
<WorkflowCard {...cardBaseProps}>
<WorkflowCard {...cardBaseProps} {...otherProps}>
<WorkflowCardHeader {...headerProps} />
{Object.keys(instructionsProps).length !== 0 && <WorkflowCardInstructions {...instructionsProps} />}
<WorkflowCardBody>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export const VerifyCodeScreen: React.FC<VerifyCodeScreenProps> = (props) => {
verifyCodeInputLabel = t('bluiRegistration:SELF_REGISTRATION.VERIFY_EMAIL.VERIFICATION'),
initialValue = screenData.VerifyCode.code,
verifyCodeTextFieldProps,
...otherProps
} = props;

const handleOnNext = useCallback(
Expand Down Expand Up @@ -153,6 +154,7 @@ export const VerifyCodeScreen: React.FC<VerifyCodeScreenProps> = (props) => {
codeValidator={codeValidator}
errorDisplayConfig={errorDisplayConfig}
verifyCodeTextFieldProps={verifyCodeTextFieldProps}
{...otherProps}
/>
);
};
Loading

0 comments on commit 521f43f

Please sign in to comment.