Skip to content

Commit c02cb1c

Browse files
authored
fix: Fix LCP of app (#30)
* Issue-29: Fix LCP of app Relates to #29 - It fixes accessibility - Fixes LCP, performance increase from 50 to 70% * Fix Text: follow -> share
1 parent 81757f9 commit c02cb1c

File tree

4 files changed

+21
-21
lines changed

4 files changed

+21
-21
lines changed

app/components/Conversation.tsx

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -416,18 +416,6 @@ export default function Conversation(): JSX.Element {
416416
}
417417
}, [chatMessages]);
418418

419-
/**
420-
* loading message (api key)
421-
*/
422-
if (!connection) {
423-
return (
424-
<div className="w-auto h-full items-center flex justify-center">
425-
<Spinner size={"sm"} className="-mt-1 mr-2" />
426-
Connecting...
427-
</div>
428-
);
429-
}
430-
431419
return (
432420
<>
433421
<NextUIProvider className="h-full">
@@ -442,7 +430,7 @@ export default function Conversation(): JSX.Element {
442430
>
443431
<div className="grid grid-cols-12 overflow-x-auto gap-y-2">
444432
{initialLoad ? (
445-
<InitialLoad fn={startConversation} />
433+
<InitialLoad fn={startConversation} connecting={!connection} />
446434
) : (
447435
<>
448436
{chatMessages.length > 0 &&

app/components/InitialLoad.tsx

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,15 @@ import { ExclamationIcon } from "./icons/ExclamationIcon";
22
import { Headphones } from "./Headphones";
33
import { isBrowser, isIOS } from "react-device-detect";
44
import Image from "next/image";
5+
import { Spinner } from "@nextui-org/react";
56

6-
export const InitialLoad = ({ fn }: { fn: () => void }) => {
7+
export const InitialLoad = ({ fn, connecting = true }: { fn: () => void, connecting: boolean }) => {
78
return (
89
<>
910
<div className="col-start-1 col-end-13 sm:col-start-2 sm:col-end-12 md:col-start-3 md:col-end-11 lg:col-start-4 lg:col-end-10 p-3 mb-1/2">
1011
<button
11-
onClick={() => fn()}
12+
disabled={connecting}
13+
onClick={() => !connecting && fn()}
1214
type="button"
1315
className="relative block w-full glass p-6 sm:p-8 lg:p-12 rounded-xl"
1416
>
@@ -25,8 +27,15 @@ export const InitialLoad = ({ fn }: { fn: () => void }) => {
2527
</ul>
2628
</div>
2729
<span className="mt-4 block font-semibold">
28-
<div className="bg-white text-black rounded px-10 py-3 font-semibold sm:w-fit sm:mx-auto">
29-
{isBrowser ? "Click" : "Tap"} here to start
30+
<div className="bg-white text-black rounded px-10 py-3 font-semibold sm:w-fit sm:mx-auto opacity-90">
31+
{connecting ? (
32+
<div className="w-auto h-full items-center flex justify-center opacity-40 cursor-not-allowed">
33+
<Spinner size={"sm"} className="-mt-1 mr-2" />
34+
Connecting...
35+
</div>
36+
) : (
37+
<>{isBrowser ? "Click" : "Tap"} here to start</>
38+
)}
3039
</div>
3140
</span>
3241
<span className="mt-4 block text-sm text-gray-100/70">

app/layout.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export const viewport: Viewport = {
2424
themeColor: "#000000",
2525
initialScale: 1,
2626
width: "device-width",
27-
maximumScale: 1,
27+
// maximumScale: 1, hitting accessability
2828
};
2929

3030
export const metadata: Metadata = {

app/page.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
"use client";
22

3-
import Conversation from "./components/Conversation";
43
import Image from "next/image";
54
import GitHubButton from "react-github-btn";
65

76
export const runtime = "edge";
8-
import * as FullStory from "@fullstory/browser";
7+
import { init } from "@fullstory/browser";
98
import { useEffect } from "react";
109
import { XIcon } from "./components/icons/XIcon";
1110
import { FacebookIcon } from "./components/icons/FacebookIcon";
1211
import { LinkedInIcon } from "./components/icons/LinkedInIcon";
12+
import Conversation from "./components/Conversation";
1313

1414
export default function Home() {
1515
useEffect(() => {
16-
FullStory.init({ orgId: "5HWAN" });
16+
init({ orgId: "5HWAN" });
1717
}, []);
1818

1919
return (
@@ -80,6 +80,7 @@ export default function Home() {
8080

8181
return e.preventDefault();
8282
}}
83+
aria-label="share on twitter"
8384
target="_blank"
8485
>
8586
<XIcon className="mb-1" />
@@ -95,6 +96,7 @@ export default function Home() {
9596

9697
return e.preventDefault();
9798
}}
99+
aria-label="share on Linkedin"
98100
>
99101
<LinkedInIcon className="mb-1" />
100102
</a>
@@ -110,6 +112,7 @@ export default function Home() {
110112
return e.preventDefault();
111113
}}
112114
target="_blank"
115+
aria-label="share on Facebook"
113116
>
114117
<FacebookIcon className="mb-1" />
115118
</a>

0 commit comments

Comments
 (0)