From 66759409e37a81d9cb679b58e0ca6a4add6a150a Mon Sep 17 00:00:00 2001 From: Mike Cao Date: Wed, 28 Apr 2021 01:52:06 -0700 Subject: [PATCH] Added button to show/hide charts, closes #577. --- assets/chart-bar.svg | 1 + components/metrics/WebsiteChart.js | 17 +++++++----- components/pages/WebsiteList.js | 37 ++++++++++++++++++------- components/pages/WebsiteList.module.css | 7 +++++ 4 files changed, 45 insertions(+), 17 deletions(-) create mode 100644 assets/chart-bar.svg diff --git a/assets/chart-bar.svg b/assets/chart-bar.svg new file mode 100644 index 0000000000..d1d72fdc24 --- /dev/null +++ b/assets/chart-bar.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/components/metrics/WebsiteChart.js b/components/metrics/WebsiteChart.js index 0f4b48c32a..fca6d54154 100644 --- a/components/metrics/WebsiteChart.js +++ b/components/metrics/WebsiteChart.js @@ -23,6 +23,7 @@ export default function WebsiteChart({ domain, stickyHeader = false, showLink = false, + hideChart = false, onDataLoad = () => {}, }) { const shareToken = useShareToken(); @@ -91,13 +92,15 @@ export default function WebsiteChart({
{error && } - + {!hideChart && ( + + )}
diff --git a/components/pages/WebsiteList.js b/components/pages/WebsiteList.js index 0355247031..f4c2997909 100644 --- a/components/pages/WebsiteList.js +++ b/components/pages/WebsiteList.js @@ -1,28 +1,26 @@ -import React from 'react'; +import React, { useState } from 'react'; import { FormattedMessage } from 'react-intl'; import Link from 'components/common/Link'; import WebsiteChart from 'components/metrics/WebsiteChart'; import Page from 'components/layout/Page'; import EmptyPlaceholder from 'components/common/EmptyPlaceholder'; +import Button from 'components/common/Button'; import useFetch from 'hooks/useFetch'; import Arrow from 'assets/arrow-right.svg'; +import Chart from 'assets/chart-bar.svg'; import styles from './WebsiteList.module.css'; export default function WebsiteList({ userId }) { const { data } = useFetch('/api/websites', { params: { user_id: userId } }); + const [hideCharts, setHideCharts] = useState(false); if (!data) { return null; } - return ( - - {data.map(({ website_id, name, domain }) => ( -
- -
- ))} - {data.length === 0 && ( + if (data.length === 0) { + return ( + - )} + + ); + } + + return ( + +
+
+ {data.map(({ website_id, name, domain }) => ( +
+ +
+ ))}
); } diff --git a/components/pages/WebsiteList.module.css b/components/pages/WebsiteList.module.css index 816c5f3631..4c2952d6db 100644 --- a/components/pages/WebsiteList.module.css +++ b/components/pages/WebsiteList.module.css @@ -9,3 +9,10 @@ border-bottom: 0; margin-bottom: 0; } + +.menubar { + display: flex; + align-items: center; + justify-content: flex-end; + padding-top: 10px; +}