Skip to content

Commit

Permalink
Fix mobile version of matrix grid
Browse files Browse the repository at this point in the history
  • Loading branch information
Viktor Riabkov committed Apr 4, 2024
1 parent 1d2a728 commit 2ba417f
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 5 deletions.
2 changes: 2 additions & 0 deletions src/entities/activity/ui/items/Matrix/MatrixCell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@ export const MatrixCell = ({ children, isRowLabel }: Props) => {

return (
<Box
display="flex"
height={lessThanTarget ? '100px' : '112px'}
padding={lessThanTarget ? '8px' : '14px'}
justifyContent="center"
alignItems="center"
width={isRowLabel ? rowLabelWidth : '100%'}
minWidth={lessThanTarget ? '70px' : '142px'}
maxWidth="400px"
data-testid="matrix-cell"
>
{children}
</Box>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import Box from '@mui/material/Box';
import { MatrixCell } from '../MatrixCell';

import { CheckboxItem, SelectBaseBox } from '~/shared/ui';
import { useCustomMediaQuery } from '~/shared/utils';

type Props = {
id: string;
Expand All @@ -13,14 +14,17 @@ type Props = {
};

export const CheckboxButton = ({ id, isChecked, text, onChange }: Props) => {
const { lessThanSM } = useCustomMediaQuery();

return (
<Box flex={1} key={id}>
<Box flex={1} key={id} data-testid="matrix-checkbox-button-container">
<MatrixCell>
<SelectBaseBox
color={null}
onHandleChange={onChange}
checked={isChecked}
justifyContent="center"
padding={lessThanSM ? '12px 8px' : '16px'}
>
<CheckboxItem
id={id}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ type Props = {

export const CheckboxGrid = ({ rows, options, onChange, values }: Props) => {
return (
<Box display="flex" flex={1} flexDirection="column">
<Box display="flex" flex={1} flexDirection="column" data-testid="matrix-checkbox-grid">
<MatrixHeader options={options} />

{rows.map((row, rowI) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ type Props = {

export const RadioButton = ({ id, text, isChecked, onChange }: Props) => {
return (
<Box flex={1} key={id}>
<Box flex={1} key={id} data-testid="matrix-radio-button-container">
<MatrixCell>
<SelectBaseBox
color={null}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ type Props = {

export const RadioGrid = ({ rows, options, onChange, values }: Props) => {
return (
<Box display="flex" flex={1} flexDirection="column">
<Box display="flex" flex={1} flexDirection="column" data-testid="matrix-radio-grid">
<MatrixHeader options={options} />

{rows.map((row, rowI) => {
Expand Down
3 changes: 2 additions & 1 deletion src/shared/ui/Items/SelectBase/SelectBaseBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import Box from '@mui/material/Box';
import { Theme } from '~/shared/constants';

type Props = PropsWithChildren<{
padding?: string;
justifyContent?:
| 'flex-start'
| 'center'
Expand Down Expand Up @@ -40,7 +41,7 @@ export const SelectBaseBox = (props: Props) => {
gap="12px"
className="response-option"
borderRadius="12px"
padding="16px"
padding={props.padding ? props.padding : '16px'}
border={`2px solid ${borderColor}`}
bgcolor={props.color ? props.color : backgroundColor}
onClick={props.onHandleChange}
Expand Down

0 comments on commit 2ba417f

Please sign in to comment.