Skip to content

Commit 442c0d1

Browse files
author
Sviatlana Marozka
committed
feat(chat): add possibility to open graphic at full screen
1 parent cc6fb5b commit 442c0d1

File tree

3 files changed

+17
-7
lines changed

3 files changed

+17
-7
lines changed

apps/chat/src/components/Chat/MessageAttachment.tsx

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -280,9 +280,10 @@ export const MessageAttachment = ({ attachment, isInner }: Props) => {
280280
<div
281281
data-no-context-menu
282282
className={classNames(
283-
'rounded bg-layer-3 px-1 py-2',
283+
'bg-layer-3 rounded px-1 py-2',
284284
isExpanded && 'col-span-1 col-start-1 sm:col-span-2 md:col-span-3',
285-
!isInner && 'border border-secondary',
285+
!isInner && 'border-secondary border',
286+
attachment.openFullScreen && isOpened && 'fixed inset-x-0 top-0 z-40 flex h-full flex-col',
286287
)}
287288
>
288289
<div className="flex items-center gap-3 px-2">
@@ -303,7 +304,7 @@ export const MessageAttachment = ({ attachment, isInner }: Props) => {
303304
</a>
304305
</Tooltip>
305306
) : (
306-
<Icon size={18} className="shrink-0 text-secondary" />
307+
<Icon size={18} className="text-secondary shrink-0" />
307308
)}
308309
</div>
309310
<button
@@ -348,7 +349,7 @@ export const MessageAttachment = ({ attachment, isInner }: Props) => {
348349
height={18}
349350
width={18}
350351
className={classNames(
351-
'shrink-0 text-secondary transition',
352+
'text-secondary shrink-0 transition',
352353
isOpened && 'rotate-180',
353354
)}
354355
/>
@@ -371,7 +372,10 @@ export const MessageAttachment = ({ attachment, isInner }: Props) => {
371372
</div>
372373
{isOpenable && isOpened && (
373374
<div
374-
className="relative mt-2 h-auto w-full overflow-hidden border-t border-tertiary p-3 pt-4 text-sm duration-200"
375+
className={classNames(
376+
'border-tertiary relative mt-2 w-full border-t p-3 pt-4 text-sm duration-200',
377+
attachment.openFullScreen ? 'grow overflow-auto' : 'h-auto overflow-hidden'
378+
)}
375379
ref={anchorRef}
376380
>
377381
{attachment.data && (
@@ -388,7 +392,7 @@ export const MessageAttachment = ({ attachment, isInner }: Props) => {
388392
href={mappedAttachmentReferenceUrl}
389393
target="_blank"
390394
rel="noopener noreferrer"
391-
className="mt-3 block text-accent-primary"
395+
className="text-accent-primary mt-3 block"
392396
>
393397
{t('Reference...')}
394398
</a>

apps/chat/src/components/Plotly/Plotly.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,19 @@ export const PlotlyComponent = memo(
1616
({ plotlyData: { layout, ...data } }: Props) => {
1717
const containerRef = useRef<HTMLDivElement>(null);
1818
const [width, setWidth] = useState(0);
19+
const [height, setHeight] = useState(0);
1920
const [currentLayout, setCurrentLayout] = useState<Partial<Layout>>(layout);
2021

2122
useEffect(() => {
2223
if (!containerRef.current) {
2324
return;
2425
}
2526

27+
const containerHeight = containerRef.current.clientHeight;
28+
const layoutHeight = currentLayout.height && currentLayout.height > containerHeight ? currentLayout.height : containerHeight;
29+
setHeight(layoutHeight);
2630
setWidth(containerRef.current.scrollWidth);
31+
2732
}, []);
2833

2934
const handleRelayout = (newLayout: PlotRelayoutEvent) => {
@@ -35,7 +40,7 @@ export const PlotlyComponent = memo(
3540
<div ref={containerRef} className="size-full">
3641
<Plot
3742
{...data}
38-
layout={{ ...currentLayout, width }}
43+
layout={{ ...currentLayout, width, height }}
3944
onRelayout={handleRelayout}
4045
/>
4146
</div>

libs/shared/src/types/chat.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export interface Attachment {
2323
url?: string;
2424
reference_type?: MIMEType;
2525
reference_url?: string;
26+
openFullScreen?: boolean;
2627
}
2728

2829
export type StageStatus = 'completed' | 'failed' | null;

0 commit comments

Comments
 (0)