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

feat(tupaiaWeb): RN-1367: Multiphotograph viz captions + restyle #5769

Merged
merged 19 commits into from
Jul 26, 2024
Merged
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
2 changes: 2 additions & 0 deletions packages/tupaia-web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@
"react-query": "^3.39.3",
"react-router": "6.3.0",
"react-router-dom": "6.3.0",
"react-slick": "^0.30.2",
"slick-carousel": "^1.8.1",
"styled-components": "^5.1.0",
"vite-plugin-ejs": "^1.6.4",
"vite-plugin-env-compatible": "^1.1.1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,21 @@ const StyledModal = styled(Modal)`
}
`;

// MatrixWrapper is an expanding wrapper that allows the matrix to grow to the full width of the screen
const MatrixWrapper = css`
// ExpandingWrapper is an expanding wrapper that allows the viz to grow to the full width of the screen
const ExpandingWrapper = css`
max-width: 90vw;
padding: 0 0.5rem;
width: auto;
`;

// BigChartWrapper is a wrapper that sets the chart to be full width when there is a lot of data. This needs to be separate from MatrixWrapper because recharts needs a fixed width to expand because it calculates the svg width based on the width of the parent div
// BigChartWrapper is a wrapper that sets the chart to be full width when there is a lot of data. This needs to be separate from ExpandingWrapper because recharts needs a fixed width to expand because it calculates the svg width based on the width of the parent div
const BigChartWrapper = css`
min-width: 90vw;
width: 90%;
`;

const Wrapper = styled.div<{
$isMatrix?: boolean;
$isExpanding?: boolean;
$hasBigData?: boolean;
}>`
min-height: 25rem;
Expand All @@ -50,7 +50,7 @@ const Wrapper = styled.div<{
padding: 0 0.5rem;
width: 45rem;

${({ $isMatrix }) => $isMatrix && MatrixWrapper}
${({ $isExpanding }) => $isExpanding && ExpandingWrapper}
${({ $hasBigData }) => $hasBigData && BigChartWrapper}
`;

Expand All @@ -60,19 +60,31 @@ const ContentWrapper = ({ children }: { children: React.ReactNode }) => {

const { currentDashboardItem, reportData } = useEnlargedDashboardItem();

const isMatrix = currentDashboardItem?.config?.type === 'matrix';
const getIsExpanding = () => {
if (!currentDashboardItem) return false;
if (currentDashboardItem?.config?.type === 'matrix') return true;
if (currentDashboardItem?.config?.type === 'view') {
const { viewType } = currentDashboardItem?.config;
return viewType === 'multiPhotograph';
}
return false;
};

const isExpandingSize = getIsExpanding();

const getHasBigData = () => {
if (!reportData || isExportMode || currentDashboardItem?.config?.type !== 'chart') return false;
if (!reportData || isExportMode) return false;
// only charts with more than 20 data points are considered big. Matrix will expand to fit the screen if there is a lot of data, and 'view' type dashboards are always fixed because the data is semi-static
const { data } = reportData as BaseReport;
return data ? data?.length > 20 : false;
const { data = [] } = reportData as BaseReport;

if (currentDashboardItem?.config?.type !== 'chart') return false;
return data?.length > 20;
};

const hasBigData = getHasBigData();

return (
<Wrapper $isMatrix={isMatrix} $hasBigData={hasBigData}>
<Wrapper $isExpanding={isExpandingSize} $hasBigData={hasBigData}>
{children}
</Wrapper>
);
Expand Down

This file was deleted.

Loading