File tree 2 files changed +18
-1
lines changed
2 files changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -34,6 +34,7 @@ import {
34
34
} from '@/components'
35
35
import { Goal } from './goals'
36
36
import type { GoalResponse } from 'src/pages/[username]'
37
+ import { scrollToContentWithId } from 'src/utils'
37
38
38
39
type LikeData = {
39
40
count : number
@@ -141,7 +142,13 @@ export function HomePageFeedUpdate({
141
142
</ div >
142
143
</ div >
143
144
< div className = "mt-4 flex" >
144
- < button onClick = { ( ) => setGoalId ( ) } className = "hidden lg:block" >
145
+ < button
146
+ onClick = { ( ) => {
147
+ setGoalId ( )
148
+ scrollToContentWithId ( `homepage-update-${ update . id } ` )
149
+ } }
150
+ className = "hidden lg:block"
151
+ >
145
152
< span className = "inline-flex items-center px-2.5 py-0.5 rounded-md text-sm font-medium bg-brand-100 text-brand-800 hover:text-brand-600" >
146
153
🚀 Goal: { goal . title }
147
154
</ span >
Original file line number Diff line number Diff line change 1
1
export const delay = ( ms : number ) => new Promise ( ( res ) => setTimeout ( res , ms ) )
2
+
3
+ export function scrollToContentWithId ( id : string ) {
4
+ const element = document . getElementById ( id )
5
+ if ( ! element ) {
6
+ return
7
+ }
8
+ const yOffset = 80
9
+ const y = element . getBoundingClientRect ( ) . top + window . pageYOffset - yOffset
10
+ window . scrollTo ( { behavior : 'smooth' , top : y } )
11
+ }
You can’t perform that action at this time.
0 commit comments