From e4e7f5b05c71bd396621017c474afb2db6e9f4be Mon Sep 17 00:00:00 2001 From: Mike Cao Date: Fri, 31 Jul 2020 21:56:25 -0700 Subject: [PATCH] Updated rankings styling and filters. --- components/Dropdown.module.css | 8 ++++---- components/RankingsChart.js | 14 +++++++++++--- components/RankingsChart.module.css | 26 ++++++++++++++++++++++++-- components/WebsiteDetails.js | 18 +++++++++--------- components/WebsiteDetails.module.css | 4 ++-- 5 files changed, 50 insertions(+), 20 deletions(-) diff --git a/components/Dropdown.module.css b/components/Dropdown.module.css index 660ce8f3..b210de2b 100644 --- a/components/Dropdown.module.css +++ b/components/Dropdown.module.css @@ -5,7 +5,7 @@ } .value { - padding: 4px 24px 4px 8px; + padding: 4px 32px 4px 16px; border: 1px solid #b3b3b3; border-radius: 4px; cursor: pointer; @@ -24,12 +24,12 @@ .option { background: #fff; - padding: 4px 8px; + padding: 4px 16px; cursor: pointer; } .option:hover { - background: #eaeaea; + background: #f5f5f5; } .caret { @@ -41,6 +41,6 @@ transform: rotate(45deg); top: -4px; bottom: 0; - right: 8px; + right: 12px; margin: auto; } diff --git a/components/RankingsChart.js b/components/RankingsChart.js index 59f25754..135e58ae 100644 --- a/components/RankingsChart.js +++ b/components/RankingsChart.js @@ -16,7 +16,12 @@ export default function RankingsChart({ }) { const [data, setData] = useState(); - const rankings = useMemo(() => (data && dataFilter ? dataFilter(data) : data), [data]); + const rankings = useMemo(() => { + if (data) { + return (dataFilter ? dataFilter(data) : data).filter((e, i) => i < 10); + } + return []; + }, [data]); const total = useMemo(() => rankings?.reduce((n, { y }) => n + y, 0) || 0, [rankings]); @@ -46,13 +51,16 @@ export default function RankingsChart({
{title}
{heading}
- {rankings.map(({ x, y }, i) => (i <= 10 ? : null))} + {rankings.map(({ x, y }) => ( + + ))} ); } const Row = ({ label, value, total }) => { - const props = useSpring({ width: (value / total) * 100, from: { width: 0 } }); + const pct = total ? (value / total) * 100 : 0; + const props = useSpring({ width: pct, from: { width: 0 } }); const valueProps = useSpring({ y: value, from: { y: 0 } }); return ( diff --git a/components/RankingsChart.module.css b/components/RankingsChart.module.css index 2d3e6f66..11b04ccf 100644 --- a/components/RankingsChart.module.css +++ b/components/RankingsChart.module.css @@ -1,7 +1,19 @@ .container { position: relative; - min-height: 390px; + min-height: 430px; font-size: 14px; + border-left: 1px solid #e1e1e1; + border-top: 1px solid #e1e1e1; + padding: 20px; +} + +.container:first-child { + padding-left: 0; + border-left: 0; +} + +.container:last-child { + padding-right: 0; } .header { @@ -29,6 +41,7 @@ justify-content: space-between; align-items: center; margin-bottom: 5px; + overflow: hidden; } .label { @@ -38,6 +51,14 @@ flex: 2; } +.label:empty { + color: #b3b3b3; +} + +.label:empty:before { + content: 'Unknown'; +} + .value { width: 50px; text-align: right; @@ -49,7 +70,7 @@ width: 50px; color: #6e6e6e; position: relative; - border-left: 1px solid #6e6e6e; + border-left: 1px solid #8e8e8e; padding-left: 10px; } @@ -60,4 +81,5 @@ height: 30px; opacity: 0.1; background: #2680eb; + z-index: -1; } diff --git a/components/WebsiteDetails.js b/components/WebsiteDetails.js index 7a6f1200..73c3006d 100644 --- a/components/WebsiteDetails.js +++ b/components/WebsiteDetails.js @@ -6,7 +6,8 @@ import RankingsChart from './RankingsChart'; import { getDateRange } from '../lib/date'; import styles from './WebsiteDetails.module.css'; -const osFilter = data => data.map(({ x, y }) => ({ x: !x ? 'Unknown' : x, y })); +const pageviewClasses = 'col-md-12 col-lg-6'; +const sessionClasses = 'col-12 col-lg-4'; const urlFilter = data => data.filter(({ x }) => x !== '' && !x.startsWith('#')); @@ -48,7 +49,7 @@ const browsers = { chrome: 'Chrome', 'chromium-webview': 'Chrome (webview)', phantomjs: 'PhantomJS', - crios: 'CriOS', + crios: 'Chrome (iOS)', firefox: 'Firefox', fxios: 'Firefox (iOS)', 'opera-mini': 'Opera Mini', @@ -92,7 +93,7 @@ export default function WebsiteDetails({ websiteId, defaultDateRange = '7day' }) return ( <>
-
+

{data.label}

@@ -102,7 +103,7 @@ export default function WebsiteDetails({ websiteId, defaultDateRange = '7day' }) title="Top URLs" type="url" heading="Views" - className="col-12 col-md-8 col-lg-6" + className={pageviewClasses} websiteId={data.website_id} startDate={startDate} endDate={endDate} @@ -112,7 +113,7 @@ export default function WebsiteDetails({ websiteId, defaultDateRange = '7day' }) title="Top referrers" type="referrer" heading="Views" - className="col-12 col-md-8 col-lg-6" + className={pageviewClasses} websiteId={data.website_id} startDate={startDate} endDate={endDate} @@ -124,7 +125,7 @@ export default function WebsiteDetails({ websiteId, defaultDateRange = '7day' }) title="Browsers" type="browser" heading="Visitors" - className="col-12 col-md-8 col-lg-4" + className={sessionClasses} websiteId={data.website_id} startDate={startDate} endDate={endDate} @@ -134,17 +135,16 @@ export default function WebsiteDetails({ websiteId, defaultDateRange = '7day' }) title="Operating system" type="os" heading="Visitors" - className="col-12 col-md-8 col-lg-4" + className={sessionClasses} websiteId={data.website_id} startDate={startDate} endDate={endDate} - dataFilter={osFilter} />