From 94757369a5ec469eae3eccde4a7e0a1d8b951074 Mon Sep 17 00:00:00 2001 From: Sean Edmunds Date: Mon, 9 Sep 2024 14:52:45 -0500 Subject: [PATCH] Mobile view and misc. --- src/pages/homepage/Homepage.tsx | 23 +++++++++++-------- src/pages/homepage/components/AppItem.tsx | 11 +++++---- .../homepage/components/Applications.tsx | 5 ++-- src/pages/homepage/components/Bookmarks.tsx | 5 ++-- src/pages/homepage/components/Header.tsx | 11 ++++++--- src/pages/homepage/components/LinkGroups.tsx | 5 ++-- src/pages/homepage/components/LinkItem.tsx | 10 ++++++-- 7 files changed, 45 insertions(+), 25 deletions(-) diff --git a/src/pages/homepage/Homepage.tsx b/src/pages/homepage/Homepage.tsx index ca171d6..fc13d12 100644 --- a/src/pages/homepage/Homepage.tsx +++ b/src/pages/homepage/Homepage.tsx @@ -21,15 +21,18 @@ export default function Homepage({ theme }: any) { key: 'bookmarkFilter', defaultValue: ['All'], }); + const isMobile = window.matchMedia('(max-width: 600px)').matches; function date() { const currentDate = new Date(); - const dateOptions: Intl.DateTimeFormatOptions = { - weekday: 'long', - year: 'numeric', - month: 'long', - day: 'numeric', - }; - const date = currentDate.toLocaleDateString('en-GB', dateOptions); + const dateOptions: Intl.DateTimeFormatOptions = !isMobile + ? { + weekday: 'long', + year: 'numeric', + month: 'long', + day: 'numeric', + } + : {}; + const date = currentDate.toLocaleDateString('en-US', dateOptions); return date; } function greet(list: any) { @@ -60,9 +63,9 @@ export default function Homepage({ theme }: any) { return ( -
- - +
+ + ('none'); return ( @@ -16,11 +16,14 @@ function AppItem({ url, icon, name }: any) { className={stacks.appItemBox} > diff --git a/src/pages/homepage/components/Applications.tsx b/src/pages/homepage/components/Applications.tsx index 9b2fe50..42e7d37 100644 --- a/src/pages/homepage/components/Applications.tsx +++ b/src/pages/homepage/components/Applications.tsx @@ -4,7 +4,7 @@ import { useQueryAPI } from '../../../hooks/useAPI'; import texts from '../../../styles/Text.module.css'; import AppItem from './AppItem'; -function Applications({ contentType }: any) { +function Applications({ contentType, isMobile }: any) { const { data, isFetching } = useQueryAPI({ endpoint: 'api/apps' }); const [applications, setApplications] = useState([]); useEffect(() => { @@ -28,7 +28,7 @@ function Applications({ contentType }: any) { display: 'grid', gridColumnGap: '5px', gridRowGap: '5px', - gridTemplateColumns: '1fr 1fr 1fr 1fr 1fr 1fr', + gridTemplateColumns: isMobile ? '1fr 1fr 1fr' : '1fr 1fr 1fr 1fr 1fr 1fr', gridTemplateRows: '64px', paddingBottom: 'var(--module-spacing)', }} @@ -45,6 +45,7 @@ function Applications({ contentType }: any) { url={application.url} icon={application.icon} category={application.category} + isMobile={isMobile} /> ); })} diff --git a/src/pages/homepage/components/Bookmarks.tsx b/src/pages/homepage/components/Bookmarks.tsx index 4fccf07..ad3a1e4 100644 --- a/src/pages/homepage/components/Bookmarks.tsx +++ b/src/pages/homepage/components/Bookmarks.tsx @@ -4,7 +4,7 @@ import { useQueryAPI } from '../../../hooks/useAPI'; import texts from '../../../styles/Text.module.css'; import LinkGroups from './LinkGroups'; -function Links({ contentType }: any) { +function Links({ contentType, isMobile }: any) { const { data: linkData, isFetched: linksIsFetched } = useQueryAPI({ endpoint: 'api/links', }); @@ -36,7 +36,7 @@ function Links({ contentType }: any) { flexWrap: 'nowrap', gridColumnGap: '20px', gridRowGap: '0px', - gridTemplateColumns: '1fr 1fr 1fr 1fr 1fr', + gridTemplateColumns: isMobile ? '1fr 1fr' : '1fr 1fr 1fr 1fr 1fr', gridTemplateRows: 'auto', }} > @@ -52,6 +52,7 @@ function Links({ contentType }: any) { links={bookmarks.filter( (bookmark: any) => bookmark.category === category.categoryName, )} + isMobile={isMobile} /> ); } diff --git a/src/pages/homepage/components/Header.tsx b/src/pages/homepage/components/Header.tsx index 6a4bbf3..95b783e 100644 --- a/src/pages/homepage/components/Header.tsx +++ b/src/pages/homepage/components/Header.tsx @@ -2,7 +2,7 @@ import { Stack, Text } from '@mantine/core'; import { useEffect, useState } from 'react'; import { textClasses } from '../../../styles'; -function Header({ greet, date }: any) { +function Header({ greet, date, isMobile }: any) { const [time, setTime] = useState(new Date()); function fixDigits(k: any) { @@ -26,7 +26,7 @@ function Header({ greet, date }: any) { zIndex: '1', clear: 'both', display: 'flex', - flexDirection: 'row', + flexDirection: isMobile ? 'column' : 'row', gap: 0, }} > @@ -36,7 +36,11 @@ function Header({ greet, date }: any) { width: '100%', }} > - + {greet} @@ -47,6 +51,7 @@ function Header({ greet, date }: any) { justifyContent: 'right', width: 'auto', gap: 0, + flexDirection: isMobile ? 'row' : 'column', }} > {category} {links?.map((link: any) => ( - + ))} ); diff --git a/src/pages/homepage/components/LinkItem.tsx b/src/pages/homepage/components/LinkItem.tsx index e1974ee..e044009 100644 --- a/src/pages/homepage/components/LinkItem.tsx +++ b/src/pages/homepage/components/LinkItem.tsx @@ -1,9 +1,15 @@ import { Text } from '@mantine/core'; import texts from '../../../styles/Text.module.css'; -function LinkItem({ link }: any) { +function LinkItem({ link, isMobile }: any) { return ( - + {link.name} );