Skip to content

Commit f5daa76

Browse files
committed
feat: add abstract detail component
Signed-off-by: Amit Amrutiya <[email protected]>
1 parent 6647665 commit f5daa76

File tree

3 files changed

+56
-0
lines changed

3 files changed

+56
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/* eslint-disable @typescript-eslint/no-explicit-any */
2+
import { OperatorDataContainer } from './styles';
3+
import { isEmptyAtAllDepths } from './utils';
4+
5+
interface OperatorDataFormatterProps {
6+
data: any;
7+
FormatStructuredData: any;
8+
propertyFormatter: any;
9+
}
10+
11+
export const OperatorDataFormatter = ({
12+
data,
13+
FormatStructuredData,
14+
propertyFormatter
15+
}: OperatorDataFormatterProps) => {
16+
if (!data || isEmptyAtAllDepths(data)) {
17+
return null;
18+
}
19+
20+
return (
21+
<OperatorDataContainer>
22+
<FormatStructuredData data={data} propertyFormatters={propertyFormatter} isLevel={false} />
23+
</OperatorDataContainer>
24+
);
25+
};
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import ExpandLessIcon from '@mui/icons-material/ExpandLess';
2+
import ExpandMoreIcon from '@mui/icons-material/ExpandMore';
3+
import { iconMedium } from '../../constants/iconsSizes';
4+
import { useTheme } from '../../theme';
5+
6+
interface ExpandArrowProps {
7+
expanded: boolean;
8+
}
9+
10+
const ExpandArrow: React.FC<ExpandArrowProps> = ({ expanded }) => {
11+
const theme = useTheme();
12+
return expanded ? (
13+
<ExpandLessIcon fill={theme.palette.icon.default} {...iconMedium} />
14+
) : (
15+
<ExpandMoreIcon fill={theme.palette.icon.default} {...iconMedium} />
16+
);
17+
};
18+
19+
export default ExpandArrow;
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import React from 'react';
2+
3+
export const LevelContext = React.createContext<number>(0);
4+
5+
interface LevelProps {
6+
children: React.ReactNode;
7+
}
8+
9+
export const Level: React.FC<LevelProps> = ({ children }) => {
10+
const level = React.useContext(LevelContext);
11+
return <LevelContext.Provider value={level + 1}>{children}</LevelContext.Provider>;
12+
};

0 commit comments

Comments
 (0)