diff --git a/src/components/Card.tsx b/src/components/Card.tsx index 69feb78f..7fa7e9cc 100644 --- a/src/components/Card.tsx +++ b/src/components/Card.tsx @@ -39,7 +39,7 @@ const cardHeaderStyle = css` [data-class=copy-button] { vertical-align: text-bottom; - margin: 6px 0; + margin: 2px 0; margin-left: 16px; } `; diff --git a/src/components/CopyToClipboardButton.tsx b/src/components/CopyToClipboardButton.tsx index 6409a432..97423e28 100644 --- a/src/components/CopyToClipboardButton.tsx +++ b/src/components/CopyToClipboardButton.tsx @@ -4,7 +4,6 @@ import { IconButton, IconButtonProps, Tooltip } from "@mui/material"; import { css } from "@emotion/react"; const buttonStyle = css` - padding: 0; `; export type CopyToClipboardButtonProps = Omit & { diff --git a/src/components/DataViewer.tsx b/src/components/DataViewer.tsx index 91a6c9c5..8bf2525a 100644 --- a/src/components/DataViewer.tsx +++ b/src/components/DataViewer.tsx @@ -1,8 +1,8 @@ /** @jsxImportSource @emotion/react */ import { PropsWithChildren, ReactNode, useMemo, useState } from "react"; import { css, Theme } from "@emotion/react"; -import { IconButton, Modal, ToggleButton, ToggleButtonGroup } from "@mui/material"; -import { Close } from "@mui/icons-material"; +import { IconButton, Modal, ToggleButton, ToggleButtonGroup, Tooltip } from "@mui/material"; +import { AutoStories, Close } from "@mui/icons-material"; import { Network } from "../model/network"; import { RuntimeMetadataArg } from "../model/runtime-metadata/runtimeMetadataArg"; @@ -91,6 +91,7 @@ const simpleControlsStyle = css` align-items: flex-start; margin-bottom: 0; margin-left: 12px; + padding-top: 2px; `; const modeButtonsStyle = css` @@ -104,21 +105,20 @@ const modeButtonStyle = css` line-height: 24px; `; -const fullscreenButtonStyle = css` - padding: 2px; - margin-left: 8px; -`; +const buttonStyle = css` + margin: -4px 0; + margin-left: 4px; -const copyButtonStyle = css` - padding: 2px; + &:last-child { + margin-right: -2px; + } `; const closeButtonStyle = css` position: absolute; top: 0; right: 0; - margin: 12px; - padding: 0; + margin: 8px; z-index: 10; `; @@ -169,7 +169,7 @@ const DataViewerModalHandle = (props: DataViewerModalHandleProps) => { return ( <> - setShowModal(true)}> + setShowModal(true)}> { >
{!simple && } - {copyToClipboard && } + {copyToClipboard && } {!simple &&
- {copyToClipboard && } + {copyToClipboard && }
{mode === "json" && jsonContent} diff --git a/src/components/InfoTable.tsx b/src/components/InfoTable.tsx index 6130e5f1..a6494b6a 100644 --- a/src/components/InfoTable.tsx +++ b/src/components/InfoTable.tsx @@ -75,7 +75,8 @@ const valueStyle = css` `; const copyButtonStyle = css` - margin-left: 16px; + margin: -4px 0; + margin-left: 12px; `; type InfoTableDataFn = (data: T, ...additionalData: A) => R; diff --git a/src/components/blocks/BlockInfoTable.tsx b/src/components/blocks/BlockInfoTable.tsx index edf3b2c0..af92cba4 100644 --- a/src/components/blocks/BlockInfoTable.tsx +++ b/src/components/blocks/BlockInfoTable.tsx @@ -84,7 +84,11 @@ export const BlockInfoTable = (props: BlockInfoTableProps) => { /> data.specVersion} + render={(data) => + + {data.specVersion} + + } /> diff --git a/src/components/blocks/BlocksTable.tsx b/src/components/blocks/BlocksTable.tsx index 1de9068b..eadaa3f7 100644 --- a/src/components/blocks/BlocksTable.tsx +++ b/src/components/blocks/BlocksTable.tsx @@ -5,6 +5,7 @@ import { PaginatedResource } from "../../model/paginatedResource"; import { AccountAddress } from "../account/AccountAddress"; import { ItemsTable, ItemsTableAttribute } from "../ItemsTable"; +import { Link } from "../Link"; import { Time } from "../Time"; import { BlockLink } from "./BlockLink"; @@ -47,7 +48,11 @@ function ExtrinsicsTable(props: BlocksTableProps) { /> block.specVersion} + render={(block) => + + {block.specVersion} + + } /> {showValidator && { - - {data.palletName}.{data.callName} - + <> + + {data.metadata.call && } + } /> { /> data.specVersion} + render={(data) => + + {data.specVersion} + + } /> ); diff --git a/src/components/calls/CallNameButton.tsx b/src/components/calls/CallNameButton.tsx new file mode 100644 index 00000000..2ddcc552 --- /dev/null +++ b/src/components/calls/CallNameButton.tsx @@ -0,0 +1,29 @@ +/** @jsxImportSource @emotion/react */ +import { css } from "@emotion/react"; + +import { Call } from "../../model/call"; + +import { ButtonLink } from "../ButtonLink"; + +const buttonStyle = css` + margin: -4px 0; +`; + +export interface CallNameButtonProps { + call: Call; +} + +export const CallNameButton = (props: CallNameButtonProps) => { + const {call} = props; + + return ( + + {call.palletName}.{call.callName} + + ); +}; diff --git a/src/components/calls/CallRuntimeMetadataButton.tsx b/src/components/calls/CallRuntimeMetadataButton.tsx new file mode 100644 index 00000000..94c50078 --- /dev/null +++ b/src/components/calls/CallRuntimeMetadataButton.tsx @@ -0,0 +1,23 @@ +import { Call } from "../../model/call"; + +import { RuntimeMetadataButton } from "../runtime/RuntimeMetadataButton"; + +export interface CallRuntimeMetadataButtonProps { + call: Call; +} + +export const CallRuntimeMetadataButton = (props: CallRuntimeMetadataButtonProps) => { + const {call} = props; + + if (!call.metadata.call) { + return null; + } + + return ( + + ); +}; diff --git a/src/components/calls/CallsTable.tsx b/src/components/calls/CallsTable.tsx index a36205ac..ab83b9db 100644 --- a/src/components/calls/CallsTable.tsx +++ b/src/components/calls/CallsTable.tsx @@ -9,6 +9,7 @@ import { ButtonLink } from "../ButtonLink"; import { ItemsTable, ItemsTableAttribute } from "../ItemsTable"; import { CallLink } from "./CallLink"; +import { CallNameButton } from "./CallNameButton"; export type CallsTableProps = { network: Network; @@ -41,15 +42,7 @@ export const CallsTable = (props: CallsTableProps) => { /> - - {call.palletName}.{call.callName} - - } + render={(call) => } /> {showAccount && ( ; @@ -72,13 +75,10 @@ export const EventInfoTable = (props: EventInfoTableProps) => { - - {data.palletName}.{data.eventName} - + <> + + {data.metadata.event && } + } /> { /> data.specVersion} + render={(data) => + + {data.specVersion} + + } /> ); diff --git a/src/components/events/EventNameButton.tsx b/src/components/events/EventNameButton.tsx new file mode 100644 index 00000000..04f79aec --- /dev/null +++ b/src/components/events/EventNameButton.tsx @@ -0,0 +1,29 @@ +/** @jsxImportSource @emotion/react */ +import { css } from "@emotion/react"; + +import { Event } from "../../model/event"; + +import { ButtonLink } from "../ButtonLink"; + +const buttonStyle = css` + margin: -4px 0; +`; + +export interface EventNameButtonProps { + event: Event; +} + +export const EventNameButton = (props: EventNameButtonProps) => { + const {event} = props; + + return ( + + {event.palletName}.{event.eventName} + + ); +}; diff --git a/src/components/events/EventRuntimeMetadataButton.tsx b/src/components/events/EventRuntimeMetadataButton.tsx new file mode 100644 index 00000000..e1ae3e87 --- /dev/null +++ b/src/components/events/EventRuntimeMetadataButton.tsx @@ -0,0 +1,23 @@ +import { Event } from "../../model/event"; + +import { RuntimeMetadataButton } from "../runtime/RuntimeMetadataButton"; + +export interface EventRuntimeMetadataButtonProps { + event: Event; +} + +export const EventRuntimeMetadataButton = (props: EventRuntimeMetadataButtonProps) => { + const {event} = props; + + if (!event.metadata.event) { + return null; + } + + return ( + + ); +}; diff --git a/src/components/events/EventsTable.tsx b/src/components/events/EventsTable.tsx index bd5a09d1..50f89383 100644 --- a/src/components/events/EventsTable.tsx +++ b/src/components/events/EventsTable.tsx @@ -12,6 +12,7 @@ import { DataViewer } from "../DataViewer"; import { ItemsTable, ItemsTableAttribute } from "../ItemsTable"; import { EventLink } from "./EventLink"; +import { EventNameButton } from "./EventNameButton"; const parametersColCss = (showExtrinsic?: boolean) => css` width: ${showExtrinsic ? "40%" : "60%"}; @@ -48,15 +49,7 @@ function EventsTable(props: EventsTableProps) { /> - - {event.palletName}.{event.eventName} - - } + render={(event) => } /> {showExtrinsic && ( ; @@ -93,13 +96,10 @@ export const ExtrinsicInfoTable = (props: ExtrinsicInfoTableProps) => { - - {data.palletName}.{data.callName} - + <> + + {data.metadata.call && } + } /> { /> data.specVersion} + render={(data) => + + {data.specVersion} + + } /> ); diff --git a/src/components/extrinsics/ExtrinsicNameButton.tsx b/src/components/extrinsics/ExtrinsicNameButton.tsx new file mode 100644 index 00000000..b52d2e1a --- /dev/null +++ b/src/components/extrinsics/ExtrinsicNameButton.tsx @@ -0,0 +1,29 @@ +/** @jsxImportSource @emotion/react */ +import { css } from "@emotion/react"; + +import { Extrinsic } from "../../model/extrinsic"; + +import { ButtonLink } from "../ButtonLink"; + +const buttonStyle = css` + margin: -4px 0; +`; + +export interface ExtrinsicNameButtonProps { + extrinsic: Extrinsic; +} + +export const ExtrinsicNameButton = (props: ExtrinsicNameButtonProps) => { + const {extrinsic} = props; + + return ( + + {extrinsic.palletName}.{extrinsic.callName} + + ); +}; diff --git a/src/components/extrinsics/ExtrinsicRuntimeMetadataButton.tsx b/src/components/extrinsics/ExtrinsicRuntimeMetadataButton.tsx new file mode 100644 index 00000000..f21a3d71 --- /dev/null +++ b/src/components/extrinsics/ExtrinsicRuntimeMetadataButton.tsx @@ -0,0 +1,23 @@ +import { Extrinsic } from "../../model/extrinsic"; + +import { RuntimeMetadataButton } from "../runtime/RuntimeMetadataButton"; + +export interface ExtrinsicRuntimeMetadataButtonProps { + extrinsic: Extrinsic; +} + +export const ExtrinsicRuntimeMetadataButton = (props: ExtrinsicRuntimeMetadataButtonProps) => { + const {extrinsic} = props; + + if (!extrinsic.metadata.call) { + return null; + } + + return ( + + ); +}; diff --git a/src/components/extrinsics/ExtrinsicsTable.tsx b/src/components/extrinsics/ExtrinsicsTable.tsx index 7a5879d8..6f65411b 100644 --- a/src/components/extrinsics/ExtrinsicsTable.tsx +++ b/src/components/extrinsics/ExtrinsicsTable.tsx @@ -8,6 +8,7 @@ import { ItemsTable, ItemsTableAttribute } from "../ItemsTable"; import { Time } from "../Time"; import { ExtrinsicLink } from "./ExtrinsicLink"; +import { ExtrinsicNameButton } from "./ExtrinsicNameButton"; export type ExtrinsicsTableProps = { network: Network; @@ -47,15 +48,7 @@ function ExtrinsicsTable(props: ExtrinsicsTableProps) { /> - - {extrinsic.palletName}.{extrinsic.callName} - - } + render={(extrinsic) => } /> {showAccount && { + const {title, description, link} = props; + + return ( + +

{title}


+ + {description} + +
Click to view more
+ + } + > + + + +
+ ); +}; diff --git a/src/components/runtime/RuntimeMetadataCallsTable.tsx b/src/components/runtime/RuntimeMetadataCallsTable.tsx index 0352f1a9..06800a79 100644 --- a/src/components/runtime/RuntimeMetadataCallsTable.tsx +++ b/src/components/runtime/RuntimeMetadataCallsTable.tsx @@ -59,7 +59,7 @@ export function RuntimeMetadataCallsTable(props: ExtrinsicsTableProps) { ( - + {data.description} )} diff --git a/src/components/runtime/RuntimeMetadataConstantsTable.tsx b/src/components/runtime/RuntimeMetadataConstantsTable.tsx index ef877ccb..e0007b18 100644 --- a/src/components/runtime/RuntimeMetadataConstantsTable.tsx +++ b/src/components/runtime/RuntimeMetadataConstantsTable.tsx @@ -49,7 +49,7 @@ export function RuntimeMetadataConstantsTable(props: ConstantsTableProps) { ( - + {data.description} )} diff --git a/src/components/runtime/RuntimeMetadataDescription.tsx b/src/components/runtime/RuntimeMetadataDescription.tsx index f5cac056..0670c8a0 100644 --- a/src/components/runtime/RuntimeMetadataDescription.tsx +++ b/src/components/runtime/RuntimeMetadataDescription.tsx @@ -2,7 +2,7 @@ import Markdown from "react-markdown"; import { css } from "@emotion/react"; -const descriptionStyle = css` +const descriptionStyle = (darkMode?: boolean) => css` padding: 16px; padding: 0;; height: 100%; @@ -25,11 +25,12 @@ const descriptionStyle = css` code { padding: 2px 6px; - background-color: #f5f5f5; - background-color: rgba(0, 0, 0, .065); border-radius: 8px; font-size: 14px; line-height: 20px; + + ${!darkMode && css`background-color: rgba(0, 0, 0, .065);`} + ${darkMode && css`background-color: rgba(255, 255, 255, .2);`} } h1, h2, h3, h4, h5, h6 { @@ -37,45 +38,36 @@ const descriptionStyle = css` } `; -const ellipsisStyle = css` +const lineClampStyle = (lines: number ) => css` display: -webkit-box; -webkit-box-orient: vertical; - -webkit-line-clamp: 1; + -webkit-line-clamp: ${lines}; overflow: hidden; `; export interface RuntimeMetadataDescription { - onlyLine?: number; - ellipsis?: boolean; + lineClamp?: number; + darkMode?: boolean; className?: string; children: string; } export const RuntimeMetadataDescription = (props: RuntimeMetadataDescription) => { - const {onlyLine, ellipsis, className, children} = props; - - let text = children; - - if (onlyLine) { - const lines = children.split("\n"); - text = lines[onlyLine - 1] as string; + const {lineClamp, darkMode, className, children} = props; - if (ellipsis && lines.length > 1) { - text += " …"; - } - } + const text = children; return ( - {text} + {text.replace(/\n/, " \n")} ); }; diff --git a/src/components/runtime/RuntimeMetadataErrorsTable.tsx b/src/components/runtime/RuntimeMetadataErrorsTable.tsx index a24a53ef..bf0ee35b 100644 --- a/src/components/runtime/RuntimeMetadataErrorsTable.tsx +++ b/src/components/runtime/RuntimeMetadataErrorsTable.tsx @@ -49,7 +49,7 @@ export function RuntimeMetadataErrorsTable(props: ErrorsTableProps) { ( - + {data.description} )} diff --git a/src/components/runtime/RuntimeMetadataEventsTable.tsx b/src/components/runtime/RuntimeMetadataEventsTable.tsx index 8c6afeb0..f33930ce 100644 --- a/src/components/runtime/RuntimeMetadataEventsTable.tsx +++ b/src/components/runtime/RuntimeMetadataEventsTable.tsx @@ -58,7 +58,7 @@ export function RuntimeMetadataEventsTable(props: ExtrinsicsTableProps) { ( - + {data.description} )} diff --git a/src/components/runtime/RuntimeMetadataStoragesTable.tsx b/src/components/runtime/RuntimeMetadataStoragesTable.tsx index 440d90c3..763bdae5 100644 --- a/src/components/runtime/RuntimeMetadataStoragesTable.tsx +++ b/src/components/runtime/RuntimeMetadataStoragesTable.tsx @@ -58,7 +58,7 @@ export function RuntimeMetadataStoragesTable(props: StoragesTableProps) { ( - + {data.description} )} diff --git a/src/components/search/BlockSearchResultsTable.tsx b/src/components/search/BlockSearchResultsTable.tsx index a5d702c9..ab8dbdd1 100644 --- a/src/components/search/BlockSearchResultsTable.tsx +++ b/src/components/search/BlockSearchResultsTable.tsx @@ -4,6 +4,7 @@ import { SearchResultItem } from "../../model/searchResultItem"; import { AccountAddress } from "../account/AccountAddress"; import { BlockLink } from "../blocks/BlockLink"; +import { Link } from "../Link"; import { Time } from "../Time"; @@ -37,7 +38,9 @@ export const BlockSearchResultsTable = (props: BlockSearchResultsTable) => { label="Spec version" render={(block) => - <>{block.specVersion} + + {block.specVersion} + } /> diff --git a/src/components/search/EventSearchResultsTable.tsx b/src/components/search/EventSearchResultsTable.tsx index 7ce4181c..2ac091d4 100644 --- a/src/components/search/EventSearchResultsTable.tsx +++ b/src/components/search/EventSearchResultsTable.tsx @@ -6,8 +6,8 @@ import { PaginatedResource } from "../../model/paginatedResource"; import { ExtrinsicLink } from "../extrinsics/ExtrinsicLink"; import { EventLink } from "../events/EventLink"; +import { EventNameButton } from "../events/EventNameButton"; -import { ButtonLink } from "../ButtonLink"; import { DataViewer } from "../DataViewer"; import { SearchResultsTable, SearchResultsTableItemAttribute, SearchResultsTableProps } from "./SearchResultsTable"; @@ -43,15 +43,7 @@ export const EventSearchResultsTable = (props: EventSearchResultsTable) => { /> label="Name" - render={(event) => ( - - {event.palletName}.{event.eventName} - - )} + render={(event) => } /> label="Extrinsic" diff --git a/src/components/search/ExtrinsicSearchResultsTable.tsx b/src/components/search/ExtrinsicSearchResultsTable.tsx index 84e8a5f3..ea2bcbd7 100644 --- a/src/components/search/ExtrinsicSearchResultsTable.tsx +++ b/src/components/search/ExtrinsicSearchResultsTable.tsx @@ -4,9 +4,9 @@ import { SearchResultItem } from "../../model/searchResultItem"; import { AccountAddress } from "../account/AccountAddress"; -import { ButtonLink } from "../ButtonLink"; import { ExtrinsicLink } from "../extrinsics/ExtrinsicLink"; -import { Link } from "../Link"; +import { ExtrinsicNameButton } from "../extrinsics/ExtrinsicNameButton"; + import { Time } from "../Time"; import { SearchResultsTable, SearchResultsTableItemAttribute, SearchResultsTableProps } from "./SearchResultsTable"; @@ -38,15 +38,7 @@ export const ExtrinsicSearchResultsTable = (props: ExtrinsicSearchResultsTable) /> label="Name" - render={(extrinsic) => ( - - {extrinsic.palletName}.{extrinsic.callName} - - )} + render={(extrinsic) => } /> label="Account"