Skip to content

Commit b2519fb

Browse files
committed
Refactor AuthOptionFactory to utilize theme context and improve form styling
1 parent ac36df8 commit b2519fb

2 files changed

Lines changed: 10 additions & 2 deletions

File tree

packages/react/src/components/presentation/auth/AuthOptionFactory.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ import flowIconRegistry from '../../primitives/Icons/flowIconRegistry';
5454
import Select from '../../primitives/Select/Select';
5555
import Typography from '../../primitives/Typography/Typography';
5656
import {TypographyVariant} from '../../primitives/Typography/Typography.styles';
57+
import useTheme from '../../../contexts/Theme/useTheme';
5758

5859
const logger: ReturnType<typeof createPackageComponentLogger> = createPackageComponentLogger(
5960
'@asgardeo/react',
@@ -199,6 +200,8 @@ const createAuthComponentFromFlow = (
199200
variant?: any;
200201
} = {},
201202
): ReactElement | null => {
203+
const {theme} = useTheme();
204+
202205
const key: string | number = options.key || component.id;
203206

204207
/** Resolve any remaining {{t()}} or {{meta()}} template expressions in a string at render time. */
@@ -403,6 +406,12 @@ const createAuthComponentFromFlow = (
403406

404407
case EmbeddedFlowComponentType.Block: {
405408
if (component.components && component.components.length > 0) {
409+
const formStyles: CSSProperties = {
410+
display: 'flex',
411+
flexDirection: 'column',
412+
gap: `calc(${theme.vars.spacing.unit} * 2)`,
413+
};
414+
406415
const blockComponents: any = component.components
407416
.map((childComponent: any, index: any) =>
408417
createAuthComponentFromFlow(
@@ -423,7 +432,7 @@ const createAuthComponentFromFlow = (
423432
.filter(Boolean);
424433

425434
return (
426-
<form id={component.id} key={key}>
435+
<form id={component.id} key={key} style={formStyles}>
427436
{blockComponents}
428437
</form>
429438
);

packages/react/src/components/primitives/FormControl/FormControl.styles.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ const useStyles = (
4242
const formControl: string = css`
4343
text-align: start;
4444
font-family: ${theme.vars.typography.fontFamily};
45-
margin-bottom: calc(${theme.vars.spacing.unit} * 2);
4645
`;
4746

4847
const helperText: string = css`

0 commit comments

Comments
 (0)