-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(docs) : UX issues in the iota api ref page (#4015)
* Fix UX for iota api ref page * Fix sidenav and codeblocks ui * Add browserify * Add browserify * Remove BrowserOnly component * Add ExecutionEnvironment import statement
- Loading branch information
1 parent
ec67eef
commit edd0332
Showing
7 changed files
with
150 additions
and
116 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
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
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,51 +1,61 @@ | ||
// Copyright (c) Mysten Labs, Inc. | ||
// Modifications Copyright (c) 2024 IOTA Stiftung | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
import React from "react"; | ||
import React, { useState } from "react"; | ||
import Link from "@docusaurus/Link"; | ||
import NetworkSelect from "./networkselect"; | ||
|
||
const RefNav = (props) => { | ||
const { json, apis } = props; | ||
|
||
const { json, apis, openDropdown, setOpenDropdown } = props; | ||
const [page, setPage] = useState(null) | ||
const toggleDropdown = (index) => { | ||
setOpenDropdown(openDropdown === index ? null : index); | ||
}; | ||
return ( | ||
<div className="mb-24"> | ||
<div className="sticky -top-12 -mt-8 pt-8 pb-2 bg-white dark:bg-ifm-background-color-dark"> | ||
<div className="sticky -top-12 -mt-8 pt-8 pb-2 bg-white dark:bg-ifm-background-color-dark flex justify-center"> | ||
<NetworkSelect /> | ||
</div> | ||
|
||
{apis.map((api) => { | ||
{apis.map((api, index) => { | ||
return ( | ||
<div key={`${api.replaceAll(/\s/g, "-").toLowerCase()}`}> | ||
<Link | ||
href={`#${api.replaceAll(/\s/g, "-").toLowerCase()}`} | ||
data-to-scrollspy-id={`${api | ||
.replaceAll(/\s/g, "-") | ||
.toLowerCase()}`} | ||
className="hover:no-underline pt-4 block text-black dark:text-white hover:text-iota-blue dark:hover:text-iota-blue" | ||
> | ||
{api} | ||
</Link> | ||
{json["methods"] | ||
.filter((method) => method.tags[0].name == api) | ||
.map((method) => { | ||
return ( | ||
<Link | ||
className="my-1 pl-4 block text-iota-gray-95 dark:text-iota-grey-35 hover:no-underline dark:hover:text-iota-blue" | ||
key={`link-${method.name.toLowerCase()}`} | ||
href={`#${method.name.toLowerCase()}`} | ||
data-to-scrollspy-id={`${method.name.toLowerCase()}`} | ||
> | ||
{method.name} | ||
</Link> | ||
); | ||
})} | ||
<div onClick={() => toggleDropdown(index)}> | ||
<Link | ||
href={`#${api.replaceAll(/\s/g, "-").toLowerCase()}`} | ||
data-to-scrollspy-id={`${api | ||
.replaceAll(/\s/g, "-") | ||
.toLowerCase()}`} | ||
className="hover:no-underline text-[#525860] dark:text-[#C0C0C0] hover:text-[#525860] dark:hover:text-white" | ||
> | ||
<div className="flex justify-between p-[5.625px] dark:hover:bg-[#212121] hover:bg-[#f2f2f2]" style={{ alignItems: "center" }}> | ||
<div className={`font-medium ${openDropdown === index && 'menu__link--active'}`}>{api}</div> | ||
<div className="ml-4 pr-4 text-center"> | ||
<p className={`transition-transform duration-500 scale-y-150 ${openDropdown === index ? 'rotate-90' : ''}`} style={{ marginBottom: "0px", fontSize: "17px", fontWeight: "600" }}>></p> | ||
</div> | ||
</div> | ||
</Link> | ||
</div> | ||
<div className={`ml-4 transition-all duration-300 overflow-hidden ${openDropdown === index ? "max-h-screen" : "max-h-0" | ||
}`}> | ||
{json["methods"] | ||
.filter((method) => method.tags[0].name == api) | ||
.map((method) => { | ||
return ( | ||
<Link | ||
className={`menu__link font-medium block hover:no-underline text-base ${page === method.name && 'menu__link--active'}`} | ||
key={`link-${method.name.toLowerCase()}`} | ||
href={`#${method.name.toLowerCase()}`} | ||
data-theme="dark" | ||
onClick={() => setPage(method.name)} | ||
> | ||
{method.name} | ||
</Link> | ||
); | ||
})} | ||
</div> | ||
</div> | ||
); | ||
})} | ||
</div> | ||
); | ||
}; | ||
|
||
export default RefNav; | ||
export default RefNav; |
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
Oops, something went wrong.