-
-
Notifications
You must be signed in to change notification settings - Fork 772
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: note left bar dont sticky when scroll out paper
Signed-off-by: Innei <[email protected]>
- Loading branch information
Showing
9 changed files
with
94 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import type { FC } from 'react' | ||
|
||
export const Comments: FC<{ | ||
refId: string | ||
}> = ({ refId }) => { | ||
return ( | ||
<div className="relative mb-[60px] mt-[120px] min-h-[10000px]"> | ||
Comments WIP, RefId: {refId} | ||
</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,34 @@ | ||
'use client' | ||
|
||
import { OnlyDesktop } from '~/components/ui/viewport' | ||
|
||
import { useNoteMainContainerHeight } from './NoteMainContainer' | ||
import { NoteTimeline } from './NoteTimeline' | ||
import { NoteTopicInfo } from './NoteTopicInfo' | ||
|
||
export const NoteLeftSidebar: Component = ({ className }) => { | ||
return ( | ||
<div className={className}> | ||
<AutoHeightOptimize className={className}> | ||
<OnlyDesktop> | ||
<div className="sticky top-[120px] mt-[120px]"> | ||
<div className="sticky top-[120px] mt-[120px] min-h-[300px]"> | ||
<NoteTimeline /> | ||
|
||
<NoteTopicInfo /> | ||
</div> | ||
</OnlyDesktop> | ||
</AutoHeightOptimize> | ||
) | ||
} | ||
|
||
const AutoHeightOptimize: Component = ({ children }) => { | ||
const mainContainerHeight = useNoteMainContainerHeight() | ||
return ( | ||
<div | ||
style={{ | ||
height: mainContainerHeight ? `${mainContainerHeight}px` : 'auto', | ||
}} | ||
> | ||
{children} | ||
</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
'use client' | ||
|
||
import { useEffect, useRef } from 'react' | ||
import { atom, useAtomValue, useSetAtom } from 'jotai' | ||
|
||
import { jotaiStore } from '~/lib/store' | ||
|
||
const noteMainContainerHeightAtom = atom(0) | ||
export const NoteMainContainer: Component = ({ className, children }) => { | ||
const mainRef = useRef<HTMLDivElement>(null) | ||
const setHeight = useSetAtom(noteMainContainerHeightAtom) | ||
useEffect(() => { | ||
if (!mainRef.current) return | ||
// measure the height of the main element | ||
const mainHeight = mainRef.current.offsetHeight | ||
if (mainHeight) setHeight(mainHeight) | ||
|
||
const ob = new ResizeObserver((entries) => { | ||
const mainHeight = (entries[0].target as HTMLElement).offsetHeight | ||
if (mainHeight) setHeight(mainHeight) | ||
}) | ||
ob.observe(mainRef.current) | ||
|
||
return () => { | ||
ob.disconnect() | ||
jotaiStore.set(noteMainContainerHeightAtom, 0) | ||
} | ||
}, []) | ||
|
||
return ( | ||
<main className={className} ref={mainRef}> | ||
{children} | ||
</main> | ||
) | ||
} | ||
|
||
export const useNoteMainContainerHeight = () => | ||
useAtomValue(noteMainContainerHeightAtom) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
571c049
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
springtide – ./
springtide-innei.vercel.app
springtide.vercel.app
springtide-git-main-innei.vercel.app
innei.in