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

Update sx implementation on base screens to ensure we are using sx correctly #468

Merged
merged 2 commits into from
Sep 11, 2023
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
4 changes: 2 additions & 2 deletions login-workflow/src/components/Dialog/BasicDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,11 @@ export type BasicDialogProps = Omit<DialogProps, 'open'> & {
};

export const BasicDialog: React.FC<React.PropsWithChildren<React.PropsWithChildren<BasicDialogProps>>> = (props) => {
const { title, body, dismissButtonText, open = false, ...dialogProps } = props;
const { title, body, dismissButtonText, open = false, sx, ...dialogProps } = props;
const theme = useTheme();

return (
<Dialog {...dialogProps} open={open}>
<Dialog sx={sx} {...dialogProps} open={open}>
<DialogTitle sx={DialogTitleStyles(theme)}>{title}</DialogTitle>
<DialogContent sx={{ ...DialogContentStyles(theme), flex: '1 1 auto' }}>
<Typography>{body}</Typography>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ export type PasswordRequirementsProps = BoxProps & {
*/
export const PasswordRequirements: React.FC<React.PropsWithChildren<PasswordRequirementsProps>> = (props) => {
const { t } = useLanguageLocale();
const { passwordText, passwordRequirements = defaultPasswordRequirements(t), ...otherProps } = props;
const { passwordText, passwordRequirements = defaultPasswordRequirements(t), sx, ...otherProps } = props;

return (
<Box {...otherProps}>
<Box sx={sx} {...otherProps}>
{passwordRequirements.map((req, ind) => (
<PasswordRequirementsCheck
key={`password_requirement_${ind}`}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import VisibilityOff from '@mui/icons-material/VisibilityOff';
* @category Component
*/
export const PasswordTextField: React.FC<React.PropsWithChildren<TextFieldProps> & { icon?: ReactNode }> = (props) => {
const { icon } = props;
const { icon, sx, ...otherProps } = props;
const [showPassword, setShowPassword] = useState(false);

return (
Expand All @@ -41,7 +41,8 @@ export const PasswordTextField: React.FC<React.PropsWithChildren<TextFieldProps>
</InputAdornment>
),
}}
{...props}
sx={sx}
{...otherProps}
/>
);
};
31 changes: 17 additions & 14 deletions login-workflow/src/components/Spinner/Spinner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,27 @@ export type SpinnerProps = BoxProps & {
* @category Component
*/
export const Spinner: React.FC<SpinnerProps> = (props) => {
const { visible, ...otherProps } = props;
const { visible, sx, ...otherProps } = props;
const theme = useTheme();

return visible ? (
<Box
sx={{
position: 'fixed',
top: 0,
left: 0,
right: 0,
bottom: 0,
zIndex: 1000,
backgroundColor: theme.palette.mode === 'light' ? 'rgba(255,255,255,0.6)' : 'rgba(0,0,0,0.7)',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
flexDirection: 'column',
}}
sx={[
{
position: 'fixed',
top: 0,
left: 0,
right: 0,
bottom: 0,
zIndex: 1000,
backgroundColor: theme.palette.mode === 'light' ? 'rgba(255,255,255,0.6)' : 'rgba(0,0,0,0.7)',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
flexDirection: 'column',
},
...(Array.isArray(sx) ? sx : [sx]),
]}
{...otherProps}
>
<CircularProgress size={70} variant={'indeterminate'} />
Expand Down
4 changes: 2 additions & 2 deletions login-workflow/src/components/WorkflowCard/ErrorState.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import { Typography } from '@mui/material';
import { ErrorStateProps } from './WorkflowCard.types';

export const ErrorState: React.FC<ErrorStateProps> = (props) => {
const { message, ...otherTypographyProps } = props;
const { message, sx, ...otherTypographyProps } = props;

return (
<Typography sx={{ color: 'error.main' }} {...otherTypographyProps}>
<Typography sx={[{ color: 'error.main' }, ...(Array.isArray(sx) ? sx : [sx])]} {...otherTypographyProps}>
{message}
</Typography>
);
Expand Down
23 changes: 10 additions & 13 deletions login-workflow/src/components/WorkflowCard/WorkflowCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,19 +52,16 @@ export const WorkflowCard: React.FC<WorkflowCardBaseProps> = (props) => {
{...otherBoxProps}
>
<Card
sx={[
{
width: '100%',
height: '100%',
maxWidth: { sm: '450px', xs: 'none' },
maxHeight: { sm: '730px', xs: 'none' },
display: 'flex',
flexDirection: 'column',
position: 'relative',
borderRadius: { xs: 0, sm: '4px' },
},
...(Array.isArray(sx) ? sx : [sx]),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this being removed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As per the discussion with Joe in Office hours, we just need to merge the sx prop which is being passed with the parent component not with the children components.

]}
sx={{
width: '100%',
height: '100%',
maxWidth: { sm: '450px', xs: 'none' },
maxHeight: { sm: '730px', xs: 'none' },
display: 'flex',
flexDirection: 'column',
position: 'relative',
borderRadius: { xs: 0, sm: '4px' },
}}
className={defaultClasses.card}
data-testid={defaultClasses.card}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,15 +123,12 @@ export const WorkflowCardActions: React.FC<WorkflowCardActionsProps> = (props) =
<Box sx={{ width: fullWidthButton ? 0 : 100 }} />
)
}
sx={[
{
background: 'transparent',
width: '100%',
p: 0,
'& .MuiMobileStepper-dot': showStepperDots ? { my: 0, mx: 0.5 } : { display: 'none' },
},
...(Array.isArray(sx) ? sx : [sx]),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this being removed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same comment as above

]}
sx={{
background: 'transparent',
width: '100%',
p: 0,
'& .MuiMobileStepper-dot': showStepperDots ? { my: 0, mx: 0.5 } : { display: 'none' },
}}
className={defaultClasses.stepper}
data-testid={defaultClasses.stepper}
/>
Expand Down
23 changes: 13 additions & 10 deletions login-workflow/src/components/WorkflowCard/WorkflowCardBody.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,19 @@ export const WorkflowCardBody: React.FC<CardContentProps> = (props) => {

return (
<CardContent
sx={{
display: 'flex',
flex: '1 1 0',
overflow: 'auto',
flexDirection: 'column',
pt: 0,
pb: { sm: 2, md: 3 },
px: { xs: 2, md: 3 },
...sx,
}}
sx={[
{
display: 'flex',
flex: '1 1 0',
overflow: 'auto',
flexDirection: 'column',
pt: 0,
pb: { sm: 2, md: 3 },
px: { xs: 2, md: 3 },
...sx,
},
...(Array.isArray(sx) ? sx : [sx]),
]}
{...otherCardContentProps}
>
{children}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ import { WorkflowCardInstructionProps } from './WorkflowCard.types';
*/

export const WorkflowCardInstructions: React.FC<WorkflowCardInstructionProps> = (props) => {
const { instructions, divider, ...otherProps } = props;
const { instructions, divider, sx, ...otherProps } = props;

return (
<>
{typeof instructions === 'string' ? (
<Typography sx={{ px: { md: 3, xs: 2 }, pt: 2 }} {...otherProps}>
<Typography sx={[{ px: { md: 3, xs: 2 }, pt: 2 }, ...(Array.isArray(sx) ? sx : [sx])]} {...otherProps}>
{instructions}
</Typography>
) : (
Expand Down
Loading