Skip to content

Commit 559441a

Browse files
fix: fix layout according to screen size
1 parent a96061c commit 559441a

File tree

5 files changed

+37
-36
lines changed

5 files changed

+37
-36
lines changed

components/chat/chat-window.tsx

+3-10
Original file line numberDiff line numberDiff line change
@@ -51,16 +51,9 @@ const ChatWindow: React.FC<ChatWindowProps> = ({ onClose }) => {
5151

5252
return (
5353
<div className="nx-fixed nx-bottom-0 md:nx-bottom-3 nx-right-0 md:nx-right-3 nx-w-full nx-max-w-md dark:nx-bg-[#242630] nx-bg-[#F3F5F8] nx-shadow-xl nx-rounded-xl nx-z-[51] nx-pb-6">
54-
<div className="nx-flex nx-justify-between nx-items-center dark:nx-bg-none nx-bg-gradient-to-b nx-py-3 nx-from-[rgba(95,56,251,0.1)] nx-to-[rgba(208,234,255,0.1)] nx-rounded-xl nx-px-6">
55-
<div className="tooltip">
56-
<div className="nx-p-1 nx-bg-[#5f38fb] nx-font-normal nx-text-sm nx-rounded-md nx-text-white">
57-
Beta
58-
</div>
59-
<div className="tooltip-text nx-p-2">
60-
Our chat agent is in training, and results will improve with use
61-
</div>
62-
</div>
63-
<button onClick={onClose} className="nx-text-[#000D3D]">
54+
<div className="nx-flex nx-justify-between nx-items-center dark:nx-bg-none nx-bg-gradient-to-b nx-from-[rgba(95,56,251,0.1)] nx-to-[rgba(208,234,255,0.1)] nx-rounded-xl nx-px-6">
55+
<h3 className="nx-text-lg nx-font-semibold"></h3>
56+
<button onClick={onClose} className="nx-text-[#000D3D] nx-mt-6">
6457
&#x2715;
6558
</button>
6659
</div>

components/landing-page.tsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,9 @@ function LandingPage() {
315315
</p>
316316
<Products />
317317
</section>
318-
<ChatWithUs />
318+
<div className="nx-hidden md:nx-flex">
319+
<ChatWithUs />
320+
</div>
319321
</section>
320322
);
321323
}

styles/globals.css

+9-23
Original file line numberDiff line numberDiff line change
@@ -5472,28 +5472,14 @@ pre:not([data-theme]) {
54725472
background-color: rgba(52, 52, 52, 0.08) !important;
54735473
}
54745474

5475-
.tooltip {
5476-
position: relative;
5477-
display: inline-block;
5478-
cursor: pointer;
5479-
}
5480-
5481-
.tooltip-text {
5482-
visibility: hidden;
5483-
width: 250px;
5484-
background-color: rgba(239, 244, 255, 1);
5485-
color: rgba(52, 55, 57, 1);
5486-
border-radius: 10px;
5487-
position: absolute;
5488-
bottom: 125%;
5489-
transform: translateX(-50%);
5490-
z-index: 1;
5491-
opacity: 0;
5492-
transition: opacity 0.3s;
5493-
font-size: small;
5475+
@media (max-width: 768px) {
5476+
.show-on-small {
5477+
display: block !important;
5478+
}
54945479
}
54955480

5496-
.tooltip:hover .tooltip-text {
5497-
visibility: visible;
5498-
opacity: 1;
5499-
}
5481+
@media (min-width: 769px) {
5482+
.show-on-small {
5483+
display: none !important;
5484+
}
5485+
}

theme/fetch-ai-docs/components/sidebar.tsx

+19-1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import { renderComponent } from "../utils";
2222
import { Anchor } from "./anchor";
2323
import { Collapse } from "./collapse";
2424
import { WITH_INDEXED_PAGES } from "../constants";
25+
import ChatWithUs from "components/chat/chat-with-us";
2526

2627
const TreeState: Record<string, boolean> = Object.create(null);
2728

@@ -74,6 +75,7 @@ function FolderImpl({ item, anchors }: FolderProps): ReactElement {
7475
const [route] = routeOriginal.split("#");
7576
const active = [route, route + "/"].includes(item.route + "/");
7677
const activeRouteInside = active || route.startsWith(item.route + "/");
78+
const [isMobile, setIsMobile] = useState(false);
7779

7880
const parentLevelRoute = route.split("/");
7981
const currentItemParentRoute = item.route.split("/");
@@ -135,16 +137,29 @@ function FolderImpl({ item, anchors }: FolderProps): ReactElement {
135137
};
136138
});
137139
}
140+
useEffect(() => {
141+
const handleResize = () => {
142+
setIsMobile(window.innerWidth < 1080);
143+
};
144+
145+
handleResize(); // Initial check
146+
window.addEventListener("resize", handleResize);
147+
148+
return () => {
149+
window.removeEventListener("resize", handleResize);
150+
};
151+
}, []);
138152
const isLink = "withIndexPage" in item && item.withIndexPage;
139153
const ComponentToUse = isLink ? Anchor : "button";
140154
if (
141155
currentItemParentRoute[1] == parentLevelRoute[1] ||
142156
(parentLevelRoute[1] == "" && level == 1)
143157
) {
158+
console.log({ isMobile });
144159
return (
145160
<>
146161
<li className={cn({ open, active }, "nx-w-full")}>
147-
{(!isLink || WITH_INDEXED_PAGES.includes(item.title)) && (
162+
{(isMobile || !isLink || WITH_INDEXED_PAGES.includes(item.title)) && (
148163
<ComponentToUse
149164
id={`sidebar${item.route?.split("/").join("-").toLowerCase()}`}
150165
href={isLink ? item.route : undefined}
@@ -479,6 +494,9 @@ export function Sidebar({
479494
</div>
480495
</OnFocusItemContext.Provider>
481496
</FocusedItemContext.Provider>
497+
<div className="show-on-small">
498+
<ChatWithUs />
499+
</div>
482500
</aside>
483501
</div>
484502
</>

theme/fetch-ai-docs/index.tsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,9 @@ const Body = ({
178178
headings: structuredHeadings,
179179
})}
180180
</article>
181-
<ChatWithUs />
181+
<div className="nx-hidden md:nx-flex">
182+
<ChatWithUs />
183+
</div>
182184
</>
183185
);
184186
};

0 commit comments

Comments
 (0)