Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: different height for frame width #91

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 6 additions & 9 deletions frontend/pages/chat.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,8 @@ import { initializeWebSocketConnection } from "../services/api/api";
import { useRouter } from "next/router";
import notif from "../assets/sounds/notif.mp3";
import notifRecieve from "../assets/sounds/notif-recieve.mp3";
import { AiFillAccountBook } from "react-icons/ai";
import { AiFillCamera } from "react-icons/ai";
// import boxData from "../services/utilities/box-data";
import { BsStarFill } from "react-icons/bs";
import slack from ".././assets/slack.svg";
import mail from ".././assets/mail.svg";
import logo from "../assets/logo.svg";
import Mail from "../components/mail";
import useIsInIframe from "../services/utilities/useInFrame";


import { ChatNavbar } from "../components/chatNavbar";

Expand Down Expand Up @@ -251,9 +245,12 @@ export default function Home() {
localStorage.setItem("chatType", "chatbot"); // write logic to display bot popup
};

const isInIframe = useIsInIframe();


return (
<>
<div className="main text-slate-950 bg-white w-full bg-contain">
<div className={`main text-slate-950 bg-white w-full bg-contain ${isInIframe ? "mt-8" : "mt-0"}`}>
<div className="grid grid-cols-24 w-full h-[98vh] mt-2">
<div className="flex flex-col items-center col-span-7 bg-white max-md:hidden">
<div className="flex flex-col items-center p-2 bg-white-primary rounded-xl w-[95%]">
Expand Down
6 changes: 5 additions & 1 deletion frontend/pages/chat_bot.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ import Mail from "../components/mail";
import ChatbotContainer from "../components/chatbotContainer";
import { leaveChat } from "../services/api/leaveChatApi";
import { useRouter } from "next/router";
import useIsInIframe from "../services/utilities/useInFrame";


import { ChatbotNavbar } from "../components/chatbotNavbar";

Expand Down Expand Up @@ -224,9 +226,11 @@ export default function Home() {
};
}, [router]);

const isInIframe = useIsInIframe();

return (
<>
<div className="main text-slate-950 bg-white w-full bg-contain ">
<div className={`main text-slate-950 bg-white w-full bg-contain ${isInIframe ? "mt-8" : "mt-0"}`}>
<div className="grid grid-cols-24 w-full h-[98vh] mt-2">
<div className="justify-between col-span-7 bg-white rounded-r-xl max-md:hidden">
<div className="flex flex-col items-center p-2 bg-white-primary rounded-xl w-[95%]">
Expand Down
5 changes: 4 additions & 1 deletion frontend/pages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import ChatBot from "../assets/chatbot.svg";
import SlackLogo from "../assets/slack.svg";
import LoginModal from "../components/loginModal";
import ChatBotLoginModal from "../components/chatbotLoginModal";
import useIsInIframe from "../services/utilities/useInFrame";
export default function Home() {
const router = useRouter();
const [isModalOpen, setIsModalOpen] = useState(false);
Expand Down Expand Up @@ -55,9 +56,11 @@ export default function Home() {
openChatBotModal();
};

const isInIframe = useIsInIframe();

return (
<>
<div className="main bg-white w-full bg-contain">
<div className={`main bg-white w-full bg-contain ${isInIframe ? "mt-8" : "0"}`}>
<div className="grid grid-cols-24 w-full mt-2 h-[95vh]">
<div className="flex flex-col items-center col-span-7 bg-white max-md:hidden">
<div className="flex flex-col items-center p-2 bg-white-primary rounded-xl w-[95%]">
Expand Down
6 changes: 5 additions & 1 deletion frontend/pages/private_chat.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ import mail from ".././assets/mail.svg";
import logo from "../assets/logo.svg";
import Mail from "../components/mail";
import { ChatNavbar } from "../components/chatNavbar";
import useIsInIframe from "../services/utilities/useInFrame";


export default function Home() {
const [messages, setMessages] = useState([]);
Expand Down Expand Up @@ -246,9 +248,11 @@ export default function Home() {
};
}, [router]);

const isInFrame = useIsInIframe();

return (
<>
<div className="main text-slate-950 bg- w-full h-screen bg-contain">
<div className={`main text-slate-950 bg- w-full h-screen bg-contain ${isInFrame ? "mt-8" : "mt-0"}`}>
<div className="grid grid-cols-24 w-full h-[98vh] mt-2">
<div className="justify-between flex flex-col items-center col-span-7 bg-white max-md:hidden">
<div className="flex flex-col items-center p-2 bg-white-primary rounded-xl w-[95%]">
Expand Down
13 changes: 13 additions & 0 deletions frontend/services/utilities/useInFrame.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { useEffect, useState } from 'react';

const useIsInIframe = () => {
const [isInIframe, setIsInIframe] = useState(false);

useEffect(() => {
setIsInIframe(window !== window.parent);
}, []);

return isInIframe;
};

export default useIsInIframe;