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

WIP - adjust Info Group width #714

Draft
wants to merge 1 commit into
base: stable
Choose a base branch
from
Draft
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
39 changes: 13 additions & 26 deletions src/modules/form/components/DynamicGroup.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Box, Grid, lighten } from '@mui/material';
import { ReactNode } from 'react';
import { Grid, lighten } from '@mui/material';

import { GroupItemComponentProps } from '../types';

Expand All @@ -14,27 +13,6 @@ import TableGroup from './group/TableGroup';
import Signature from '@/modules/form/components/group/Signature';
import { Component } from '@/types/gqlTypes';

export const InfoGroup = ({
children,
}: {
children: ReactNode;
nestingLevel?: number;
}) => (
<Box
sx={{
backgroundColor: (theme) => lighten(theme.palette.grey[100], 0.2),
borderRadius: 1,
width: 'fit-content',
px: 0.5,
// use box shadow to "extend" background color beyond div. doing this so we dont mess with the height
boxShadow: (theme) =>
`0 2px 0 6px ${lighten(theme.palette.grey[100], 0.2)}`,
}}
>
{children}
</Box>
);

interface Props extends GroupItemComponentProps {
clientId?: string;
debug?: (ids?: string[]) => void;
Expand Down Expand Up @@ -75,9 +53,18 @@ const DynamicGroup: React.FC<Props> = ({ debug, ...props }) => {
return <Signature key={props.item.linkId} {...props} />;
case Component.InfoGroup:
return (
<InfoGroup nestingLevel={props.nestingLevel}>
<QuestionGroup key={props.item.linkId} {...props} />
</InfoGroup>
<QuestionGroup
key={props.item.linkId}
{...props}
sx={{
backgroundColor: (theme) => lighten(theme.palette.grey[100], 0.2),
borderRadius: 1,
px: 0.5,
// use box shadow to "extend" background color beyond div. doing this so we dont mess with the height
boxShadow: (theme) =>
`0 2px 0 6px ${lighten(theme.palette.grey[100], 0.2)}`,
}}
/>
);
case Component.Table:
return <TableGroup key={props.item.linkId} {...props} />;
Expand Down
9 changes: 5 additions & 4 deletions src/modules/form/components/group/QuestionGroup.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Box, Grid, Typography } from '@mui/material';
import { Box, Grid, SxProps, Theme, Typography } from '@mui/material';

import { GroupItemComponentProps } from '../../types';

Expand All @@ -9,7 +9,8 @@ const QuestionGroup = ({
nestingLevel,
renderChildItem,
viewOnly = false,
}: GroupItemComponentProps) => {
sx,
}: GroupItemComponentProps & { sx?: SxProps<Theme> }) => {
const wrappedChildren = (
<Grid container direction='column' sx={{ mt: 0 }} gap={3}>
{renderChildItem &&
Expand All @@ -27,7 +28,7 @@ const QuestionGroup = ({

if (nestingLevel >= 1) {
return (
<Grid item xs>
<Grid item xs sx={sx}>
<Box
sx={
isConditionalGroup
Expand All @@ -52,7 +53,7 @@ const QuestionGroup = ({
}

return (
<Grid item xs>
<Grid item xs sx={sx}>
{label && <Typography sx={{ mb: 2 }}>{label}</Typography>}
{wrappedChildren}
</Grid>
Expand Down
Loading