From 4c5d7fd76759360cf8afd9ecfd327a0f4b66db65 Mon Sep 17 00:00:00 2001 From: gautamgambhir97 <140384949+gautamgambhir97@users.noreply.github.com> Date: Tue, 12 Nov 2024 16:37:34 +0530 Subject: [PATCH] feat(misc): update guides main page design (#1037) --- .github/spelling/known_words_corpus.txt | 6 +- components/components.module.css | 177 ++++++++++ components/guide-mdx.tsx | 300 +++++++++++------ pages/concepts.mdx | 319 +++++++----------- pages/examples.mdx | 358 ++++++++++---------- pages/guides.mdx | 42 ++- pages/references.mdx | 422 +++++++++--------------- src/icons/main-page-icons.tsx | 263 +++++++++++++++ src/icons/shared-icons.tsx | 13 +- styles/globals.css | 26 +- 10 files changed, 1182 insertions(+), 744 deletions(-) create mode 100644 components/components.module.css create mode 100644 src/icons/main-page-icons.tsx diff --git a/.github/spelling/known_words_corpus.txt b/.github/spelling/known_words_corpus.txt index 8500b646d..38f45e7ad 100644 --- a/.github/spelling/known_words_corpus.txt +++ b/.github/spelling/known_words_corpus.txt @@ -716,4 +716,8 @@ jupyter streamlit bot screenshots -aws \ No newline at end of file +aws +guidesmdx +agentsicon +ledgericon +asiicon \ No newline at end of file diff --git a/components/components.module.css b/components/components.module.css new file mode 100644 index 000000000..f349774e3 --- /dev/null +++ b/components/components.module.css @@ -0,0 +1,177 @@ +.sectionDetails { + display: flex; + justify-content: space-between; + padding: 8px 24px 8px 16px; + align-items: center; + gap: 2px; + align-self: stretch; + border-radius: 8px; + border: 1px solid #dce2ea; + backdrop-filter: blur(35px); + cursor: pointer; + width: 100%; + color: #000d3d; + font-family: Lexend; + font-size: 16px; + font-style: normal; + font-weight: 400; + line-height: 160%; + letter-spacing: -0.16px; +} + +:is(html[class~="dark"] .sectionDetails) { + border-radius: var(--8, 8px); + background: #2c2e38; + backdrop-filter: blur(35px); + color: #e9e9ea; + border: none; +} + +:is(html[class~="dark"] .sectionDetails:hover) { + background: rgba(95, 56, 251, 0.2); + backdrop-filter: blur(35px); + color: #bfaffd; +} + +.sectionDetails:hover { + background: #efebff; + backdrop-filter: blur(35px); + color: #5f38fb; + border: 1px solid #ffff; +} + +.iconContainer { + display: flex; + width: 54px; + height: 54px; + padding: 11px 11.123px 11px 11.124px; + justify-content: center; + align-items: center; + border-radius: 8px; + background: #f3f5f8; +} + +.heading { + color: var(--Cold-Grey-Grey500-Coolgrey, #8a9fb8); + font-family: Lexend; + font-size: 16px; + font-style: normal; + font-weight: 500; + line-height: 150%; + letter-spacing: -0.32px; + text-transform: uppercase; +} + +:is(html[class~="dark"] .heading) { + color: #a6a7ab; +} + +.dropDownGuide { + display: flex; + width: 280px; + height: 44px; + padding: 12px; + justify-content: space-between; + align-items: center; + flex-shrink: 0; + border-radius: 8px; + border: 1px solid #d0d9e3; + cursor: pointer; +} + +:is(html[class~="dark"] .dropDownGuide) { + border-radius: 8px; + border: 1px solid var(--Dark-Mode-White-20, #4d4f57); + background-color: transparent; +} + +.dropdownActive { + color: #0b1742; + font-family: Lexend; + font-size: 14px; + font-style: normal; + font-weight: 400; + line-height: normal; + opacity: 0.6; +} +:is(html[class~="dark"] .dropdownActive) { + color: #d2d3d5; +} + +.inputBoxGuide { + display: flex; + padding: var(--12, 12px) var(--112, 112px) var(--12, 12px) var(--12, 12px); + align-items: center; + gap: var(--6, 6px); + align-self: stretch; + border-radius: 8px; + border: 1px solid var(--Cold-Grey-Grey250, #d0d9e3); + color: #0b1742; + font-family: Lexend; + font-size: 14px; + font-style: normal; + font-weight: 400; + line-height: normal; +} + +:is(html[class~="dark"] .inputBoxGuide) { + background-color: #2c2e38; + border: none; + color: #fff; +} + +.inputGuide:focus-visible { + --tw-ring-shadow: none; + box-shadow: none; + --tw-ring-opacity: 1; + --tw-ring-color: none; + --tw-ring-offset-width: 0; + --tw-ring-offset-color: transparent; +} + +.inputGuide { + outline: none; + border: none; + width: 100%; + background: transparent; +} + +.tab { + display: flex; + padding: 8px; + align-items: center; + gap: 6px; + align-self: stretch; + border-radius: 4px; + width: 100%; +} + +.active { + background: #efebff; + backdrop-filter: blur(35px); + color: #5f38fb; +} + +.tab:hover { + background: #efebff; + backdrop-filter: blur(35px); + color: #5f38fb; + border: 1px solid #ffff; +} + +.label { + display: flex; + height: 24px; + padding: 2px 8px; + align-items: center; + gap: 4px; + border-radius: 4px; + background: #e8ecf1; + color: var(--Secondary-500, #556578); + text-align: center; + font-family: Lexend; + font-size: 14px; + font-style: normal; + font-weight: 400; + line-height: 20px; +} diff --git a/components/guide-mdx.tsx b/components/guide-mdx.tsx index ddabd04d2..95ec73dd7 100644 --- a/components/guide-mdx.tsx +++ b/components/guide-mdx.tsx @@ -1,8 +1,8 @@ -import React, { ChangeEvent, useState } from "react"; -import { GuideBox } from "./feature-guide-tabs"; -import { Grid3 } from "./mdx"; -import styles from "./footer.module.css"; -import { SearchIcon } from "src/icons/shared-icons"; +import React, { ReactNode, useState, ChangeEvent } from "react"; +import { SearchIcon, DropDownArrow } from "src/icons/shared-icons"; +import styles from "./components.module.css"; +import { motion } from "framer-motion"; +import Link from "next/link"; interface Guide { title: string; @@ -15,42 +15,182 @@ interface GuideCategory { description?: string; subSection?: boolean; data: Guide[]; + icon?: () => React.JSX.Element; } interface GuidesData { content: GuideCategory[]; } -const GuideMdx = ({ content }: GuidesData) => { - const [value, setValue] = useState(""); - const [inputVal, setInputVal] = useState(""); - const [evt, setEvt] = useState(""); +const pathLabels = new Map([ + [/\/.*?(quickstart|getting-started).*?\//i, "Beginner"], + [/\/.*?intermediate.*?\//i, "Intermediate"], + [/\/.*?advanced.*?\//i, "Advanced"], +]); - const onSelectChange = (event: ChangeEvent) => { - setEvt(event.target.name); - setValue(event.target.value); +const getPathLabel = (path: string): string => { + for (const [regex, label] of pathLabels) { + if (regex.test(path)) { + return label; + } + } + return ""; +}; + +const SectionHeading = ({ + heading, + icon, +}: { + heading: string; + icon?: () => React.JSX.Element; +}) => ( +
+ {icon && icon()} + {heading} +
+); + +const SectionDetails = ({ + children, + path, +}: { + children: ReactNode; + path: string; +}) => { + const label = getPathLabel(path); + return ( +
+ {children} + {label &&
{label}
} +
+ ); +}; + +const GridBox = ({ children }: { children: ReactNode }) => ( +
+ {children} +
+); + +const FilterDropdown = ({ + content, + value, + onSelectChange, + isOpen, + toggleDropdown, + activeType, +}: { + content: GuideCategory[]; + value: string; + onSelectChange: (selectedType: string) => void; + isOpen: boolean; + toggleDropdown: () => void; + activeType: string; +}) => ( +
+
+ {value} + +
+ {isOpen && ( + +
+
onSelectChange("All Types")} + > + All Types +
+ {content + .map((item) => item.type) + .map((type) => ( +
onSelectChange(type)} + > + {type} +
+ ))} +
+
+ )} +
+); + +const SearchInput = ({ + inputVal, + onInputChange, +}: { + inputVal: string; + onInputChange: (event: ChangeEvent) => void; +}) => ( +
+ + +
+); + +const GuidesMdx = ({ content }: GuidesData) => { + const [filterState, setFilterState] = useState({ + value: "All Types", + inputVal: "", + evt: "", + activeType: "All Types", + openDropdown: false, + }); + + const toggleDropdown = () => + setFilterState((prev) => ({ ...prev, openDropdown: !prev.openDropdown })); + + const onSelectChange = (selectedType: string) => { + setFilterState((prev) => ({ + ...prev, + value: selectedType, + activeType: selectedType, + openDropdown: false, + evt: "select", + })); }; const onInputChange = (event: ChangeEvent) => { - setEvt(event.target.name); - setInputVal(event.target.value); - if (event.target.value === "") { - setEvt("select"); - setValue(value); - } + const { value } = event.target; + setFilterState((prev) => ({ + ...prev, + inputVal: value, + evt: value === "" ? "select" : "input", + })); }; const filteredContent = content .map((con) => ({ ...con, data: con.data.filter((item) => { - if (value !== "" && evt === "select") { - return con.type === value; + if (filterState.evt === "select" && filterState.value !== "All Types") { + return con.type === filterState.value; } - if (inputVal !== "" && evt === "input") { + if (filterState.evt === "input" && filterState.inputVal !== "") { return ( - item.title.toLowerCase().includes(inputVal.toLowerCase()) || - item.description.toLowerCase().includes(inputVal.toLowerCase()) + item.title + .toLowerCase() + .includes(filterState.inputVal.toLowerCase()) || + item.description + .toLowerCase() + .includes(filterState.inputVal.toLowerCase()) ); } return true; @@ -59,80 +199,48 @@ const GuideMdx = ({ content }: GuidesData) => { .filter((con) => con.data.length > 0); return ( -
-
- -
- - -
+ <> +
+ +
- {filteredContent.map((con, index) => ( -
-

- {con.type} - - -

-
{con.description}
- - {con.data - .filter((item) => { - if (inputVal !== "") { - return ( - item.title.toLowerCase().includes(inputVal.toLowerCase()) || - item.description - .toLowerCase() - .includes(inputVal.toLowerCase()) - ); - } - return true; - }) - .map((guide, index) => ( - - ))} - -
- ))} -
+
+ + {filteredContent.map((items, index) => ( +
+ +
+ {items.data.map((item, itemIndex) => ( + + + {item.title} + + + ))} +
+
+ ))} +
+
+ ); }; -export default GuideMdx; +export default GuidesMdx; diff --git a/pages/concepts.mdx b/pages/concepts.mdx index 60e597548..e611762d0 100644 --- a/pages/concepts.mdx +++ b/pages/concepts.mdx @@ -5,197 +5,128 @@ start developing on the uAgents Framework and Agentverse services.
-import { Grid2 } from "../components/mdx"; -import { GuideBox } from "../components/feature-guide-tabs"; - -## Introduction to Fetch.ai - -
- Get to know Fetch.ai, the technology, tools and the goals we are delivering. -
- - - - - - -## Agentverse - -
- Explore the resources and dive into the Agentverse and its functionalities. -
- - - - - - - - - - - - - - - - - - - -## AI Engine - -
- Discover how the AI Engine facilitates interactions by discovering user - preferences, transforming raw data into actionable insights through - collaboration with agent-based services. -
- - - - - - - - - - - - - - -## Fetch network - -
- Discover the tools and products constituting and adopted within the Fetch network. -
- - - - - - - - - - - - - - - -### Ledger - - - - - - - - - - -### Indexer - -
-Explore how to index and query blockchain data efficiently using the SubQuery indexer for the Fetch ledger. - -
- - - - - - - -
+import GuidesMdx from "../components/guide-mdx" +import { AgentsIcon, AgentverseIcon ,FetchNetwork, LedgerIcon} from "src/icons/main-page-icons"; + + + + +
\ No newline at end of file diff --git a/pages/examples.mdx b/pages/examples.mdx index 73b2ecd0a..59be51c6a 100644 --- a/pages/examples.mdx +++ b/pages/examples.mdx @@ -4,179 +4,191 @@ Quick examples of complete Agents to get started quickly. -import ExamplesMdx from "../components/examples-mdx"; +import GuidesMdx from "../components/guide-mdx" +import { AgentsIcon, LedgerIcon, AgentverseIcon} from "src/icons/main-page-icons"; - -
+ icon: AgentverseIcon, + description: "Examples of agent communication and interactions using the Agentverse features.", + data: [ + { + title: "Agents communication with Mailbox", + description: "An example for Agents communication using the Agentverse Mailbox feature.", + path: "/examples/intermediate/mailbox-agents" + }, + { + title: "Agents broadcast", + description: "An example showing how to use a custom protocol to make Agents communicate.", + path: "/examples/intermediate/broadcast" + }, + { + title: "Agents Name Service", + description: "An example showing how to set up Agents Name Services.", + path: "/examples/intermediate/name-service" + }, + { + title: "Query an agent using a proxy API", + description: "An example showing how to query an agent using a proxy API.", + path: "/examples/intermediate/on-query-proxy" + } + ] + }, + { + type: "DeltaV", + icon: AgentsIcon, + description: "Examples of DeltaV functions and interactions within the Agentverse framework.", + data: [ + { + title: "Agentverse Functions: register a coin toss function on DeltaV", + description: "An example for a coin toss agent function available on DeltaV.", + path: "/examples/intermediate/coin-toss" + }, + { + title: "Agentverse Functions: register a dice roll function on DeltaV", + description: "An example for a dice roll agent function available on DeltaV.", + path: "/examples/intermediate/dice-roll" + }, + { + title: "Agentverse Functions: register a local agent as a function", + description: "An example for a local AI Agent registered as a function available on DeltaV.", + path: "/examples/local-agent-registration" + }, + { + title: "Hugging face API agent as a function", + description: "An example for an integration of the Hugging Face API with an Agentverse Agent.", + path: "/examples/intermediate/hugging-face-agent" + }, + { + title: "Using News API to build network of Primary and Secondary function in Agentverse", + description: "An example for a news reading agent showing operations with Primary and Secondary functions.", + path: "/examples/intermediate/news-reading-system" + }, + { + title: "Locally Hosted Agent with LangChain Integration", + description: "An example for a locally hosted agent that utilizes LangChain's Etherscan integration.", + path: "/examples/intermediate/local-agent-langchain" + } + ] + }, + { + type: "Agentverse API", + icon: AgentsIcon, + description: "Examples for interacting with Agentverse API for agent and service creation.", + data: [ + { + title: "Agent and Service Creation using APIs", + description: "An example on how to create agents with Agentverse APIs.", + path: "/examples/intermediate/agent-and-function-api" + }, + { + title: "Adding Secrets to Agent using Agentverse APIs", + description: "An example on how to add secrets to Agents with Agentverse APIs.", + path: "/examples/intermediate/agent-secret-api" + } + ] + }, + { + type: "AI-Engine API", + icon: AgentsIcon, + description: "Examples for using AI Engine APIs for various functionalities.", + data: [ + { + title: "AI-Engine Chat API guide", + description: "An example on how to use AI Engine chat APIs.", + path: "/examples/advanced/chat_api_example" + } + ] + }, + { + type: "Dialogue", + icon: AgentsIcon, + description: "Examples for dialogues and conversation management within the DeltaV framework.", + data: [ + { + title: "Open Dialogue Chit-Chat", + description: "An example on how to dialogues with all transitions visible to user.", + path: "/examples/advanced/open-dialogue-chitchat" + }, + { + title: "Predefined Dialogue Chit-Chat", + description: "An example in which dialogue flow is predefined, minimizing the need for manual intervention.", + path: "/examples/advanced/predefined-dialogue-chitchat" + }, + { + title: "DeltaV Dialogue Chit-Chat", + description: "An example on how to use dialogues in DeltaV compatible agents.", + path: "/examples/advanced/deltaV-dialogues" + } + ] + } +]} /> + diff --git a/pages/guides.mdx b/pages/guides.mdx index e611fe745..fc22fd686 100644 --- a/pages/guides.mdx +++ b/pages/guides.mdx @@ -3,11 +3,14 @@
The place where you can find all tutorials and guides needed to familiarise with the concepts and code in a practical way to develop your ideas autonomously.
-import GuideMdx from "../components/guide-mdx" - +]} /> + +
\ No newline at end of file diff --git a/pages/references.mdx b/pages/references.mdx index 79c4dd685..a8b61e90b 100644 --- a/pages/references.mdx +++ b/pages/references.mdx @@ -4,268 +4,166 @@ The place to get yourself around the more technical side of things used as a reference in all other sections of the documentation. -import { Grid2, Grid3 } from "../components/mdx"; +import GuidesMdx from "../components/guide-mdx" import { GuideBox } from "../components/feature-guide-tabs"; - -## Contracts - -
- An overview of the contracts used during development. -
- - - - - - - - -## Agents: uAgents Framework - -
- An overview of the constituting elements of the uAgents Framework needed to carry out effectively tasks and communications between agents. -
- - - - - - - - - - - - -## Fetch Network - -### Ledger - - - - - - - - - - - - - - - - -### CosmPy API - -
- Get started with all the technical information related to the CosmPy library. -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -### Indexer - -
-Explore how to index and query blockchain data efficiently using the SubQuery indexer for the Fetch ledger. -
- - - - - - - - - - - - - - - +import { AgentsIcon, LedgerIcon , AsiIcon} from "src/icons/main-page-icons" + +
diff --git a/src/icons/main-page-icons.tsx b/src/icons/main-page-icons.tsx new file mode 100644 index 000000000..f2f7e2d9b --- /dev/null +++ b/src/icons/main-page-icons.tsx @@ -0,0 +1,263 @@ +import React from "react"; + +export const AgentsIcon = () => { + return ( + + + + + + + + + + ); +}; + +export const AgentverseIcon = () => { + return ( + + + + + + + + + + ); +}; + +export const CliIcon = () => { + return ( + + + + + + + + ); +}; + +export const FetchNetwork = () => { + return ( + + + + + + + ); +}; + +export const AsiIcon = () => { + return ( + + + + + + + + ); +}; + +export const LedgerIcon = () => { + return ( + + + + + + + + ); +}; diff --git a/src/icons/shared-icons.tsx b/src/icons/shared-icons.tsx index b295d29e0..4431af8fc 100644 --- a/src/icons/shared-icons.tsx +++ b/src/icons/shared-icons.tsx @@ -4,6 +4,7 @@ import React, { useState, useEffect } from "react"; import { ThemeMode } from "theme/fetch-ai-docs/helpers"; import systemDiagram from "../svgs/system-diagram.svg"; import darkSystemDiagram from "../svgs/dark-system-diagram.svg"; +import { motion } from "framer-motion"; export const Message = () => { return ( @@ -350,20 +351,26 @@ export const Tick = () => { ); }; -export const DropDownArrow = () => { +interface DropDownArrowProps { + isActive?: boolean; +} + +export const DropDownArrow: React.FC = ({ isActive }) => { return ( - - + ); }; diff --git a/styles/globals.css b/styles/globals.css index 1f3ba9b76..53934a29a 100644 --- a/styles/globals.css +++ b/styles/globals.css @@ -2633,7 +2633,8 @@ span:target + .subheading-anchor:after { display: flex; width: 100%; max-width: 58.5rem; - padding: 32px 32px 0px 32px; + padding: 64px 32px 0px 32px; + margin-inline: auto; } .nextra-scrollbar:hover::-webkit-scrollbar-thumb { @@ -5001,6 +5002,29 @@ div:hover > .\[div\:hover\>\&\]\:nx-opacity-100 { box-shadow: 0px 30px 60px 0px rgba(0, 0, 0, 0.1); } +.dropDownGuide { + display: flex; + width: 400px; + padding: 4px; + flex-direction: column; + align-items: flex-start; + border-radius: 8px; + border: 1px solid #fff; + background: #fff; + box-shadow: 0px 30px 60px 0px rgba(0, 0, 0, 0.1); +} + +:is(html[class~="dark"] .dropDownGuide) { + background: #363841; + border: none; +} + +@media (max-width: 698px) { + .dropDownGuide { + width: 280px; + } +} + :is(html[class~="dark"] .dropDown) { background: #363841; border: none;