-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add use cases to homepage (#1415)
Ticket: QuivrHQ/quivr#1416 https://github.com/StanGirard/quivr/assets/63923024/243bb114-9b7f-4b98-b710-df74ee845ecb
- Loading branch information
1 parent
ef13439
commit fc052cd
Showing
15 changed files
with
211 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { useTranslation } from "react-i18next"; | ||
|
||
import { UseCasesListing } from "./components/UseCasesListing/UseCasesListing"; | ||
|
||
export const UseCases = (): JSX.Element => { | ||
const { t } = useTranslation("home"); | ||
|
||
return ( | ||
<div className="p-4 text-white"> | ||
<div className="mb-3"> | ||
<h2 className="text-center text-3xl font-semibold mb-2"> | ||
{t("useCases.title")} | ||
</h2> | ||
<p className="text-center text-lg">{t("useCases.subtitle")}</p> | ||
</div> | ||
<UseCasesListing /> | ||
</div> | ||
); | ||
}; |
60 changes: 60 additions & 0 deletions
60
frontend/app/(home)/components/UseCases/components/UseCasesListing/UseCasesListing.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import { useEffect, useState } from "react"; | ||
import { LuPanelLeft } from "react-icons/lu"; | ||
|
||
import Spinner from "@/lib/components/ui/Spinner"; | ||
import { useDevice } from "@/lib/hooks/useDevice"; | ||
import { cn } from "@/lib/utils"; | ||
|
||
import { UseCaseComponent } from "./components/UseCaseComponent"; | ||
import { casesExamples } from "./data/cases"; | ||
import { UseCase } from "./types"; | ||
|
||
export const UseCasesListing = (): JSX.Element => { | ||
const [cases, setCases] = useState<UseCase[]>([]); | ||
const [selectedCaseId, setSelectedCaseId] = useState<string>(); | ||
const selectedCase = cases.find((c) => c.id === selectedCaseId); | ||
const { isMobile } = useDevice(); | ||
|
||
useEffect(() => { | ||
setCases(casesExamples); | ||
setSelectedCaseId("1"); | ||
}, []); | ||
|
||
if (selectedCaseId === undefined) { | ||
return ( | ||
<div className="flex justify-center"> | ||
<Spinner /> | ||
</div> | ||
); | ||
} | ||
|
||
return ( | ||
<div className="flex grid grid-cols-6 gap-10 flex flex-column items-start"> | ||
<div | ||
className={"col-span-6 md:col-span-2 flex flex-col gap-3 col-span-6"} | ||
> | ||
{cases.map((c) => ( | ||
<div | ||
key={c.id} | ||
onClick={() => !isMobile && setSelectedCaseId(c.id)} | ||
className={cn( | ||
"p-6 rounded-lg cursor-pointer", | ||
selectedCaseId === c.id && | ||
"md:bg-[#7D73A7] md:border-[1px] md:border-[#6752F5]" | ||
)} | ||
> | ||
<h3 className="font-semibold mb-3">{c.name}</h3> | ||
<p>{c.description}</p> | ||
</div> | ||
))} | ||
</div> | ||
|
||
{selectedCase !== undefined && ( | ||
<div className="hidden md:block col-span-4 bg-white rounded-xl p-6 px-10 m-6"> | ||
<LuPanelLeft className="text-black text-xl" /> | ||
<UseCaseComponent discussions={selectedCase.discussions} /> | ||
</div> | ||
)} | ||
</div> | ||
); | ||
}; |
38 changes: 38 additions & 0 deletions
38
...app/(home)/components/UseCases/components/UseCasesListing/components/UseCaseComponent.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { Fragment } from "react"; | ||
import { PiPaperclipFill } from "react-icons/pi"; | ||
|
||
import { UseCase } from "../types"; | ||
|
||
type UseCaseComponentProps = { | ||
discussions: UseCase["discussions"]; | ||
}; | ||
|
||
export const UseCaseComponent = ({ | ||
discussions, | ||
}: UseCaseComponentProps): JSX.Element => { | ||
return ( | ||
<div className="flex flex-col gap-2 text-black"> | ||
{discussions.map((d) => ( | ||
<Fragment key={d.question}> | ||
<div className="flex justify-end"> | ||
<div className="bg-[#9B9B9B] max-w-[75%] bg-opacity-10 p-4 rounded-xl"> | ||
<p>{d.question}</p> | ||
</div> | ||
</div> | ||
<div className="flex"> | ||
<div className="bg-[#E0DDFC] max-w-[75%] rounded-xl p-4"> | ||
<span className="text-[#8F8F8F] text-xs">@Quivr</span> | ||
<p>{d.answer}</p> | ||
</div> | ||
</div> | ||
</Fragment> | ||
))} | ||
<div className="flex mt-1 flex-col w-full shadow-md dark:shadow-primary/25 hover:shadow-xl transition-shadow rounded-xl bg-white dark:bg-black border border-black/10 dark:border-white/25 p-4 mt-10"> | ||
<div className="flex items-center"> | ||
<PiPaperclipFill className="text-3xl" /> | ||
<span className="text-[#BFBFBF]">@Einstein</span> | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
}; |
49 changes: 49 additions & 0 deletions
49
frontend/app/(home)/components/UseCases/components/UseCasesListing/data/cases.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import { UseCase } from "../types"; | ||
|
||
export const casesExamples: UseCase[] = [ | ||
{ | ||
id: "1", | ||
name: "Research and Studies", | ||
description: "Quivr is your indispensable research companion.", | ||
discussions: [ | ||
{ | ||
question: "Can you explain what can Research and Studies do ?", | ||
answer: `Hey there ! First you can upload documents by clicking on “+”. Then you can ask questions to your documents, and interact with them. `, | ||
}, | ||
{ | ||
question: "Cool, and what about brains ? ", | ||
answer: `Brains are like your data base. You can feed a brain with multiple documents and then interact with one brain. You can also talk to Chat GPT by typing @ChatGPT4 `, | ||
}, | ||
], | ||
}, | ||
{ | ||
id: "2", | ||
name: "Legal research", | ||
description: "Your ultimate digital ally in the field of law.", | ||
discussions: [ | ||
{ | ||
question: "Can you explain whar can Legal research do ?", | ||
answer: `Hey there ! First you can upload documents by clicking on “+”. Then you can ask questions to your documents, and interact with them. `, | ||
}, | ||
{ | ||
question: "Cool, and what about brains ? ", | ||
answer: `Brains are like your data base. You can feed a brain with multiple documents and then interact with one brain. You can also talk to Chat GPT by typing @ChatGPT4 `, | ||
}, | ||
], | ||
}, | ||
{ | ||
id: "3", | ||
name: "Sales", | ||
description: "Placeholder", | ||
discussions: [ | ||
{ | ||
question: "Can you explain what can Sales do ?", | ||
answer: `Hey there ! First you can upload documents by clicking on “+”. Then you can ask questions to your documents, and interact with them. `, | ||
}, | ||
{ | ||
question: "Cool, and what about brains ? ", | ||
answer: `Brains are like your data base. You can feed a brain with multiple documents and then interact with one brain. You can also talk to Chat GPT by typing @ChatGPT4 `, | ||
}, | ||
], | ||
}, | ||
]; |
1 change: 1 addition & 0 deletions
1
frontend/app/(home)/components/UseCases/components/UseCasesListing/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from "./UseCasesListing"; |
9 changes: 9 additions & 0 deletions
9
frontend/app/(home)/components/UseCases/components/UseCasesListing/types.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
export type UseCase = { | ||
id: string; | ||
name: string; | ||
description: string; | ||
discussions: { | ||
question: string; | ||
answer: string; | ||
}[]; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from "./UseCasesListing"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,9 @@ | ||
{ | ||
"sign_in": "Sign in", | ||
"sign_up": "Sign up", | ||
"star_us": "Star us on Github" | ||
"star_us": "Star us on Github", | ||
"useCases":{ | ||
"title": "Experience it now.", | ||
"subtitle": "Check our example on using Quivr" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,9 @@ | ||
{ | ||
"sign_in": "Iniciar sesión", | ||
"sign_up": "Registrarse", | ||
"star_us": "Danos una estrella en Github" | ||
"star_us": "Danos una estrella en Github", | ||
"useCases": { | ||
"title": "Experiméntalo ahora.", | ||
"subtitle": "Comprueba nuestro ejemplo de uso de Quivr." | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,9 @@ | ||
{ | ||
"sign_in": "Se connecter", | ||
"sign_up": "S'inscrire", | ||
"star_us": "Étoilez-nous sur Github" | ||
"star_us": "Étoilez-nous sur Github", | ||
"useCases": { | ||
"title": "Expérimentez-le maintenant.", | ||
"subtitle": "Consultez notre exemple d'utilisation de Quivr." | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,9 @@ | ||
{ | ||
"sign_in": "Entrar", | ||
"sign_up": "Cadastrar", | ||
"star_us": "Nos avalie no Github" | ||
"star_us": "Nos avalie no Github", | ||
"useCases": { | ||
"title": "Experimente agora.", | ||
"subtitle": "Confira nosso exemplo de uso do Quivr." | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,9 @@ | ||
{ | ||
"sign_in": "Войти", | ||
"sign_up": "Зарегистрироваться", | ||
"star_us": "Поставьте звезду на Github" | ||
"star_us": "Поставьте звезду на Github", | ||
"useCases": { | ||
"title": "Попробуйте сейчас.", | ||
"subtitle": "Посмотрите наш пример использования Quivr." | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,9 @@ | ||
{ | ||
"sign_in": "登录", | ||
"sign_up": "注册", | ||
"star_us": "在Github上给我们加星" | ||
"star_us": "在Github上给我们加星", | ||
"useCases": { | ||
"title": "立刻体验。", | ||
"subtitle": "查看我们使用 Quivr 的示例。" | ||
} | ||
} |