mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
add option to disable accordions
This commit is contained in:
parent
590d70a8da
commit
a74c1bf06a
@ -1,28 +1,58 @@
|
|||||||
import { t } from '@lingui/macro';
|
import { t } from '@lingui/macro';
|
||||||
import { Accordion, Alert, Space, Stack, Text } from '@mantine/core';
|
import {
|
||||||
import { IconExclamationCircle } from '@tabler/icons-react';
|
Accordion,
|
||||||
|
AccordionControlProps,
|
||||||
|
Alert,
|
||||||
|
Box,
|
||||||
|
Space,
|
||||||
|
Stack,
|
||||||
|
Text,
|
||||||
|
Tooltip
|
||||||
|
} from '@mantine/core';
|
||||||
|
import { IconAlertCircle, IconExclamationCircle } from '@tabler/icons-react';
|
||||||
import { ReactNode } from 'react';
|
import { ReactNode } from 'react';
|
||||||
|
|
||||||
import { StylishText } from '../../../components/items/StylishText';
|
import { StylishText } from '../../../components/items/StylishText';
|
||||||
|
|
||||||
|
function AccordionControl(props: AccordionControlProps) {
|
||||||
|
console.log(props);
|
||||||
|
return (
|
||||||
|
<Box sx={{ display: 'flex', alignItems: 'center' }}>
|
||||||
|
{props.disabled && (
|
||||||
|
<Tooltip
|
||||||
|
label={t`No data available`}
|
||||||
|
children={<IconAlertCircle size="1rem" color="gray" />}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
<Accordion.Control
|
||||||
|
{...props}
|
||||||
|
pl={props.disabled ? '0.25rem' : '1.25rem'}
|
||||||
|
/>
|
||||||
|
</Box>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
export default function PricingPanel({
|
export default function PricingPanel({
|
||||||
content,
|
content,
|
||||||
label,
|
label,
|
||||||
title,
|
title,
|
||||||
visible
|
visible,
|
||||||
|
disabled = undefined
|
||||||
}: {
|
}: {
|
||||||
content: ReactNode;
|
content: ReactNode;
|
||||||
label: string;
|
label: string;
|
||||||
title: string;
|
title: string;
|
||||||
visible: boolean;
|
visible: boolean;
|
||||||
|
disabled: boolean | undefined;
|
||||||
}): ReactNode {
|
}): ReactNode {
|
||||||
|
const is_disabled = disabled === undefined ? false : disabled;
|
||||||
return (
|
return (
|
||||||
visible && (
|
visible && (
|
||||||
<Accordion.Item value={label}>
|
<Accordion.Item value={label}>
|
||||||
<Accordion.Control>
|
<AccordionControl disabled={is_disabled}>
|
||||||
<StylishText size="lg">{title}</StylishText>
|
<StylishText size="lg">{title}</StylishText>
|
||||||
</Accordion.Control>
|
</AccordionControl>
|
||||||
<Accordion.Panel>{content}</Accordion.Panel>
|
<Accordion.Panel>{!is_disabled && content}</Accordion.Panel>
|
||||||
</Accordion.Item>
|
</Accordion.Item>
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user