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

configurable form theme #1482

Merged
merged 1 commit into from
May 3, 2024
Merged
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
20 changes: 17 additions & 3 deletions spiffworkflow-frontend/src/components/CustomForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,20 @@ export default function CustomForm({
'numeric-range': NumericRangeField,
};

let reactJsonSchemaFormTheme = reactJsonSchemaForm;
if ('ui:theme' in uiSchema) {
if (uiSchema['ui:theme'] === 'carbon') {
reactJsonSchemaFormTheme = 'carbon';
} else if (uiSchema['ui:theme'] === 'mui') {
reactJsonSchemaFormTheme = 'mui';
} else {
console.error(
`Unsupported theme: ${uiSchema['ui:theme']}. Defaulting to mui`
);
reactJsonSchemaFormTheme = 'mui';
}
burnettk marked this conversation as resolved.
Show resolved Hide resolved
}

const rjsfTemplates: any = {};
if (restrictedWidth) {
rjsfTemplates.ObjectFieldTemplate = ObjectFieldRestrictedGridTemplate;
Expand Down Expand Up @@ -475,16 +489,16 @@ export default function CustomForm({
templates: rjsfTemplates,
omitExtraData: true,
};
if (reactJsonSchemaForm === 'carbon') {
if (reactJsonSchemaFormTheme === 'carbon') {
// eslint-disable-next-line react/jsx-props-no-spreading
return <CarbonForm {...formProps}>{childrenToUse}</CarbonForm>;
}

if (reactJsonSchemaForm === 'mui') {
if (reactJsonSchemaFormTheme === 'mui') {
// eslint-disable-next-line react/jsx-props-no-spreading
return <MuiForm {...formProps}>{childrenToUse}</MuiForm>;
}

console.error(`Unsupported form type: ${reactJsonSchemaForm}`);
console.error(`Unsupported form type: ${reactJsonSchemaFormTheme}`);
burnettk marked this conversation as resolved.
Show resolved Hide resolved
return null;
}
Loading