Skip to content

Commit

Permalink
feat: mobile responsivness for zoomed full body and fullchat layouts
Browse files Browse the repository at this point in the history
  • Loading branch information
andrepat0 committed Nov 15, 2024
1 parent eb21b78 commit 0fe2239
Show file tree
Hide file tree
Showing 6 changed files with 507 additions and 157 deletions.
12 changes: 7 additions & 5 deletions src/components/layouts/FullPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,28 +25,30 @@ const FullPageLayout: React.FC<LayoutProps> = ({
{integrationStyle}
{integrationBackground}

<Spin spinning={loading}>
<Spin className="memori-full-body--container" spinning={loading}>
{showInstruct && ChangeMode && changeModeProps && (
<ChangeMode {...changeModeProps} />
)}

{Header && headerProps && <Header {...headerProps} />}
<div className="memori-full-body--header">
{Header && headerProps && <Header {...headerProps} />}
</div>

<div className="memori--grid">
<div className="memori--grid-column memori--grid-column-left">
<div className="memori-full-body-layout--avatar-mobile memori--grid-column memori--grid-column-left">
{Avatar && avatarProps && <Avatar {...avatarProps} />}

<div id="extension" />
</div>
<div className="memori--grid-column memori--grid-column-right">
<div className="memori--grid-column--zoomed-full-body memori-full-body-layout--controls memori--grid-column memori--grid-column-right">
{sessionId && hasUserActivatedSpeak && Chat && chatProps ? (
<Chat {...chatProps} />
) : startPanelProps ? (
<StartPanel {...startPanelProps} />
) : null}
</div>

{poweredBy}
<div className="memori--powered-by-custom">{poweredBy}</div>
</div>
</Spin>
</>
Expand Down
58 changes: 50 additions & 8 deletions src/components/layouts/ZoomedFullBody.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,36 +21,78 @@ const ZoomedFullBodyLayout: React.FC<LayoutProps> = ({
loading = false,
poweredBy,
}) => {

useEffect(() => {
// Prevent body scrolling
document.body.style.overflow = 'hidden';
return () => {
document.body.style.overflow = '';

// Touch focus handler for chat bubbles
const handleBubbleTouch = (e: any) => {
const bubble = e.target.closest('.memori-chat--bubble');
if (bubble) {
// Remove focus from other bubbles
document.querySelectorAll('.memori-chat--bubble.focused').forEach(other => {
if (other !== bubble) {
other.classList.remove('focused');
}
});
bubble.classList.add('focused');
// Prevent any default touch behaviors
e.stopPropagation();
}
};

// Handle clicking outside to remove focus
const handleOutsideTouch = (e: any) => {
const chatContainer = e.target.closest('.memori-full-body-layout--controls');
const bubble = e.target.closest('.memori-chat--bubble');

if (chatContainer && !bubble) {
document.querySelectorAll('.memori-chat--bubble.focused').forEach(bubble => {
bubble.classList.remove('focused');
});
}
};
}, []);

// Add event listeners
const chatContainer = document.querySelector('.memori-full-body-layout--controls');
if (chatContainer) {
chatContainer.addEventListener('touchstart', handleBubbleTouch, { passive: true });
document.addEventListener('touchstart', handleOutsideTouch, { passive: true });
}

// Cleanup function
return () => {
document.body.style.overflow = '';
if (chatContainer) {
chatContainer.removeEventListener('touchstart', handleBubbleTouch);
document.removeEventListener('touchstart', handleOutsideTouch);
}
};
}, []); // Empty dependency array since we only want this to run once on mount

return (
<>
{integrationStyle}
{integrationBackground}

<Spin className="memori-spin--zoomed-full-body" spinning={loading}>
<Spin className="memori-full-body--container" spinning={loading}>
{showInstruct && ChangeMode && changeModeProps && (
<ChangeMode {...changeModeProps} />
)}

{Header && headerProps && <Header {...headerProps} />}
<div className="memori-full-body--header">
{Header && headerProps && <Header {...headerProps} />}
</div>

<div className="memori--grid">
<div className="memori--grid-column memori--grid-column-left">
<div className="memori-full-body-layout--avatar-mobile memori--grid-column memori--grid-column-left ">
{Avatar && avatarProps && (
<Avatar chatProps={chatProps} isZoomed {...avatarProps} />
)}

<div id="extension" />
</div>
<div className="memori--grid-column memori--grid-column--zoomed-full-body memori--grid-column-right">
<div className="memori--grid-column--zoomed-full-body memori-full-body-layout--controls memori--grid-column memori--grid-column-right ">
{sessionId && hasUserActivatedSpeak && Chat && chatProps ? (
<Chat {...chatProps} />
) : startPanelProps ? (
Expand Down
168 changes: 88 additions & 80 deletions src/components/layouts/__snapshots__/FullPage.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -36,74 +36,48 @@ exports[`renders FullPage layout unchanged 1`] = `
/>
</div>
<div
class="memori-spin"
class="memori-spin memori-full-body--container"
>
<div
class="memori-header"
class="memori-full-body--header"
>
<div
class="memori-export-history-button memori-header--button memori-header--button--export"
data-headlessui-state=""
title="Vuoi esportare la cronologia chat?"
class="memori-header"
>
<button
class="memori-button memori-button--circle memori-button--icon-only memori-button--disabled"
<div
class="memori-export-history-button memori-header--button memori-header--button--export"
data-headlessui-state=""
disabled=""
id="headlessui-popover-button-:r0:"
type="button"
title="Vuoi esportare la cronologia chat?"
>
<div
class="memori-button--icon"
<button
class="memori-button memori-button--circle memori-button--icon-only memori-button--disabled"
data-headlessui-state=""
disabled=""
id="headlessui-popover-button-:r0:"
type="button"
>
<svg
aria-hidden="true"
focusable="false"
role="img"
viewBox="0 0 1024 1024"
xmlns="http://www.w3.org/2000/svg"
<div
class="memori-button--icon"
>
<path
d="M464 512a48 48 0 1096 0 48 48 0 10-96 0zm200 0a48 48 0 1096 0 48 48 0 10-96 0zm-400 0a48 48 0 1096 0 48 48 0 10-96 0zm661.2-173.6c-22.6-53.7-55-101.9-96.3-143.3a444.35 444.35 0 00-143.3-96.3C630.6 75.7 572.2 64 512 64h-2c-60.6.3-119.3 12.3-174.5 35.9a445.35 445.35 0 00-142 96.5c-40.9 41.3-73 89.3-95.2 142.8-23 55.4-34.6 114.3-34.3 174.9A449.4 449.4 0 00112 714v152a46 46 0 0046 46h152.1A449.4 449.4 0 00510 960h2.1c59.9 0 118-11.6 172.7-34.3a444.48 444.48 0 00142.8-95.2c41.3-40.9 73.8-88.7 96.5-142 23.6-55.2 35.6-113.9 35.9-174.5.3-60.9-11.5-120-34.8-175.6zm-151.1 438C704 845.8 611 884 512 884h-1.7c-60.3-.3-120.2-15.3-173.1-43.5l-8.4-4.5H188V695.2l-4.5-8.4C155.3 633.9 140.3 574 140 513.7c-.4-99.7 37.7-193.3 107.6-263.8 69.8-70.5 163.1-109.5 262.8-109.9h1.7c50 0 98.5 9.7 144.2 28.9 44.6 18.7 84.6 45.6 119 80 34.3 34.3 61.3 74.4 80 119 19.4 46.2 29.1 95.2 28.9 145.8-.6 99.6-39.7 192.9-110.1 262.7z"
/>
</svg>
</div>
</button>
</div>
<button
class="memori-button memori-button--primary memori-button--circle memori-button--padded memori-button--icon-only memori-header--button memori-header--button-settings"
title="Impostazioni"
>
<span
class="memori-button--icon"
>
<svg
aria-hidden="true"
focusable="false"
role="img"
viewBox="0 0 1024 1024"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M924.8 625.7l-65.5-56c3.1-19 4.7-38.4 4.7-57.8s-1.6-38.8-4.7-57.8l65.5-56a32.03 32.03 0 009.3-35.2l-.9-2.6a443.74 443.74 0 00-79.7-137.9l-1.8-2.1a32.12 32.12 0 00-35.1-9.5l-81.3 28.9c-30-24.6-63.5-44-99.7-57.6l-15.7-85a32.05 32.05 0 00-25.8-25.7l-2.7-.5c-52.1-9.4-106.9-9.4-159 0l-2.7.5a32.05 32.05 0 00-25.8 25.7l-15.8 85.4a351.86 351.86 0 00-99 57.4l-81.9-29.1a32 32 0 00-35.1 9.5l-1.8 2.1a446.02 446.02 0 00-79.7 137.9l-.9 2.6c-4.5 12.5-.8 26.5 9.3 35.2l66.3 56.6c-3.1 18.8-4.6 38-4.6 57.1 0 19.2 1.5 38.4 4.6 57.1L99 625.5a32.03 32.03 0 00-9.3 35.2l.9 2.6c18.1 50.4 44.9 96.9 79.7 137.9l1.8 2.1a32.12 32.12 0 0035.1 9.5l81.9-29.1c29.8 24.5 63.1 43.9 99 57.4l15.8 85.4a32.05 32.05 0 0025.8 25.7l2.7.5a449.4 449.4 0 00159 0l2.7-.5a32.05 32.05 0 0025.8-25.7l15.7-85a350 350 0 0099.7-57.6l81.3 28.9a32 32 0 0035.1-9.5l1.8-2.1c34.8-41.1 61.6-87.5 79.7-137.9l.9-2.6c4.5-12.3.8-26.3-9.3-35zM788.3 465.9c2.5 15.1 3.8 30.6 3.8 46.1s-1.3 31-3.8 46.1l-6.6 40.1 74.7 63.9a370.03 370.03 0 01-42.6 73.6L721 702.8l-31.4 25.8c-23.9 19.6-50.5 35-79.3 45.8l-38.1 14.3-17.9 97a377.5 377.5 0 01-85 0l-17.9-97.2-37.8-14.5c-28.5-10.8-55-26.2-78.7-45.7l-31.4-25.9-93.4 33.2c-17-22.9-31.2-47.6-42.6-73.6l75.5-64.5-6.5-40c-2.4-14.9-3.7-30.3-3.7-45.5 0-15.3 1.2-30.6 3.7-45.5l6.5-40-75.5-64.5c11.3-26.1 25.6-50.7 42.6-73.6l93.4 33.2 31.4-25.9c23.7-19.5 50.2-34.9 78.7-45.7l37.9-14.3 17.9-97.2c28.1-3.2 56.8-3.2 85 0l17.9 97 38.1 14.3c28.7 10.8 55.4 26.2 79.3 45.8l31.4 25.8 92.8-32.9c17 22.9 31.2 47.6 42.6 73.6L781.8 426l6.5 39.9zM512 326c-97.2 0-176 78.8-176 176s78.8 176 176 176 176-78.8 176-176-78.8-176-176-176zm79.2 255.2A111.6 111.6 0 01512 614c-29.9 0-58-11.7-79.2-32.8A111.6 111.6 0 01400 502c0-29.9 11.7-58 32.8-79.2C454 401.6 482.1 390 512 390c29.9 0 58 11.6 79.2 32.8A111.6 111.6 0 01624 502c0 29.9-11.7 58-32.8 79.2z"
/>
</svg>
</span>
</button>
<div
class="memori-share-button memori-share-button--align-left"
data-headlessui-state=""
>
<svg
aria-hidden="true"
focusable="false"
role="img"
viewBox="0 0 1024 1024"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M464 512a48 48 0 1096 0 48 48 0 10-96 0zm200 0a48 48 0 1096 0 48 48 0 10-96 0zm-400 0a48 48 0 1096 0 48 48 0 10-96 0zm661.2-173.6c-22.6-53.7-55-101.9-96.3-143.3a444.35 444.35 0 00-143.3-96.3C630.6 75.7 572.2 64 512 64h-2c-60.6.3-119.3 12.3-174.5 35.9a445.35 445.35 0 00-142 96.5c-40.9 41.3-73 89.3-95.2 142.8-23 55.4-34.6 114.3-34.3 174.9A449.4 449.4 0 00112 714v152a46 46 0 0046 46h152.1A449.4 449.4 0 00510 960h2.1c59.9 0 118-11.6 172.7-34.3a444.48 444.48 0 00142.8-95.2c41.3-40.9 73.8-88.7 96.5-142 23.6-55.2 35.6-113.9 35.9-174.5.3-60.9-11.5-120-34.8-175.6zm-151.1 438C704 845.8 611 884 512 884h-1.7c-60.3-.3-120.2-15.3-173.1-43.5l-8.4-4.5H188V695.2l-4.5-8.4C155.3 633.9 140.3 574 140 513.7c-.4-99.7 37.7-193.3 107.6-263.8 69.8-70.5 163.1-109.5 262.8-109.9h1.7c50 0 98.5 9.7 144.2 28.9 44.6 18.7 84.6 45.6 119 80 34.3 34.3 61.3 74.4 80 119 19.4 46.2 29.1 95.2 28.9 145.8-.6 99.6-39.7 192.9-110.1 262.7z"
/>
</svg>
</div>
</button>
</div>
<button
aria-expanded="false"
aria-haspopup="true"
class="memori-button memori-button--circle memori-button--icon-only memori-share-button--button memori-header--button memori-header--button-share memori-button--primary"
data-headlessui-state=""
id="headlessui-menu-button-:r5:"
title="Condividi"
type="button"
class="memori-button memori-button--primary memori-button--circle memori-button--padded memori-button--icon-only memori-header--button memori-header--button-settings"
title="Impostazioni"
>
<div
<span
class="memori-button--icon"
>
<svg
Expand All @@ -114,18 +88,48 @@ exports[`renders FullPage layout unchanged 1`] = `
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M752 664c-28.5 0-54.8 10-75.4 26.7L469.4 540.8a160.68 160.68 0 0 0 0-57.6l207.2-149.9C697.2 350 723.5 360 752 360c66.2 0 120-53.8 120-120s-53.8-120-120-120-120 53.8-120 120c0 11.6 1.6 22.7 4.7 33.3L439.9 415.8C410.7 377.1 364.3 352 312 352c-88.4 0-160 71.6-160 160s71.6 160 160 160c52.3 0 98.7-25.1 127.9-63.8l196.8 142.5c-3.1 10.6-4.7 21.8-4.7 33.3 0 66.2 53.8 120 120 120s120-53.8 120-120-53.8-120-120-120zm0-476c28.7 0 52 23.3 52 52s-23.3 52-52 52-52-23.3-52-52 23.3-52 52-52zM312 600c-48.5 0-88-39.5-88-88s39.5-88 88-88 88 39.5 88 88-39.5 88-88 88zm440 236c-28.7 0-52-23.3-52-52s23.3-52 52-52 52 23.3 52 52-23.3 52-52 52z"
d="M924.8 625.7l-65.5-56c3.1-19 4.7-38.4 4.7-57.8s-1.6-38.8-4.7-57.8l65.5-56a32.03 32.03 0 009.3-35.2l-.9-2.6a443.74 443.74 0 00-79.7-137.9l-1.8-2.1a32.12 32.12 0 00-35.1-9.5l-81.3 28.9c-30-24.6-63.5-44-99.7-57.6l-15.7-85a32.05 32.05 0 00-25.8-25.7l-2.7-.5c-52.1-9.4-106.9-9.4-159 0l-2.7.5a32.05 32.05 0 00-25.8 25.7l-15.8 85.4a351.86 351.86 0 00-99 57.4l-81.9-29.1a32 32 0 00-35.1 9.5l-1.8 2.1a446.02 446.02 0 00-79.7 137.9l-.9 2.6c-4.5 12.5-.8 26.5 9.3 35.2l66.3 56.6c-3.1 18.8-4.6 38-4.6 57.1 0 19.2 1.5 38.4 4.6 57.1L99 625.5a32.03 32.03 0 00-9.3 35.2l.9 2.6c18.1 50.4 44.9 96.9 79.7 137.9l1.8 2.1a32.12 32.12 0 0035.1 9.5l81.9-29.1c29.8 24.5 63.1 43.9 99 57.4l15.8 85.4a32.05 32.05 0 0025.8 25.7l2.7.5a449.4 449.4 0 00159 0l2.7-.5a32.05 32.05 0 0025.8-25.7l15.7-85a350 350 0 0099.7-57.6l81.3 28.9a32 32 0 0035.1-9.5l1.8-2.1c34.8-41.1 61.6-87.5 79.7-137.9l.9-2.6c4.5-12.3.8-26.3-9.3-35zM788.3 465.9c2.5 15.1 3.8 30.6 3.8 46.1s-1.3 31-3.8 46.1l-6.6 40.1 74.7 63.9a370.03 370.03 0 01-42.6 73.6L721 702.8l-31.4 25.8c-23.9 19.6-50.5 35-79.3 45.8l-38.1 14.3-17.9 97a377.5 377.5 0 01-85 0l-17.9-97.2-37.8-14.5c-28.5-10.8-55-26.2-78.7-45.7l-31.4-25.9-93.4 33.2c-17-22.9-31.2-47.6-42.6-73.6l75.5-64.5-6.5-40c-2.4-14.9-3.7-30.3-3.7-45.5 0-15.3 1.2-30.6 3.7-45.5l6.5-40-75.5-64.5c11.3-26.1 25.6-50.7 42.6-73.6l93.4 33.2 31.4-25.9c23.7-19.5 50.2-34.9 78.7-45.7l37.9-14.3 17.9-97.2c28.1-3.2 56.8-3.2 85 0l17.9 97 38.1 14.3c28.7 10.8 55.4 26.2 79.3 45.8l31.4 25.8 92.8-32.9c17 22.9 31.2 47.6 42.6 73.6L781.8 426l6.5 39.9zM512 326c-97.2 0-176 78.8-176 176s78.8 176 176 176 176-78.8 176-176-78.8-176-176-176zm79.2 255.2A111.6 111.6 0 01512 614c-29.9 0-58-11.7-79.2-32.8A111.6 111.6 0 01400 502c0-29.9 11.7-58 32.8-79.2C454 401.6 482.1 390 512 390c29.9 0 58 11.6 79.2 32.8A111.6 111.6 0 01624 502c0 29.9-11.7 58-32.8 79.2z"
/>
</svg>
</div>
</span>
</button>
<div
class="memori-share-button memori-share-button--align-left"
data-headlessui-state=""
>
<button
aria-expanded="false"
aria-haspopup="true"
class="memori-button memori-button--circle memori-button--icon-only memori-share-button--button memori-header--button memori-header--button-share memori-button--primary"
data-headlessui-state=""
id="headlessui-menu-button-:r5:"
title="Condividi"
type="button"
>
<div
class="memori-button--icon"
>
<svg
aria-hidden="true"
focusable="false"
role="img"
viewBox="0 0 1024 1024"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M752 664c-28.5 0-54.8 10-75.4 26.7L469.4 540.8a160.68 160.68 0 0 0 0-57.6l207.2-149.9C697.2 350 723.5 360 752 360c66.2 0 120-53.8 120-120s-53.8-120-120-120-120 53.8-120 120c0 11.6 1.6 22.7 4.7 33.3L439.9 415.8C410.7 377.1 364.3 352 312 352c-88.4 0-160 71.6-160 160s71.6 160 160 160c52.3 0 98.7-25.1 127.9-63.8l196.8 142.5c-3.1 10.6-4.7 21.8-4.7 33.3 0 66.2 53.8 120 120 120s120-53.8 120-120-53.8-120-120-120zm0-476c28.7 0 52 23.3 52 52s-23.3 52-52 52-52-23.3-52-52 23.3-52 52-52zM312 600c-48.5 0-88-39.5-88-88s39.5-88 88-88 88 39.5 88 88-39.5 88-88 88zm440 236c-28.7 0-52-23.3-52-52s23.3-52 52-52 52 23.3 52 52-23.3 52-52 52z"
/>
</svg>
</div>
</button>
</div>
</div>
</div>
<div
class="memori--grid"
>
<div
class="memori--grid-column memori--grid-column-left"
class="memori-full-body-layout--avatar-mobile memori--grid-column memori--grid-column-left"
>
<div
class="memori--avatar-wrapper memori--avatar-readyplayerme"
Expand Down Expand Up @@ -190,7 +194,7 @@ exports[`renders FullPage layout unchanged 1`] = `
/>
</div>
<div
class="memori--grid-column memori--grid-column-right"
class="memori--grid-column--zoomed-full-body memori-full-body-layout--controls memori--grid-column memori--grid-column-right"
>
<div
class="memori--start-panel"
Expand Down Expand Up @@ -390,26 +394,30 @@ exports[`renders FullPage layout unchanged 1`] = `
</div>
</div>
<div
class="memori--powered-by"
class="memori--powered-by-custom"
>
<img
alt=""
src="https://aisuru.com/images/aisuru/logo.png"
/>
<p>
<span
class="sr-only"
>
Powered by
</span>
<a
href="https://memori.ai/it?integrationID=cb3c4776-7f0b-4f97-a773-c32a5d7a3bf1&memori=aisuru.com-username-Memori"
rel="noopener noreferrer"
target="_blank"
>
Memori.AI
</a>
</p>
<div
class="memori--powered-by"
>
<img
alt=""
src="https://aisuru.com/images/aisuru/logo.png"
/>
<p>
<span
class="sr-only"
>
Powered by
</span>
<a
href="https://memori.ai/it?integrationID=cb3c4776-7f0b-4f97-a773-c32a5d7a3bf1&memori=aisuru.com-username-Memori"
rel="noopener noreferrer"
target="_blank"
>
Memori.AI
</a>
</p>
</div>
</div>
</div>
<div
Expand Down
Loading

0 comments on commit 0fe2239

Please sign in to comment.