Skip to content

Commit 0edaf33

Browse files
swap posts cta for users cta
1 parent 7822608 commit 0edaf33

File tree

1 file changed

+20
-16
lines changed

1 file changed

+20
-16
lines changed

src/components/hero/Hero.tsx

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,21 @@ import { useContext } from 'react'
22
import Image from 'next/image'
33
import Link from 'next/link'
44
import { Button } from '@/components/ui/button'
5-
import { ContextTopTenPosts } from '@/context/ContextTopTenPosts'
5+
import { ContextTopUsers } from '@/context/ContextTopUsers'
66
import heroLogo from '@/assets/hero_logo.webp'
77

88
const Hero = () => {
9-
const contextTopTenPosts = useContext(ContextTopTenPosts)
10-
if (!contextTopTenPosts) {
11-
throw new Error(
12-
'Feed must be used within a ContextTopTenPosts.Provider'
13-
)
9+
const contextTopUsers = useContext(ContextTopUsers)
10+
if (!contextTopUsers) {
11+
throw new Error('Hero must be used within a ContextTopUsers.Provider')
1412
}
15-
const topTenPostsRef = contextTopTenPosts
13+
const topTenUsers = contextTopUsers
1614

17-
const handleScrollToTopTenPosts = () => {
18-
if (topTenPostsRef.current) {
15+
const handleScrollToTopUsers = () => {
16+
if (topTenUsers.current) {
1917
const OFFSET = 64
2018
const top =
21-
topTenPostsRef.current.getBoundingClientRect().top +
19+
topTenUsers.current.getBoundingClientRect().top +
2220
window.scrollY -
2321
OFFSET
2422

@@ -70,28 +68,34 @@ const Hero = () => {
7068
It makes use of the{' '}
7169
<strong className="font-mono px-0.5 text-large">
7270
/comments
71+
</strong>
72+
,{' '}
73+
<strong className="font-mono px-0.5 text-large">
74+
/posts
7375
</strong>{' '}
7476
and{' '}
7577
<strong className="font-mono px-0.5 text-large">
7678
/users
7779
</strong>{' '}
7880
routes from JSON Placeholder to fetch and display
79-
comments along with user information in a card format.
81+
comments, and the quote of the day, along with user
82+
information in a card format.
8083
</p>
8184
<p className="text-center p-4 mt-6 outline-4 outline-stone-400/60 rounded-lg">
82-
Check out the top 10 posts of the week right now!
85+
Check out the most active users of the past week right
86+
now!
8387
<Button
8488
asChild
8589
variant="outline"
8690
className="flex m-auto mt-4 px-8 w-fit"
8791
>
8892
<button
8993
className="text-normal"
90-
aria-label="Scroll to Top 10 Posts"
91-
title="Scroll to Top 10 Posts"
92-
onClick={handleScrollToTopTenPosts}
94+
aria-label="Scroll to the most active users"
95+
title="Scroll to the most active users"
96+
onClick={handleScrollToTopUsers}
9397
>
94-
Top 10 Posts
98+
Most Active Users
9599
</button>
96100
</Button>
97101
</p>

0 commit comments

Comments
 (0)