Skip to content

Commit cc75e1f

Browse files
committed
fix: note head cover cls
Signed-off-by: Innei <i@innei.in>
1 parent e52cb55 commit cc75e1f

5 files changed

Lines changed: 85 additions & 68 deletions

File tree

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@
161161
"tailwind-scrollbar": "3.1.0",
162162
"tailwind-variants": "0.2.1",
163163
"tailwindcss": "^3.4.3",
164+
"tailwindcss-animated": "1.0.1",
164165
"typescript": "5.4.4",
165166
"worker-loader": "3.0.8",
166167
"zx": "7.2.3"

pnpm-lock.yaml

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/components/modules/note/NoteHeadCover.tsx

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import { useLayoutEffect, useState } from 'react'
44
import clsx from 'clsx'
55

6-
import { AutoResizeHeight } from '~/components/modules/shared/AutoResizeHeight'
6+
import { useCurrentNoteDataSelector } from '~/providers/note/CurrentNoteDataProvider'
77

88
function cropImageTo16by9(src: string): Promise<string> {
99
return new Promise((resolve, reject) => {
@@ -63,6 +63,10 @@ export const NoteHeadCover = ({ image }: { image?: string }) => {
6363
}
6464
const NoteHeadCoverImpl = ({ image }: { image: string }) => {
6565
const [imageBlob, setImageBlob] = useState<string | null>(null)
66+
const imageInfo = useCurrentNoteDataSelector((state) =>
67+
state?.data.images?.find((i) => i.src === image),
68+
)
69+
const accentColor = imageInfo?.accent
6670
useLayoutEffect(() => {
6771
let isMounted = true
6872
cropImageTo16by9(image).then((b) => {
@@ -76,30 +80,29 @@ const NoteHeadCoverImpl = ({ image }: { image: string }) => {
7680

7781
return (
7882
<>
79-
{!!imageBlob && (
80-
<div
81-
data-hide-print
82-
className={clsx(
83-
'z-1 absolute inset-x-0',
84-
imageBlob ? 'h-[224px]' : '0',
85-
'top-[-6.5rem] md:top-0',
86-
)}
87-
>
83+
<div
84+
data-hide-print
85+
className={clsx(
86+
'z-1 absolute inset-x-0',
87+
imageBlob || accentColor ? 'h-[224px]' : '0',
88+
'cover-mask-b top-[-6.5rem] md:top-0',
89+
)}
90+
style={{
91+
backgroundColor: accentColor,
92+
}}
93+
>
94+
{!!imageBlob && (
8895
<div
8996
style={{
9097
backgroundImage: `url(${imageBlob})`,
9198
}}
92-
className="cover-mask-b size-full bg-cover bg-center bg-no-repeat"
99+
// eslint-disable-next-line tailwindcss/classnames-order
100+
className="size-full animate-fade bg-cover bg-center bg-no-repeat"
93101
/>
94-
</div>
95-
)}
102+
)}
103+
</div>
96104

97-
<AutoResizeHeight>
98-
<div
99-
data-hide-print
100-
className={clsx(imageBlob ? 'h-[120px]' : 'h-0', 'hidden md:block')}
101-
/>
102-
</AutoResizeHeight>
105+
<div data-hide-print className={clsx('h-[120px]', 'hidden md:block')} />
103106
</>
104107
)
105108
}

src/styles/theme.css

Lines changed: 49 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,55 @@
33
.border-border {
44
@apply border-zinc-900/10 dark:border-zinc-700;
55
}
6+
7+
.mask-both {
8+
mask-image: linear-gradient(
9+
rgba(255, 255, 255, 0) 0%,
10+
rgb(255, 255, 255) 20px,
11+
rgb(255, 255, 255) calc(100% - 20px),
12+
rgba(255, 255, 255, 0) 100%
13+
);
14+
}
15+
.mask-both-lg {
16+
mask-image: linear-gradient(
17+
rgba(255, 255, 255, 0) 0%,
18+
rgb(255, 255, 255) 50px,
19+
rgb(255, 255, 255) calc(100% - 50px),
20+
rgba(255, 255, 255, 0) 100%
21+
);
22+
}
23+
24+
.mask-b {
25+
mask-image: linear-gradient(
26+
rgb(255, 255, 255) calc(100% - 20px),
27+
rgba(255, 255, 255, 0) 100%
28+
);
29+
}
30+
31+
.mask-b-lg {
32+
mask-image: linear-gradient(
33+
rgb(255, 255, 255) calc(100% - 50px),
34+
rgba(255, 255, 255, 0) 100%
35+
);
36+
}
37+
38+
.mask-t {
39+
mask-image: linear-gradient(
40+
rgba(255, 255, 255, 0) 0%,
41+
rgb(255, 255, 255) 20px
42+
);
43+
}
44+
45+
.mask-t-lg {
46+
mask-image: linear-gradient(
47+
rgba(255, 255, 255, 0) 0%,
48+
rgb(255, 255, 255) 50px
49+
);
50+
}
51+
52+
.cover-mask-b {
53+
mask-image: linear-gradient(180deg, #fff -17.19%, #00000000 92.43%);
54+
}
655
}
756

857
@layer components {
@@ -154,55 +203,6 @@
154203
}
155204
}
156205

157-
.mask-both {
158-
mask-image: linear-gradient(
159-
rgba(255, 255, 255, 0) 0%,
160-
rgb(255, 255, 255) 20px,
161-
rgb(255, 255, 255) calc(100% - 20px),
162-
rgba(255, 255, 255, 0) 100%
163-
);
164-
}
165-
.mask-both-lg {
166-
mask-image: linear-gradient(
167-
rgba(255, 255, 255, 0) 0%,
168-
rgb(255, 255, 255) 50px,
169-
rgb(255, 255, 255) calc(100% - 50px),
170-
rgba(255, 255, 255, 0) 100%
171-
);
172-
}
173-
174-
.mask-b {
175-
mask-image: linear-gradient(
176-
rgb(255, 255, 255) calc(100% - 20px),
177-
rgba(255, 255, 255, 0) 100%
178-
);
179-
}
180-
181-
.mask-b-lg {
182-
mask-image: linear-gradient(
183-
rgb(255, 255, 255) calc(100% - 50px),
184-
rgba(255, 255, 255, 0) 100%
185-
);
186-
}
187-
188-
.mask-t {
189-
mask-image: linear-gradient(
190-
rgba(255, 255, 255, 0) 0%,
191-
rgb(255, 255, 255) 20px
192-
);
193-
}
194-
195-
.mask-t-lg {
196-
mask-image: linear-gradient(
197-
rgba(255, 255, 255, 0) 0%,
198-
rgb(255, 255, 255) 50px
199-
);
200-
}
201-
202-
.cover-mask-b {
203-
mask-image: linear-gradient(180deg, #fff -17.19%, #00000000 92.43%);
204-
}
205-
206206
.code-wrap {
207207
white-space: break-spaces !important;
208208
overflow: auto !important;

tailwind.config.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,8 @@ const twConfig: Config = {
299299

300300
require('tailwind-scrollbar'),
301301
require('@tailwindcss/container-queries'),
302+
require('tailwindcss-animated'),
303+
302304
require('./src/styles/theme.css'),
303305
require('./src/styles/uikit.css'),
304306
],

0 commit comments

Comments
 (0)