b15d092abd
Hidden behind a new feature flag: `IS_RECORD_PAGE_LAYOUT_EDITING_ENABLED` https://github.com/user-attachments/assets/112f5a8d-0dd0-4b9f-8825-9980db35fcbd
57 lines
1.9 KiB
TypeScript
57 lines
1.9 KiB
TypeScript
import styled from '@emotion/styled';
|
|
import { useIsMobile } from 'twenty-ui/utilities';
|
|
|
|
import { getPageLayoutVerticalListViewerVariant } from '@/page-layout/components/utils/getPageLayoutVerticalListViewerVariant';
|
|
import { type PageLayoutVerticalListViewerVariant } from '@/page-layout/types/PageLayoutVerticalListViewerVariant';
|
|
import { type PageLayoutWidget } from '@/page-layout/types/PageLayoutWidget';
|
|
import { WidgetRenderer } from '@/page-layout/widgets/components/WidgetRenderer';
|
|
import { useIsInPinnedTab } from '@/page-layout/widgets/hooks/useIsInPinnedTab';
|
|
import { useLayoutRenderingContext } from '@/ui/layout/contexts/LayoutRenderingContext';
|
|
|
|
const StyledVerticalListContainer = styled.div<{
|
|
variant: PageLayoutVerticalListViewerVariant;
|
|
shouldUseWhiteBackground: boolean;
|
|
}>`
|
|
background: ${({ theme, shouldUseWhiteBackground }) =>
|
|
shouldUseWhiteBackground
|
|
? theme.background.primary
|
|
: theme.background.secondary};
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: ${({ theme, variant }) =>
|
|
variant === 'side-column' ? 0 : theme.spacing(2)};
|
|
padding: ${({ theme, variant }) =>
|
|
variant === 'side-column' ? 0 : theme.spacing(2)};
|
|
`;
|
|
|
|
type PageLayoutVerticalListViewerProps = {
|
|
widgets: PageLayoutWidget[];
|
|
};
|
|
|
|
export const PageLayoutVerticalListViewer = ({
|
|
widgets,
|
|
}: PageLayoutVerticalListViewerProps) => {
|
|
const { isInRightDrawer } = useLayoutRenderingContext();
|
|
const isMobile = useIsMobile();
|
|
const { isInPinnedTab } = useIsInPinnedTab();
|
|
|
|
const variant = getPageLayoutVerticalListViewerVariant({
|
|
isInPinnedTab,
|
|
isMobile,
|
|
isInRightDrawer,
|
|
});
|
|
|
|
return (
|
|
<StyledVerticalListContainer
|
|
variant={variant}
|
|
shouldUseWhiteBackground={isMobile || isInRightDrawer}
|
|
>
|
|
{widgets.map((widget) => (
|
|
<div key={widget.id}>
|
|
<WidgetRenderer widget={widget} />
|
|
</div>
|
|
))}
|
|
</StyledVerticalListContainer>
|
|
);
|
|
};
|