Skip to content

Commit 65db810

Browse files
committed
Refactor Dialog width props and remove classnames types
Replaces the Dialog 'width' and 'maxWidth' props with a 'className' prop for width customization, updating usage in Capture and PrintModal components. Removes '@types/classnames' from dependencies as it is no longer needed.
1 parent 8c87e23 commit 65db810

5 files changed

Lines changed: 54 additions & 62 deletions

File tree

pnpm-lock.yaml

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

viewers/snippet/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@
6262
"@rollup/plugin-typescript": "^12.3.0",
6363
"@rollup/plugin-url": "^8.0.1",
6464
"@tailwindcss/postcss": "^4.1.17",
65-
"@types/classnames": "^2.3.1",
6665
"@types/node": "^20.5.4",
6766
"@types/react": "^18.2.0",
6867
"@types/uuid": "^9.0.2",

viewers/snippet/src/components/capture.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,12 @@ export function Capture({ documentId }: CaptureProps) {
7979

8080
return (
8181
<>
82-
<Dialog open={open} onClose={handleClose} width="48rem" title={translate('capture.title')}>
82+
<Dialog
83+
open={open}
84+
onClose={handleClose}
85+
title={translate('capture.title')}
86+
className="md:w-[48rem]"
87+
>
8388
<div className="space-y-6">
8489
<div className="flex justify-center">
8590
{previewUrl && (

viewers/snippet/src/components/print-modal.tsx

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -96,12 +96,14 @@ export function PrintModal({ documentId, isOpen, onClose, onExited }: PrintModal
9696
title={translate('print.title')}
9797
onClose={onClose}
9898
onExited={onExited}
99-
maxWidth="32rem"
99+
className="md:w-[32rem]"
100100
>
101101
<div className="space-y-6">
102102
{/* Pages to print */}
103103
<div>
104-
<label className="text-fg-secondary mb-3 block text-sm font-medium">{translate('print.pages')}</label>
104+
<label className="text-fg-secondary mb-3 block text-sm font-medium">
105+
{translate('print.pages')}
106+
</label>
105107
<div className="space-y-2">
106108
<label className="flex items-center">
107109
<input
@@ -126,7 +128,9 @@ export function PrintModal({ documentId, isOpen, onClose, onExited }: PrintModal
126128
disabled={isLoading}
127129
className="accent-accent mr-2"
128130
/>
129-
<span className="text-fg-primary text-sm">{translate('print.current', {params: {currentPage}})}</span>
131+
<span className="text-fg-primary text-sm">
132+
{translate('print.current', { params: { currentPage } })}
133+
</span>
130134
</label>
131135

132136
<label className="flex items-start">
@@ -140,7 +144,9 @@ export function PrintModal({ documentId, isOpen, onClose, onExited }: PrintModal
140144
className="accent-accent mr-2 mt-0.5"
141145
/>
142146
<div className="flex-1">
143-
<span className="text-fg-primary mb-1 block text-sm">{translate('print.specify')}</span>
147+
<span className="text-fg-primary mb-1 block text-sm">
148+
{translate('print.specify')}
149+
</span>
144150
<input
145151
type="text"
146152
placeholder={translate('print.specifyEG')}
@@ -155,7 +161,7 @@ export function PrintModal({ documentId, isOpen, onClose, onExited }: PrintModal
155161
/>
156162
{selection === 'custom' && customPages.trim() && totalPages > 0 && (
157163
<p className="text-fg-muted mt-1 text-xs">
158-
{translate('print.current', {params: {totalPages}})}
164+
{translate('print.current', { params: { totalPages } })}
159165
</p>
160166
)}
161167
</div>
@@ -173,7 +179,9 @@ export function PrintModal({ documentId, isOpen, onClose, onExited }: PrintModal
173179
disabled={isLoading}
174180
className="accent-accent mr-2"
175181
/>
176-
<span className="text-fg-secondary text-sm font-medium">{translate('print.annotation')}</span>
182+
<span className="text-fg-secondary text-sm font-medium">
183+
{translate('print.annotation')}
184+
</span>
177185
</label>
178186
</div>
179187

viewers/snippet/src/components/ui/dialog.tsx

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/** @jsxImportSource preact */
22
import { h, ComponentChildren } from 'preact';
33
import { useEffect, useRef, useState } from 'preact/hooks';
4+
import { twMerge } from 'tailwind-merge';
45
import { Icon } from './icon';
56
import { Button } from './button';
67

@@ -19,10 +20,6 @@ export interface DialogProps {
1920
className?: string;
2021
/** Whether to show close button */
2122
showCloseButton?: boolean;
22-
/** Maximum width of the dialog */
23-
maxWidth?: string;
24-
/** width of the dialog */
25-
width?: string;
2623
}
2724

2825
export function Dialog({
@@ -33,8 +30,6 @@ export function Dialog({
3330
onExited,
3431
className,
3532
showCloseButton = true,
36-
maxWidth = '32rem',
37-
width,
3833
}: DialogProps) {
3934
const overlayRef = useRef<HTMLDivElement>(null);
4035
const [shouldRender, setShouldRender] = useState(open);
@@ -104,10 +99,11 @@ export function Dialog({
10499
onClick={handleBackdropClick}
105100
>
106101
<div
107-
className={`bg-bg-surface md:border-border-subtle relative flex h-full w-full flex-col transition-all duration-200 md:h-auto md:w-[28rem] md:max-w-[90vw] md:rounded-lg md:border md:shadow-lg ${
108-
isAnimating && open ? 'scale-100 opacity-100' : 'scale-95 opacity-0'
109-
} ${className}`}
110-
style={`${width ? 'width:' + width : ''}`}
102+
className={twMerge(
103+
'bg-bg-surface md:border-border-subtle relative flex h-full w-full flex-col transition-all duration-200 md:h-auto md:w-[28rem] md:max-w-[90vw] md:rounded-lg md:border md:shadow-lg',
104+
isAnimating && open ? 'scale-100 opacity-100' : 'scale-95 opacity-0',
105+
className,
106+
)}
111107
onClick={(e) => e.stopPropagation()}
112108
>
113109
{/* Header */}

0 commit comments

Comments
 (0)