Skip to content

Commit

Permalink
feat(ref): act-1516 - added extra content prop to parser (#1521)
Browse files Browse the repository at this point in the history
  • Loading branch information
TrofimovAnton85 authored Sep 6, 2024
1 parent c9d3c43 commit f42790f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
3 changes: 3 additions & 0 deletions src/components/ParserOpenRPC/DetailsBox/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ interface DetailsBoxProps {
components: SchemaComponents;
result: any;
tags: TagItem[];
extraContent?: JSX.Element;
}

export default function DetailsBox({
Expand All @@ -31,6 +32,7 @@ export default function DetailsBox({
components,
result,
tags,
extraContent,
}: DetailsBoxProps) {
return (
<>
Expand All @@ -45,6 +47,7 @@ export default function DetailsBox({
)}
<Heading as="h1">{method}</Heading>
<MDContent content={description} />
{extraContent && <div className="padding-top--lg">{extraContent}</div>}
<Heading
as="h2"
className={clsx(
Expand Down
4 changes: 3 additions & 1 deletion src/components/ParserOpenRPC/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { MetamaskProviderContext } from "@site/src/theme/Root";
interface ParserProps {
network: NETWORK_NAMES;
method?: string;
extraContent?: JSX.Element;
}

interface ParserOpenRPCContextProps {
Expand All @@ -30,7 +31,7 @@ interface ParserOpenRPCContextProps {
export const ParserOpenRPCContext =
createContext<ParserOpenRPCContextProps | null>(null);

export default function ParserOpenRPC({ network, method }: ParserProps) {
export default function ParserOpenRPC({ network, method, extraContent }: ParserProps) {
if (!method || !network) return null;
const [isModalOpen, setModalOpen] = useState(false);
const [reqResult, setReqResult] = useState(undefined);
Expand Down Expand Up @@ -178,6 +179,7 @@ export default function ParserOpenRPC({ network, method }: ParserProps) {
components={currentMethodData.components.schemas}
result={currentMethodData.result}
tags={currentMethodData.tags}
extraContent={extraContent}
/>
<ErrorsBox errors={currentMethodData.errors} />
</div>
Expand Down
7 changes: 6 additions & 1 deletion wallet/reference/new-reference.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,10 @@ sidebar_class_name: "hidden"

import ParserOpenRPC from "@site/src/components/ParserOpenRPC"
import { NETWORK_NAMES } from "@site/src/plugins/plugin-json-rpc"
import Description from "@site/services/reference/_partials/_eth_sendtransaction-description.mdx"

<ParserOpenRPC network={NETWORK_NAMES.metamask} method="eth_requestAccounts" />
<ParserOpenRPC
network={NETWORK_NAMES.metamask}
method="eth_requestAccounts"
extraContent={<Description />}
/>

0 comments on commit f42790f

Please sign in to comment.