feat: scroll to main on breadcrumb link
This commit is contained in:
@@ -52,7 +52,7 @@ useUserSettings()
|
|||||||
const { visitRepo } = useVisitRepo({ user: user, repo: repo })
|
const { visitRepo } = useVisitRepo({ user: user, repo: repo })
|
||||||
const { toHTML } = useMarkdown(repo)
|
const { toHTML } = useMarkdown(repo)
|
||||||
const { listenToClick } = useLinks("note-display")
|
const { listenToClick } = useLinks("note-display")
|
||||||
const { stackedNotes } = useRouteQueryStackedNotes()
|
const { stackedNotes, scrollToFocusedNote } = useRouteQueryStackedNotes()
|
||||||
|
|
||||||
const { titles } = useNoteView("note-container")
|
const { titles } = useNoteView("note-container")
|
||||||
|
|
||||||
@@ -96,7 +96,11 @@ onUnmounted(() => {
|
|||||||
<div class="note readme">
|
<div class="note readme">
|
||||||
<header-note v-if="withHeader" class="header" :user="user" :repo="repo" />
|
<header-note v-if="withHeader" class="header" :user="user" :repo="repo" />
|
||||||
<div class="repo-title-breadcrumb">
|
<div class="repo-title-breadcrumb">
|
||||||
{{ repo }}
|
<a
|
||||||
|
class="title-stacked-note-link"
|
||||||
|
@click.prevent="scrollToFocusedNote()"
|
||||||
|
>{{ repo }}</a
|
||||||
|
>
|
||||||
</div>
|
</div>
|
||||||
<div class="repo-title">
|
<div class="repo-title">
|
||||||
<div class="repo-header">
|
<div class="repo-header">
|
||||||
|
|||||||
@@ -266,18 +266,6 @@ $border-color: rgba(18, 19, 58, 0.2);
|
|||||||
right: 1rem;
|
right: 1rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
a.title-stacked-note-link {
|
|
||||||
color: var(--color-base-content);
|
|
||||||
display: block;
|
|
||||||
text-decoration: none;
|
|
||||||
position: sticky;
|
|
||||||
top: 0;
|
|
||||||
|
|
||||||
&:hover {
|
|
||||||
cursor: pointer;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.title-stacked-note {
|
.title-stacked-note {
|
||||||
background-color: var(--color-base-100);
|
background-color: var(--color-base-100);
|
||||||
color: var(--color-base-content);
|
color: var(--color-base-content);
|
||||||
|
|||||||
@@ -20,20 +20,28 @@ export const useRouteQueryStackedNotes = () => {
|
|||||||
const { scrollToNote, isMobile } = useOverlay(false)
|
const { scrollToNote, isMobile } = useOverlay(false)
|
||||||
|
|
||||||
const scrollToFocusedNote = (
|
const scrollToFocusedNote = (
|
||||||
sha: string,
|
sha: string | null = null,
|
||||||
notes: string[] = stackedNotes.value,
|
notes: string[] = stackedNotes.value,
|
||||||
) => {
|
) => {
|
||||||
nextTick(() => {
|
nextTick(() => {
|
||||||
const index = notes.findIndex((noteSHA) => noteSHA === sha)
|
const index = sha ? notes.findIndex((noteSHA) => noteSHA === sha) : 0
|
||||||
|
|
||||||
if (isMobile.value) {
|
if (isMobile.value) {
|
||||||
const element = document.querySelector(`.note-${sha}`) as HTMLElement
|
if (sha) {
|
||||||
const top = (index + 1) * (element?.clientHeight ?? height.value)
|
const element = document.querySelector(`.note-${sha}`) as HTMLElement
|
||||||
scrollToNote(top)
|
const top = (index + 1) * (element?.clientHeight ?? height.value)
|
||||||
|
scrollToNote(top)
|
||||||
|
} else {
|
||||||
|
scrollToNote(0)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
const margin = index * 44
|
if (sha) {
|
||||||
const left = (index + 1) * NOTE_WIDTH - margin
|
const margin = index * 44
|
||||||
scrollToNote(left)
|
const left = (index + 1) * NOTE_WIDTH - margin
|
||||||
|
scrollToNote(left)
|
||||||
|
} else {
|
||||||
|
scrollToNote(0)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -91,6 +91,18 @@ a {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
a.title-stacked-note-link {
|
||||||
|
color: var(--color-base-content);
|
||||||
|
display: block;
|
||||||
|
text-decoration: none;
|
||||||
|
position: sticky;
|
||||||
|
top: 0;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.notyf__toast {
|
.notyf__toast {
|
||||||
border-radius: revert-layer;
|
border-radius: revert-layer;
|
||||||
border: none;
|
border: none;
|
||||||
|
|||||||
Reference in New Issue
Block a user