Skip to content

Commit

Permalink
worked on the skeleton
Browse files Browse the repository at this point in the history
  • Loading branch information
OchiengPaul442 committed Jan 23, 2024
1 parent 57fb107 commit 2e49e1a
Show file tree
Hide file tree
Showing 5 changed files with 274 additions and 18 deletions.
22 changes: 22 additions & 0 deletions platform/public/icons/SideBar/world_Icon.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import React from 'react';

const world_Icon = ({ width, height, fill }) => {
return (
<svg
xmlns='http://www.w3.org/2000/svg'
width={width || 24}
height={height || 24}
viewBox='0 0 24 24'
fill='none'>
<path
d='M15 2.458A9.996 9.996 0 0012 2C6.477 2 2 6.477 2 12s4.477 10 10 10 10-4.477 10-10c0-1.715-.432-3.33-1.193-4.74M17 5.75h.005M10.5 21.888v-2.203a.5.5 0 01.12-.325l2.486-2.9a.5.5 0 00-.131-.76l-2.857-1.632a.499.499 0 01-.186-.187L8.07 10.62a.5.5 0 00-.478-.25l-5.528.492M21 6c0 2.21-2 4-4 6-2-2-4-3.79-4-6a4 4 0 018 0zm-3.75-.25a.25.25 0 11-.5 0 .25.25 0 01.5 0z'
stroke={fill || '#145FFF'}
strokeWidth={1.5}
strokeLinecap='round'
strokeLinejoin='round'
/>
</svg>
);
};

export default world_Icon;
37 changes: 27 additions & 10 deletions platform/src/common/components/Layout/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,18 @@ import { useDispatch, useSelector } from 'react-redux';
import { fetchUserChecklists } from '@/lib/store/services/checklists/CheckData';
import { updateCards } from '@/lib/store/services/checklists/CheckList';
import Head from 'next/head';
import { useRouter } from 'next/router';

const Layout = ({ pageTitle = 'AirQo Analytics', children, topbarTitle, noBorderBottom }) => {
const Layout = ({
pageTitle = 'AirQo Analytics',
children,
topbarTitle,
noBorderBottom,
noTopNav = true,
}) => {
// Constants
const MAX_WIDTH = '(max-width: 1024px)';

const router = useRouter();
const dispatch = useDispatch();
const chartData = useSelector((state) => state.chart);
const userInfo = useSelector((state) => state.login.userInfo);
Expand Down Expand Up @@ -78,6 +85,14 @@ const Layout = ({ pageTitle = 'AirQo Analytics', children, topbarTitle, noBorder

useEffect(fetchData, [dispatch, userInfo]);

useEffect(() => {
if (router.pathname === '/map') {
setCollapsed(true);
} else {
setCollapsed(false);
}
}, [router.pathname]);

useEffect(() => {
localStorage.setItem('collapsed', collapsed);
}, [collapsed]);
Expand Down Expand Up @@ -114,14 +129,16 @@ const Layout = ({ pageTitle = 'AirQo Analytics', children, topbarTitle, noBorder
/>
</div>
<div className='w-full overflow-x-hidden'>
<TopBar
topbarTitle={topbarTitle}
noBorderBottom={noBorderBottom}
toggleDrawer={toggleDrawer}
setToggleDrawer={setToggleDrawer}
collapsed={collapsed}
setCollapsed={setCollapsed}
/>
{noTopNav && (
<TopBar
topbarTitle={topbarTitle}
noBorderBottom={noBorderBottom}
toggleDrawer={toggleDrawer}
setToggleDrawer={setToggleDrawer}
collapsed={collapsed}
setCollapsed={setCollapsed}
/>
)}
{children}
</div>
</div>
Expand Down
15 changes: 7 additions & 8 deletions platform/src/common/components/SideBar/AuthenticatedSidebar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { useWindowSize } from '@/lib/windowSize';
import SideBarItem, { SideBarDropdownItem, SidebarIconItem } from './SideBarItem';
import AirqoLogo from '@/icons/airqo_logo.svg';
import CloseIcon from '@/icons/close_icon';
import WorldIcon from '@/icons/SideBar/world_Icon';
import HomeIcon from '@/icons/SideBar/HomeIcon';
import SettingsIcon from '@/icons/SideBar/SettingsIcon';
import BarChartIcon from '@/icons/SideBar/BarChartIcon';
Expand Down Expand Up @@ -59,8 +60,7 @@ const AuthenticatedSideBar = ({ toggleDrawer, setToggleDrawer, collapsed, setCol
<div
className={`${
size.width >= 1024 ? 'flex' : sideBarDisplayStyle
} bg-white h-[calc(100vh)] lg:relative flex-col justify-between overflow-y-auto border-t-0 border-r-[1px] border-r-grey-750 scrollbar-thin scrollbar-thumb-gray-800 scrollbar-track-gray-200`}
>
} bg-white h-[calc(100vh)] lg:relative flex-col justify-between overflow-y-auto border-t-0 border-r-[1px] border-r-grey-750 scrollbar-thin scrollbar-thumb-gray-800 scrollbar-track-gray-200`}>
<div>
<div className='p-4 justify-between items-center flex'>
<AirqoLogo className='w-[46.56px] h-8 flex flex-col flex-1' />
Expand All @@ -70,8 +70,7 @@ const AuthenticatedSideBar = ({ toggleDrawer, setToggleDrawer, collapsed, setCol
<button
type='button'
className='lg:hidden relative flex items-center justify-end z-10 w-auto focus:outline-none border border-gray-200 rounded-md'
onClick={() => setToggleDrawer(!toggleDrawer)}
>
onClick={() => setToggleDrawer(!toggleDrawer)}>
<CloseIcon />
</button>
</div>
Expand All @@ -87,12 +86,12 @@ const AuthenticatedSideBar = ({ toggleDrawer, setToggleDrawer, collapsed, setCol
Icon={CollocateIcon}
dropdown
toggleMethod={() => setCollocationOpen(!collocationOpen)}
toggleState={collocationOpen}
>
toggleState={collocationOpen}>
<SideBarDropdownItem itemLabel='Overview' itemPath='/collocation/overview' />
<SideBarDropdownItem itemLabel='Collocate' itemPath='/collocation/collocate' />
</SideBarItem>
)}
<SideBarItem label='AirQo map' Icon={WorldIcon} navPath='/map' />
</div>
</div>
<div className='mx-2 mb-3'>
Expand All @@ -105,8 +104,7 @@ const AuthenticatedSideBar = ({ toggleDrawer, setToggleDrawer, collapsed, setCol
<div
className={`${
size.width >= 1024 ? 'flex' : sideBarDisplayStyle
} bg-white h-[calc(100vh)] lg:relative flex-col justify-between overflow-y-auto border-t-0 border-r-[1px] border-r-grey-750 scrollbar-thin scrollbar-thumb-gray-800 scrollbar-track-gray-200`}
>
} bg-white h-[calc(100vh)] lg:relative flex-col justify-between overflow-y-auto border-t-0 border-r-[1px] border-r-grey-750 scrollbar-thin scrollbar-thumb-gray-800 scrollbar-track-gray-200`}>
<div className='flex flex-col items-center justify-center'>
<div className='p-4 justify-between items-center flex'>
<AirqoLogo className='w-[46.56px] h-8 flex flex-col flex-1' />
Expand All @@ -118,6 +116,7 @@ const AuthenticatedSideBar = ({ toggleDrawer, setToggleDrawer, collapsed, setCol
{checkAccess('CREATE_UPDATE_AND_DELETE_NETWORK_DEVICES') && (
<SidebarIconItem IconComponent={CollocateIcon} navPath='/collocation/overview' />
)}
<SidebarIconItem IconComponent={WorldIcon} navPath='/map' />
</div>
</div>
<div className='mx-2 mb-2 flex items-center justify-center'>
Expand Down
5 changes: 5 additions & 0 deletions platform/src/common/styles/global.scss
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ select:focus {
outline: none !important;
}

.custom-scrollbar::-webkit-scrollbar {
display: none;
height: 0;
}

/* Hide the default scrollbar */
::-webkit-scrollbar {
width: 8px;
Expand Down
213 changes: 213 additions & 0 deletions platform/src/pages/map/index.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,213 @@
import React, { useState, useEffect } from 'react';
import Layout from '@/components/Layout';
import CloseIcon from '@/icons/close_icon';
import LocationIcon from '@/icons/LocationIcon';
import SearchIcon from '@/icons/Common/search_md.svg';

const TabSelector = ({ selectedTab, setSelectedTab }) => {
return (
<div className='mt-6'>
<div className='flex flex-row justify-center items-center bg-secondary-neutral-light-25 rounded-md border border-secondary-neutral-light-50 p-1'>
<div
onClick={() => setSelectedTab('locations')}
className={`px-3 py-2 flex justify-center items-center w-full hover:cursor-pointer text-sm font-medium text-secondary-neutral-light-600${
selectedTab === 'locations' ? 'border rounded-md bg-white shadow-sm' : ''
}`}>
Locations
</div>
<div
onClick={() => setSelectedTab('sites')}
className={`px-3 py-2 flex justify-center items-center w-full hover:cursor-pointer text-sm font-medium text-secondary-neutral-light-600${
selectedTab === 'sites' ? 'border rounded-md bg-white shadow-sm' : ''
}`}>
Sites
</div>
<div
onClick={() => setSelectedTab('airqlouds')}
className={`px-3 py-2 flex justify-center items-center w-full hover:cursor-pointer text-sm font-medium text-secondary-neutral-light-600${
selectedTab === 'airqlouds' ? 'border rounded-md bg-white shadow-sm' : ''
}`}>
AirQlouds
</div>
</div>
</div>
);
};

const SearchField = () => {
return (
<div className='w-full flex flex-row items-center justify-start'>
<div className='flex items-center justify-center pl-3 bg-white border h-12 rounded-lg rounded-r-none border-r-0 border-input-light-outline focus:border-input-light-outline'>
<SearchIcon />
</div>
<input
placeholder='Search Villages, Cities or Country'
className='input text-sm text-secondary-neutral-light-800 w-full h-12 ml-0 rounded-lg bg-white border-l-0 rounded-l-none border-input-light-outline focus:border-input-light-outline'
/>
</div>
);
};

const index = () => {
const [location, setLocation] = useState();
const [showSideBar, setShowSideBar] = useState(true);
const [selectedTab, setSelectedTab] = useState('locations');

useEffect(() => {
const handleResize = () => {
if (window.innerWidth < 768) {
setShowSideBar(false);
} else {
setShowSideBar(true);
}
};
window.addEventListener('resize', handleResize);
handleResize();
return () => window.removeEventListener('resize', handleResize);
}, []);

const handleSelectedTab = (tab) => {
setSelectedTab(tab);
};

const handleLocationSelect = () => {
setLocation();
};

const locations = [
{
id: 1,
name: 'Kampala',
country: 'Central, Uganda',
},
{
id: 2,
name: 'Nairobi',
country: 'Central, Kenya',
},
{
id: 3,
name: 'kiambu',
country: 'Eastern, Kenya',
},
{
id: 4,
name: 'Kitgum',
country: 'Northern, Uganda',
},
{
id: 5,
name: 'Kigaali',
country: 'Central, Rwanda',
},
];

const countries = [
{
id: 1,
name: 'Uganda',
flag: null,
},
{
id: 2,
name: 'Kenya',
flag: null,
},
{
id: 3,
name: 'Nigeria',
flag: null,
},
{
id: 4,
name: 'Rwanda',
flag: null,
},
{
id: 5,
name: 'Tanzania',
flag: null,
},
];

return (
<Layout pageTitle='AirQo Map' noTopNav={false}>
<div className='relative flex w-full h-full'>
{showSideBar && (
<div className='w-[280px] md:w-[400px] bg-white shadow-lg shadow-right space-y-4'>
<div className='px-4 pt-4'>
<div className='w-full flex justify-between items-center'>
<div>
<label className='font-medium text-xl'>Map</label>
</div>
<button
className='p-2 border rounded-xl hover:bg-gray-100'
onClick={() => setShowSideBar(!showSideBar)}>
<CloseIcon width={15} height={15} fill={'#6F87A1'} />
</button>
</div>
<p className='text-gray-500 text-sm font-normal w-auto md:w-[316.681px;] mt-6'>
Navigate, Explore, and Understand Air Quality Data with Precision, Right Down to
Your Neighborhood
</p>
<TabSelector selectedTab={selectedTab} setSelectedTab={handleSelectedTab} />
</div>
<hr />
<div className='px-4 space-y-4'>
<SearchField />

<div className='flex justify-between items-center'>
<button className='px-4 py-2 rounded-full bg-blue-500 text-white'>All</button>
<div className='flex space-x-4 overflow-x-auto custom-scrollbar ml-4'>
{countries.map((country) => (
<div className='flex items-center rounded-full bg-gray-100 p-2 space-x-2'>
{/* flags */}
<span>{country.name}</span>
</div>
))}
</div>
</div>
<div className='space-y-2'>
<label className='font-medium text-gray-600 text-sm'>Suggestions</label>
<hr />
<div className='overflow-y-auto'>
{locations.map((location) => (
<div
className='flex flex-row justify-start items-center mb-0.5 text-sm w-full hover:cursor-pointer hover:bg-blue-100 p-2 rounded-lg'
onClick={() => {
handleLocationSelect();
}}>
<div className='p-2 rounded-full bg-gray-100'>
<LocationIcon />
</div>
<div className='ml-3 flex flex-col item-start border-b w-full'>
<span className=' font-normal text-black capitalize text-lg'>
{location.name}
</span>
<span className='font-normal text-gray-500 capitalize text-sm'>
{location.country}
</span>
</div>
</div>
))}
</div>
<hr />
</div>
</div>
</div>
)}
<div className='relative p-4 h-[100vh] flex-grow'>
{!showSideBar && (
<button
className='absolute top-4 left-4 text-red-400'
onClick={() => setShowSideBar(!showSideBar)}>
open
</button>
)}
</div>
</div>
</Layout>
);
};

export default index;

0 comments on commit 2e49e1a

Please sign in to comment.