Skip to content

Commit 6f1eb26

Browse files
committed
fix: optimize print mode
Signed-off-by: Innei <i@innei.in>
1 parent c7efc67 commit 6f1eb26

File tree

16 files changed

+48
-13
lines changed

16 files changed

+48
-13
lines changed

apps/renderer/src/modules/entry-column/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@ function EntryColumnImpl() {
201201

202202
return (
203203
<div
204+
data-hide-in-print
204205
className="relative flex h-full flex-1 flex-col @container"
205206
onClick={() =>
206207
navigate({

apps/renderer/src/modules/entry-content/components/EntryPlaceholderLogo.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export const EntryPlaceholderLogo = () => {
1313

1414
return (
1515
<div
16+
data-hide-in-print
1617
onContextMenu={stopPropagation}
1718
className={cn(
1819
"flex w-full min-w-0 flex-col items-center justify-center gap-1 px-12 pb-6 text-center text-lg font-medium text-zinc-400 duration-500",

apps/renderer/src/modules/entry-content/components/EntryReadHistory.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,10 @@ export const EntryReadHistory: Component<{ entryId: string }> = ({ entryId }) =>
6565
if (!entryHistory.userIds) return null
6666

6767
return (
68-
<div className="hidden items-center duration-200 animate-in fade-in @md:flex">
68+
<div
69+
className="hidden items-center duration-200 animate-in fade-in @md:flex"
70+
data-hide-in-print
71+
>
6972
{entryHistory.userIds
7073
.filter((id) => id !== me?.id)
7174
.slice(0, LIMIT)

apps/renderer/src/modules/entry-content/components/SourceContentView.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ export const SourceContentPanel = ({ src }: { src: string | null }) => {
8383
<AnimatePresence>
8484
{showSourceContent && src && (
8585
<m.div
86+
data-hide-in-print
8687
className="absolute left-0 top-0 z-[1] size-full bg-theme-background"
8788
initial="hidden"
8889
animate="visible"

apps/renderer/src/modules/entry-content/components/SupportCreator.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ export const SupportCreator = ({ entryId }: { entryId: string }) => {
3939

4040
return (
4141
<>
42-
<Divider />
42+
<Divider data-hide-in-print />
4343

44-
<div className="my-16 flex flex-col items-center gap-8">
44+
<div className="my-16 flex flex-col items-center gap-8" data-hide-in-print>
4545
{feed.ownerUserId ? (
4646
<UserAvatar
4747
className="w-40 flex-col gap-3 p-0"

apps/renderer/src/modules/entry-content/header.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ function EntryHeaderImpl({
6464

6565
return (
6666
<div
67+
data-hide-in-print
6768
className={cn(
6869
"relative flex min-w-0 items-center justify-between gap-3 overflow-hidden text-lg text-zinc-500 duration-200 zen-mode-macos:ml-margin-macos-traffic-light-x",
6970
shouldShowMeta && "border-b border-border",
@@ -82,7 +83,10 @@ function EntryHeaderImpl({
8283
<EntryReadHistory entryId={entryId} />
8384
</div>
8485
)}
85-
<div className="relative z-10 flex w-full items-center justify-between gap-3">
86+
<div
87+
className="relative z-10 flex w-full items-center justify-between gap-3"
88+
data-hide-in-print
89+
>
8690
<div className="flex min-w-0 shrink grow">
8791
<AnimatePresence>
8892
{shouldShowMeta && (

apps/renderer/src/modules/entry-content/index.tsx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ export const EntryContentRender: Component<{
161161
[entry?.entries.media, data?.entries.media],
162162
)
163163
const customCSS = useUISettingKey("customCSS")
164+
164165
if (!entry) return null
165166

166167
const content = entry?.entries.content ?? data?.entries.content
@@ -200,12 +201,15 @@ export const EntryContentRender: Component<{
200201
compact={compact}
201202
/>
202203

203-
<div className="relative flex size-full flex-col overflow-hidden @container">
204+
<div className="relative flex size-full flex-col overflow-hidden @container print:size-auto print:overflow-visible">
204205
<EntryTimelineSidebar entryId={entry.entries.id} />
205206
<ScrollArea.ScrollArea
206207
mask={false}
207-
rootClassName={cn("h-0 min-w-0 grow overflow-y-auto", className)}
208-
scrollbarClassName="mr-[1.5px]"
208+
rootClassName={cn(
209+
"h-0 min-w-0 grow overflow-y-auto print:h-auto print:overflow-visible",
210+
className,
211+
)}
212+
scrollbarClassName="mr-[1.5px] print:hidden"
209213
viewportClassName="p-5"
210214
ref={scrollerRef}
211215
>
@@ -476,7 +480,7 @@ const ContainerToc: FC = memo(() => {
476480

477481
return (
478482
<RootPortal to={wrappedElement!}>
479-
<div className="group absolute right-[-130px] top-0 h-full w-[100px]">
483+
<div className="group absolute right-[-130px] top-0 h-full w-[100px]" data-hide-in-print>
480484
<div className="sticky top-0">
481485
<Toc
482486
onItemClick={() => {

apps/renderer/src/modules/feed-column/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ export function FeedColumn({ children, className }: PropsWithChildren<{ classNam
143143

144144
return (
145145
<WindowUnderBlur
146+
data-hide-in-print
146147
className={cn(
147148
"relative flex h-full flex-col space-y-3 pt-2.5",
148149

apps/renderer/src/pages/(main)/(layer)/feeds/[feedId]/layout.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ export function Component() {
4343
<div ref={containerRef} className="relative flex min-w-0 grow">
4444
<div
4545
className={cn("h-full shrink-0", inWideMode ? "flex-1" : "border-r", "will-change-[width]")}
46+
data-hide-in-print
4647
style={{
4748
width: position,
4849
}}

apps/renderer/src/pages/(main)/layout.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ const RootContainer = forwardRef<HTMLDivElement, PropsWithChildren>(({ children
214214
"--fo-feed-col-w": `${feedColWidth}px`,
215215
} as any
216216
}
217-
className="relative z-0 flex h-screen overflow-hidden"
217+
className="relative z-0 flex h-screen overflow-hidden print:h-auto print:overflow-auto"
218218
onContextMenu={preventDefault}
219219
>
220220
{children}
@@ -304,6 +304,7 @@ const FeedResponsiveResizerContainer = ({
304304
return (
305305
<>
306306
<div
307+
data-hide-in-print
307308
className={cn(
308309
"shrink-0 overflow-hidden",
309310
"absolute inset-y-0 z-[2]",
@@ -321,6 +322,7 @@ const FeedResponsiveResizerContainer = ({
321322
</div>
322323

323324
<div
325+
data-hide-in-print
324326
className={!isDragging ? "duration-200" : ""}
325327
style={{
326328
width: feedColumnShow ? `${position}px` : 0,

0 commit comments

Comments
 (0)