Skip to content

Commit a5de44b

Browse files
committed
feat: update blockquote style for note
Signed-off-by: Innei <[email protected]>
1 parent 29b9cc8 commit a5de44b

File tree

6 files changed

+100
-23
lines changed

6 files changed

+100
-23
lines changed

src/app/notes/[id]/page.module.css

+45
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,51 @@
55
border-bottom: 1px solid #00b8bb41;
66
}
77

8+
blockquote {
9+
& {
10+
.paragraph > span.indent {
11+
margin-left: 0 !important;
12+
}
13+
14+
.paragraph:first-child::first-letter {
15+
float: none;
16+
font-size: 1em;
17+
margin: 0;
18+
}
19+
20+
.paragraph,
21+
blockquote > ph {
22+
padding: 10px 0;
23+
margin: 0;
24+
}
25+
}
26+
27+
margin-left: calc(-3em + 2px);
28+
margin-right: calc(-3em + 2px);
29+
border: none;
30+
31+
line-height: 1.8;
32+
padding: 1em 1em 1em 2em;
33+
outline: none !important;
34+
background: #f5fafd;
35+
font-style: normal;
36+
37+
:global(html[data-theme='dark']) & {
38+
background: theme(colors.base-100);
39+
}
40+
41+
& span::first-letter {
42+
font-size: 1em;
43+
float: none;
44+
}
45+
46+
@media screen and (max-width: 599px) {
47+
margin-left: -1.25em;
48+
margin-right: -1.25em;
49+
padding: 1em 3em;
50+
}
51+
}
52+
853
.paragraph:not(:nth-child(1)) > span.indent {
954
&:nth-child(1) {
1055
margin-left: 2rem;

src/app/notes/[id]/page.tsx

+5-5
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import { useNoteByNidQuery, useNoteData } from '~/hooks/data/use-note'
2525
import { mood2icon, weather2icon } from '~/lib/meta-icon'
2626
import { ArticleElementProvider } from '~/providers/article/article-element-provider'
2727
import { MarkdownImageRecordProvider } from '~/providers/article/markdown-image-record-provider'
28-
import { useSetCurrentNoteId } from '~/providers/note/current-note-id-provider'
28+
import { CurrentNoteIdProvider, useSetCurrentNoteId } from '~/providers/note/current-note-id-provider'
2929
import { NoteLayoutRightSidePortal } from '~/providers/note/right-side-provider'
3030
import { parseDate } from '~/utils/datetime'
3131
import { springScrollToTop } from '~/utils/scroller'
@@ -70,7 +70,7 @@ const PageImpl = () => {
7070
}`
7171

7272
return (
73-
<>
73+
<CurrentNoteIdProvider initialNoteId={id}>
7474
<article
7575
className={clsx('prose', styles['with-indent'], styles['with-serif'])}
7676
>
@@ -99,17 +99,17 @@ const PageImpl = () => {
9999
<NoteLayoutRightSidePortal>
100100
<TocAside
101101
className="sticky top-[120px] ml-4 mt-[120px]"
102-
treeClassName="max-h-[calc(100vh-6rem-4.5rem-300px)] h-[calc(100vh-6rem-4.5rem-300px)]"
102+
treeClassName="max-h-[calc(100vh-6rem-4.5rem-300px)] h-[calc(100vh-6rem-4.5rem-300px)] min-h-[120px] relative"
103103
>
104-
<NoteActionAside />
104+
<NoteActionAside className="translate-y-full" />
105105
</TocAside>
106106
<TocAutoScroll />
107107
</NoteLayoutRightSidePortal>
108108
</ArticleElementProvider>
109109
</article>
110110
{!!note.topic && <NoteTopic topic={note.topic} />}
111111
<XLogInfoForNote />
112-
</>
112+
</CurrentNoteIdProvider>
113113
)
114114
}
115115

src/components/widgets/note/NoteActionAside.tsx

+8-2
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,17 @@ import { toast } from '~/lib/toast'
1313
import { urlBuilder } from '~/lib/url-builder'
1414
import { useAggregationData } from '~/providers/root/aggregation-data-provider'
1515
import { queries } from '~/queries/definition'
16+
import { clsxm } from '~/utils/helper'
1617
import { apiClient } from '~/utils/request'
1718

18-
export const NoteActionAside = () => {
19+
export const NoteActionAside: Component = ({ className }) => {
1920
return (
20-
<div className="absolute bottom-0 max-h-[300px] flex-col space-y-4">
21+
<div
22+
className={clsxm(
23+
'absolute bottom-0 max-h-[300px] flex-col space-y-4',
24+
className,
25+
)}
26+
>
2127
<LikeButton />
2228
<ShareButton />
2329
</div>

src/components/widgets/toc/Toc.tsx

+3-13
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,8 @@ export const TocAside: Component<TocAsideProps> = ({
9191
rootDepth={rootDepth}
9292
containerRef={containerRef}
9393
className={clsxm('absolute max-h-[75vh]', treeClassName)}
94-
>
95-
{children}
96-
</TocTree>
94+
/>
95+
{children}
9796
</aside>
9897
)
9998
}
@@ -104,15 +103,7 @@ const TocTree: Component<{
104103
setActiveId: (id: string | null) => void
105104
rootDepth: number
106105
containerRef: React.MutableRefObject<HTMLUListElement | null>
107-
}> = ({
108-
toc,
109-
activeId,
110-
setActiveId,
111-
rootDepth,
112-
containerRef,
113-
className,
114-
children,
115-
}) => {
106+
}> = ({ toc, activeId, setActiveId, rootDepth, containerRef, className }) => {
116107
const handleScrollTo = useCallback(
117108
(i: number, $el: HTMLElement | null, anchorId: string) => {
118109
if ($el) {
@@ -143,7 +134,6 @@ const TocTree: Component<{
143134
/>
144135
)
145136
})}
146-
{children}
147137
</ul>
148138
)
149139
}

src/components/widgets/xlog/XLogSummary.tsx

+6
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { useQuery } from '@tanstack/react-query'
22
import type { FC, SVGProps } from 'react'
33

44
import { AutoResizeHeight } from '~/components/common/AutoResizeHeight'
5+
import { useIsClient } from '~/hooks/common/use-is-client'
56
import { useNoteData } from '~/hooks/data/use-note'
67
import { clsxm } from '~/utils/helper'
78
import { apiClient } from '~/utils/request'
@@ -30,6 +31,11 @@ const XLogSummary: FC<{
3031
},
3132
)
3233

34+
const isClient = useIsClient()
35+
if (!isClient) {
36+
return null
37+
}
38+
3339
if (!cid) {
3440
return null
3541
}
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,36 @@
11
'use client'
22

3-
import { createContextState } from 'foxact/context-state'
3+
import { createContext, useContext, useState } from 'react'
4+
import type { Dispatch, FC, PropsWithChildren, SetStateAction } from 'react'
45

5-
export const [CurrentNoteIdProvider, useCurrentNoteId, useSetCurrentNoteId] =
6-
createContextState<undefined | string>(undefined)
6+
// export const [CurrentNoteIdProvider, useCurrentNoteId, useSetCurrentNoteId] =
7+
// createContextState<undefined | string>(undefined)
8+
9+
const CurrentNoteIdContext = createContext(undefined as undefined | string)
10+
11+
const SetCurrentNoteIdContext = createContext<
12+
Dispatch<SetStateAction<string | undefined>>
13+
>(() => void 0)
14+
15+
const CurrentNoteIdProvider: FC<
16+
{
17+
initialNoteId?: string
18+
} & PropsWithChildren
19+
> = ({ initialNoteId, children }) => {
20+
const [currentNoteId, setCurrentNoteId] = useState(initialNoteId)
21+
return (
22+
<CurrentNoteIdContext.Provider value={currentNoteId}>
23+
<SetCurrentNoteIdContext.Provider value={setCurrentNoteId}>
24+
{children}
25+
</SetCurrentNoteIdContext.Provider>
26+
</CurrentNoteIdContext.Provider>
27+
)
28+
}
29+
const useCurrentNoteId = () => {
30+
return useContext(CurrentNoteIdContext)
31+
}
32+
const useSetCurrentNoteId = () => {
33+
return useContext(SetCurrentNoteIdContext)
34+
}
35+
36+
export { useCurrentNoteId, useSetCurrentNoteId, CurrentNoteIdProvider }

0 commit comments

Comments
 (0)