Skip to content

Commit

Permalink
feat: improve mobile responsive for hero section and
Browse files Browse the repository at this point in the history
  • Loading branch information
juliopavila committed May 7, 2024
1 parent 9ebf947 commit fdd3e68
Show file tree
Hide file tree
Showing 11 changed files with 111 additions and 66 deletions.
2 changes: 1 addition & 1 deletion packages/client/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
<meta name="theme-color" content="#ffffff" />
<link rel="manifest" href="/manifest.json" />
</head>
<body>
<body class="overflow-hidden">
<div id="root"></div>
<div id="modal-root"></div>
<div id="popover-root"></div>
Expand Down
26 changes: 15 additions & 11 deletions packages/client/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,21 @@ const App: React.FC = () => {

return (
<Fragment>
<Navbar />
<Routes>
<Route path='/' element={<Landing />} />
<Route path='/about' element={<About />} />
<Route path='/whitepaper' element={<WhitePaper />} />
<Route path='/daily' element={<DailyPoll />} />
<Route path='/historic' element={<HistoricPoll />} />
<Route path='/result/:roundId' element={<PollResult />} />
<Route path='*' element={<Navigate to='/' replace />} />
</Routes>
<Footer />
<div className='flex min-h-screen flex-col'>
<Navbar />
<div className='flex flex-1 flex-col'>
<Routes>
<Route path='/' element={<Landing />} />
<Route path='/about' element={<About />} />
<Route path='/whitepaper' element={<WhitePaper />} />
<Route path='/daily' element={<DailyPoll />} />
<Route path='/historic' element={<HistoricPoll />} />
<Route path='/result/:roundId' element={<PollResult />} />
<Route path='*' element={<Navigate to='/' replace />} />
</Routes>
</div>
<Footer />
</div>
</Fragment>
)
}
Expand Down
4 changes: 2 additions & 2 deletions packages/client/src/components/Cards/Card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ const Card: React.FC<CardProps> = ({ children, isDetails, checked, onChecked })
return (
<div
className={`
h-full
h-full w-full
cursor-pointer
${isDetails ? ' p-4' : 'h-auto min-h-[288px] p-20'}
${isDetails ? ' p-4' : 'min-h-[144px] p-10 md:min-h-[288px] md:p-20'}
rounded-[24px] bg-white text-black
${!isDetails && 'shadow-md'}
transform
Expand Down
36 changes: 16 additions & 20 deletions packages/client/src/components/Footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,24 @@ import { Link } from 'react-router-dom'

const Footer: React.FC = () => {
return (
<footer className='relative z-10 w-screen border-t-2 border-slate-600/20 bg-slate-200 p-6'>
<div className='mx-auto w-full max-w-screen-xl'>
<div className='flex justify-between gap-4 max-md:flex-col md:items-center md:gap-2'>
<Link to='/whitepaper#' className='duration-300 ease-in-out hover:opacity-70'>
<p className='text-sm font-bold'>CRISP Whitepaper</p>
</Link>
<div className='flex items-center space-x-2'>
<p className='flex items-center space-x-2 text-sm'>Secured with </p>
<img src={EnclaveLogo} className='h-[24] w-auto cursor-pointer duration-300 ease-in-out hover:opacity-70' />
<div className='flex items-center space-x-2'>
<p className='text-sm'>built by</p>
<Link
to='https://www.gnosisguild.org/'
target='_blank'
className='flex items-center space-x-2 duration-300 ease-in-out hover:opacity-70'
>
<p className='text-sm font-bold'> Gnosis Guild</p>
<img src={GnosisGuildLogo} className='h-[24] w-[24]' />
</Link>
<footer className='relative z-10 w-full border-t-2 border-slate-600/20 bg-slate-200 p-6'>
<div className='mx-auto flex w-full max-w-screen-xl flex-col items-center justify-between gap-4 md:flex-row'>
<Link to='/whitepaper#' className='duration-300 ease-in-out hover:opacity-70'>
<p className='text-sm font-bold'>CRISP Whitepaper</p>
</Link>
<Link to='https://www.gnosisguild.org/' target='_blank' className='flex flex-col items-center gap-2 md:flex-row'>
<div className='flex items-center gap-2'>
<p className='text-sm'>Secured with</p>
<img src={EnclaveLogo} className='h-6 w-auto cursor-pointer duration-300 ease-in-out hover:opacity-70' />
</div>
<div className='flex items-center gap-2'>
<p className='text-sm'>built by</p>
<div className='flex items-center gap-2 duration-300 ease-in-out hover:opacity-70'>
<p className='text-sm font-bold'>Gnosis Guild</p>
<img src={GnosisGuildLogo} className='h-6 w-6' />
</div>
</div>
</div>
</Link>
</div>
</footer>
)
Expand Down
37 changes: 21 additions & 16 deletions packages/client/src/components/LoadingAnimation.tsx
Original file line number Diff line number Diff line change
@@ -1,38 +1,43 @@
import { useEffect, useState } from "react"
import CircularTile from "./CircularTile"
import { useEffect, useState } from 'react'
import CircularTile from '@/components/CircularTile'
import { useMediaQuery } from '@/hooks/generic/useMediaQuery'

const LoadingAnimation = ({className, isLoading}: {className?: string; isLoading: boolean}) => {
const [rotations, setRotations] = useState([0, 0, 0, 0]);
const LoadingAnimation = ({ className, isLoading }: { className?: string; isLoading: boolean }) => {
const [rotations, setRotations] = useState([0, 0, 0, 0])

// Determine if the screen width is medium or larger
const isMediumOrLarger = useMediaQuery('(min-width: 768px)')

const getRandRotation = () => {
const rand_index = Math.floor(Math.random() * 4)
const rotation = [0, 90, 180, 270][rand_index]
return rotation;
return rotation
}

useEffect(() => {
const interval = setInterval(() => {
if(isLoading) {
setRotations([getRandRotation(),getRandRotation(),getRandRotation(),getRandRotation()]);
if (isLoading) {
setRotations([getRandRotation(), getRandRotation(), getRandRotation(), getRandRotation()])
}
}, 500);
}, 500)

if(!isLoading) {
if (!isLoading) {
clearInterval(interval)
}

return () => clearInterval(interval);
}, [rotations, isLoading]);
return () => clearInterval(interval)
}, [rotations, isLoading])

// Adjust size based on screen width
const sizeClasses = isMediumOrLarger ? 'w-10 h-10' : 'w-6 h-6'

return (
<div className={`grid grid-cols-2 gap-1 w-10 h-10 ${className}`}>
<div className={`grid grid-cols-2 gap-6 md:gap-1 ${sizeClasses} ${className}`}>
{rotations.map((rotation, i) => {
return (
<CircularTile key={i} className="!fill-slate-600 duration-500 ease-in-out" rotation={rotation}/>
)
return <CircularTile key={i} className='!fill-slate-600 duration-500 ease-in-out' rotation={rotation} />
})}
</div>
)
}

export default LoadingAnimation
export default LoadingAnimation
14 changes: 14 additions & 0 deletions packages/client/src/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,20 @@
@tailwind utilities;
@tailwind components;

body,
html {
margin: 0;
padding: 0;
overflow-x: hidden;
min-height: 100vh;
display: flex;
flex-direction: column;
}

footer {
margin-top: auto;
}

@layer components {
.toast-alert {
@apply translate-x-[-10rem] opacity-0; /* Start off-screen to the left */
Expand Down
24 changes: 24 additions & 0 deletions packages/client/src/hooks/generic/useMediaQuery.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { useEffect, useState } from 'react'

export const useMediaQuery = (query: string): boolean => {
const [matches, setMatches] = useState<boolean>(false)

useEffect(() => {
const media = window.matchMedia(query)
const listener = (event: MediaQueryListEvent) => {
setMatches(event.matches)
}

media.addEventListener('change', listener)

if (media.matches !== matches) {
setMatches(media.matches)
}

return () => {
media.removeEventListener('change', listener)
}
}, [matches, query])

return matches
}
4 changes: 2 additions & 2 deletions packages/client/src/pages/About/About.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import { Link } from 'react-router-dom'

const About: React.FC = () => {
return (
<div className='relative flex w-screen flex-col items-center justify-center px-6 py-28'>
<div className='absolute bottom-0 right-0 grid w-[70vh] grid-cols-2 gap-2'>
<div className='relative flex w-full flex-1 items-center justify-center px-6 py-28'>
<div className='absolute bottom-0 right-0 grid w-full grid-cols-2 gap-2 max-md:opacity-50 md:w-[70vh]'>
<CircularTiles count={4} />
</div>
<div className='relative space-y-12'>
Expand Down
2 changes: 1 addition & 1 deletion packages/client/src/pages/DailyPoll/DailyPoll.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const DailyPoll: React.FC = () => {
const { encryptVote, broadcastVote, getRoundStateLite, existNewRound, votingRound, roundEndDate } = useVoteManagementContext()
const [voteCompleted, setVotedCompleted] = useState<boolean>(false)
const [loading, setLoading] = useState<boolean>(false)
console.log('')

useEffect(() => {
const checkRound = async () => {
await existNewRound()
Expand Down
10 changes: 5 additions & 5 deletions packages/client/src/pages/Landing/components/DailyPoll.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,15 @@ const DailyPollSection: React.FC<DailyPollSectionProps> = ({ onVoted, loading })

return (
<>
<div className='relative flex min-h-screen w-screen flex-col items-center justify-center px-6 py-28'>
<div className='absolute bottom-0 right-0 grid w-[70vh] grid-cols-2 gap-2'>
<div className='relative flex w-full flex-1 items-center justify-center px-6 py-12'>
<div className='absolute bottom-0 right-0 grid w-full grid-cols-2 gap-2 max-md:opacity-50 md:w-[70vh]'>
<CircularTiles count={4} />
</div>

<div className='relative mx-auto flex w-full max-w-screen-md flex-col items-center justify-center space-y-12'>
<div className='relative mx-auto flex w-full max-w-screen-md flex-col items-center justify-center space-y-8'>
<div className='space-y-2'>
<p className='text-center text-sm font-extrabold uppercase text-slate-400'>Daily Poll</p>
<h3 className='font-bold leading-none text-slate-600'>Choose your favorite</h3>
<h3 className='md:text-h3 text-center font-bold leading-none text-slate-600'>Choose your favorite</h3>
</div>
{roundState && (
<div className='flex items-center justify-center space-x-2'>
Expand All @@ -75,7 +75,7 @@ const DailyPollSection: React.FC<DailyPollSectionProps> = ({ onVoted, loading })
{pollOptions.map((poll) => (
<div key={poll.label} className='col-span-2 md:col-span-1'>
<Card checked={poll.checked} onChecked={() => handleChecked(poll.value)}>
<p className='inline-block text-8xl leading-none'>{poll.label}</p>
<p className='inline-block text-6xl leading-none md:text-8xl'>{poll.label}</p>
</Card>
</div>
))}
Expand Down
18 changes: 10 additions & 8 deletions packages/client/src/pages/Landing/components/Hero.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,34 +6,36 @@ import { Keyhole, ListMagnifyingGlass, ShieldCheck } from '@phosphor-icons/react

const HeroSection: React.FC = () => {
return (
<div className='relative flex min-h-screen w-screen items-center justify-center px-6'>
<div className='absolute bottom-0 right-0 grid w-[100vw] grid-cols-2 gap-2 max-md:opacity-50 md:w-[70vh]'>
<div className='relative flex w-full flex-1 items-center justify-center px-6'>
<div className='absolute bottom-0 right-0 grid w-full grid-cols-2 gap-2 max-md:opacity-50 md:w-[70vh]'>
<CircularTiles count={4} />
</div>
<div className='relative mx-auto w-full max-w-screen-md space-y-12'>
<div className='space-y-4'>
<h3 className='text-3xl font-normal leading-none text-zinc-400'>Introducing</h3>
<img src={Logo} alt='CRISP Logo' className='h-20' />
<h4 className='w-full text-base leading-none text-slate-800/50'>Collusion-Resistant Impartial Selection Protocol</h4>
<h3 className='font-normal leading-none text-zinc-400 sm:text-xl md:text-3xl'>Introducing</h3>
<img src={Logo} alt='CRISP Logo' className='sm:h-10 md:h-20' />
<h4 className='w-full leading-none text-slate-800/50 sm:text-xs md:text-base'>
Collusion-Resistant Impartial Selection Protocol
</h4>
</div>
<ul className='space-y-3'>
<li className='flex items-start space-x-2 md:items-center'>
<Keyhole className='text-lime-600/80' size={32} />
<div className='text-lg text-zinc-400'>
<div className='text-zinc-400 sm:text-sm md:text-lg'>
<span className='mr-1 font-bold text-lime-600/80'>Private.</span>
Voter privacy through advanced encryption.
</div>
</li>
<li className='flex items-start space-x-2 md:items-center'>
<ListMagnifyingGlass className='text-lime-600/80' size={32} />
<div className='text-lg text-zinc-400'>
<div className='text-zinc-400 sm:text-sm md:text-lg'>
<span className='mr-1 font-bold text-lime-600/80'>Reliable.</span>
Verifiable results while preserving confidentiality.
</div>
</li>
<li className='flex items-start space-x-2 md:items-center'>
<ShieldCheck className='text-lime-600/80' size={32} />
<div className='text-lg text-zinc-400'>
<div className='text-zinc-400 sm:text-sm md:text-lg'>
<span className='mr-1 font-bold text-lime-600/80'>Equitable.</span>
Robust safeguards against collusion and tampering.
</div>
Expand Down

0 comments on commit fdd3e68

Please sign in to comment.