From f535dca7b99347744e71403f2985cad247a137b5 Mon Sep 17 00:00:00 2001 From: Mike Cao Date: Sun, 9 Aug 2020 03:04:48 -0700 Subject: [PATCH] Initial expanded view in details. --- components/Settings.js | 17 ++++-------- components/WebsiteDetails.js | 28 ++++++++++++++++++- components/WebsiteDetails.module.css | 8 ++++++ components/WebsiteList.js | 16 ++++++----- components/charts/QuickButtons.module.css | 3 +- components/charts/RankingsChart.js | 10 ++++++- components/charts/RankingsChart.module.css | 7 ++++- components/common/Button.js | 3 +- components/common/Button.module.css | 12 ++++++-- components/common/Icon.js | 3 +- components/common/Icon.module.css | 5 ++++ components/layout/MenuLayout.js | 32 ++++++++++++++-------- components/layout/MenuLayout.module.css | 2 +- components/layout/PageHeader.module.css | 1 + 14 files changed, 108 insertions(+), 39 deletions(-) diff --git a/components/Settings.js b/components/Settings.js index 09f31c33..f3144f65 100644 --- a/components/Settings.js +++ b/components/Settings.js @@ -1,4 +1,4 @@ -import React from 'react'; +import React, { useState } from 'react'; import Page from 'components/layout/Page'; import MenuLayout from 'components/layout/MenuLayout'; import WebsiteSettings from './WebsiteSettings'; @@ -8,21 +8,16 @@ import { useSelector } from 'react-redux'; export default function Settings() { const user = useSelector(state => state.user); + const [option, setOption] = useState('Websites'); const menuOptions = ['Websites', user.is_admin && 'Accounts', 'Profile']; return ( - - {option => { - if (option === 'Websites') { - return ; - } else if (option === 'Accounts') { - return ; - } else if (option === 'Profile') { - return ; - } - }} + + {option === 'Websites' && } + {option === 'Accounts' && } + {option === 'Profile' && } ); diff --git a/components/WebsiteDetails.js b/components/WebsiteDetails.js index 4d91b7bb..250ed1f7 100644 --- a/components/WebsiteDetails.js +++ b/components/WebsiteDetails.js @@ -9,15 +9,18 @@ import { get } from 'lib/web'; import { browserFilter, urlFilter, refFilter, deviceFilter, countryFilter } from 'lib/filters'; import styles from './WebsiteDetails.module.css'; import PageHeader from './layout/PageHeader'; +import MenuLayout from './layout/MenuLayout'; const pageviewClasses = 'col-md-12 col-lg-6'; const sessionClasses = 'col-12 col-lg-4'; +const menuOptions = ['Pages', 'Referrers', 'Browsers', 'Operating system', 'Devices', 'Countries']; export default function WebsiteDetails({ websiteId, defaultDateRange = '7day' }) { const [data, setData] = useState(); const [chartLoaded, setChartLoaded] = useState(false); const [countryData, setCountryData] = useState(); const [dateRange, setDateRange] = useState(getDateRange(defaultDateRange)); + const [expand, setExpand] = useState(); const { startDate, endDate } = dateRange; async function loadData() { @@ -32,6 +35,14 @@ export default function WebsiteDetails({ websiteId, defaultDateRange = '7day' }) setTimeout(() => setDateRange(values), 300); } + function handleExpand(title) { + setExpand(title); + } + + function handleMenuSelect(title) { + setExpand(title); + } + useEffect(() => { if (websiteId) { loadData(); @@ -55,7 +66,7 @@ export default function WebsiteDetails({ websiteId, defaultDateRange = '7day' }) /> - {chartLoaded && ( + {chartLoaded && !expand && ( <>
@@ -67,6 +78,7 @@ export default function WebsiteDetails({ websiteId, defaultDateRange = '7day' }) startDate={startDate} endDate={endDate} dataFilter={urlFilter} + onExpand={handleExpand} />
@@ -78,6 +90,7 @@ export default function WebsiteDetails({ websiteId, defaultDateRange = '7day' }) startDate={startDate} endDate={endDate} dataFilter={refFilter(data.domain)} + onExpand={handleExpand} />
@@ -91,6 +104,7 @@ export default function WebsiteDetails({ websiteId, defaultDateRange = '7day' }) startDate={startDate} endDate={endDate} dataFilter={browserFilter} + onExpand={handleExpand} />
@@ -101,6 +115,7 @@ export default function WebsiteDetails({ websiteId, defaultDateRange = '7day' }) websiteId={websiteId} startDate={startDate} endDate={endDate} + onExpand={handleExpand} />
@@ -112,6 +127,7 @@ export default function WebsiteDetails({ websiteId, defaultDateRange = '7day' }) startDate={startDate} endDate={endDate} dataFilter={deviceFilter} + onExpand={handleExpand} />
@@ -129,11 +145,21 @@ export default function WebsiteDetails({ websiteId, defaultDateRange = '7day' }) endDate={endDate} dataFilter={countryFilter} onDataLoad={data => setCountryData(data)} + onExpand={handleExpand} /> )} + {expand && ( + + )} ); } diff --git a/components/WebsiteDetails.module.css b/components/WebsiteDetails.module.css index 7e59d7b9..eb787027 100644 --- a/components/WebsiteDetails.module.css +++ b/components/WebsiteDetails.module.css @@ -2,6 +2,14 @@ margin-bottom: 30px; } +.expand { + border-top: 1px solid var(--gray300); +} + +.menu { + font-size: var(--font-size-small); +} + .row { border-top: 1px solid var(--gray300); min-height: 430px; diff --git a/components/WebsiteList.js b/components/WebsiteList.js index 00668673..49cbfa9f 100644 --- a/components/WebsiteList.js +++ b/components/WebsiteList.js @@ -27,13 +27,15 @@ export default function WebsiteList() { {data?.map(({ website_id, name }) => (
- - {name} - +
+ + {name} + +
+
+ +
)} diff --git a/components/charts/RankingsChart.module.css b/components/charts/RankingsChart.module.css index bb060c04..b5b2da97 100644 --- a/components/charts/RankingsChart.module.css +++ b/components/charts/RankingsChart.module.css @@ -1,6 +1,6 @@ .container { position: relative; - min-height: 430px; + min-height: 460px; font-size: var(--font-size-small); padding: 20px 0; display: flex; @@ -90,6 +90,11 @@ transform: translate(-50%, -50%); } +.footer { + display: flex; + justify-content: center; +} + @media only screen and (max-width: 992px) { .container { min-height: auto; diff --git a/components/common/Button.js b/components/common/Button.js index b61f05d3..1f3a1ecb 100644 --- a/components/common/Button.js +++ b/components/common/Button.js @@ -16,8 +16,9 @@ export default function Button({