Skip to content

Commit

Permalink
fix layout of transaction list (#208)
Browse files Browse the repository at this point in the history
  • Loading branch information
frontendphil authored Nov 15, 2024
1 parent a9aa51a commit 3443792
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 44 deletions.
23 changes: 18 additions & 5 deletions extension/src/components/Input.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,31 @@
import { ReactNode, useId } from 'react'

type RenderProps = {
inputId: string
descriptionId: string
}

type InputProps = {
label: string
children: (inputId: string) => ReactNode
description?: string
children: (props: RenderProps) => ReactNode
}

export const Input = ({ children, label }: InputProps) => {
const id = useId()
export const Input = ({ children, label, description }: InputProps) => {
const inputId = useId()
const descriptionId = useId()

return (
<div className="flex flex-col gap-2">
<label htmlFor={id}>{label}</label>
<label htmlFor={inputId}>{label}</label>

{children({ inputId, descriptionId })}

{children(id)}
{description && (
<span className="opacity-70" id={descriptionId}>
{description}
</span>
)}
</div>
)
}
10 changes: 6 additions & 4 deletions extension/src/components/TextInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,17 @@ type TextInputProps = Omit<
'id' | 'type' | 'className'
> & {
label: string
description?: string
}

export const TextInput = ({ label, ...props }: TextInputProps) => (
<Input label={label}>
{(id) => (
export const TextInput = ({ label, description, ...props }: TextInputProps) => (
<Input label={label} description={description}>
{({ inputId, descriptionId }) => (
<input
{...props}
type="text"
id={id}
id={inputId}
aria-describedby={descriptionId}
className="border border-zodiac-light-mustard border-opacity-80 bg-transparent px-3 py-2 font-mono text-sm text-white outline-none transition-all hover:border-white"
/>
)}
Expand Down
20 changes: 0 additions & 20 deletions extension/src/panel/app-routes/transactions/BaseTransaction.tsx

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Box } from '@/components'
import { Box, TextInput } from '@/components'
import { FunctionFragment, Result } from 'ethers'
import { BaseTransaction } from './BaseTransaction'

interface Props {
functionFragment: FunctionFragment
Expand All @@ -14,11 +13,14 @@ export const DecodedTransaction = ({ functionFragment, data }: Props) => {
return (
<Box p={2} bg>
{functionFragment.inputs.length > 0 && (
<fieldset className="flex flex-col gap-2">
<fieldset className="flex flex-col gap-3">
{functionFragment.inputs.map((input, i) => (
<BaseTransaction value={data[i].toString()}>
{input.name} <i className="pl-1 opacity-70">{input.type}</i>
</BaseTransaction>
<TextInput
readOnly
defaultValue={data[i].toString()}
label={input.name}
description={input.type}
/>
))}
</fieldset>
)}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import { BaseTransaction } from './BaseTransaction'
import { TextInput } from '@/components'

interface Props {
data: string
}

export const RawTransaction = ({ data }: Props) => (
<BaseTransaction value={data || ''}>
<span>Data</span>
</BaseTransaction>
<TextInput readOnly defaultValue={data || ''} label="Data" />
)
9 changes: 5 additions & 4 deletions extension/src/panel/app-routes/transactions/Transactions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export const Transactions = () => {
}

return (
<div className="flex flex-1 flex-col gap-4 pb-8 pt-4">
<div className="flex flex-1 flex-col gap-4 overflow-hidden pb-8 pt-4">
<div className="px-4">
<RouteBubble />
</div>
Expand Down Expand Up @@ -92,10 +92,10 @@ export const Transactions = () => {
</div>
</div>

<div className="flex flex-1 flex-col gap-8 overflow-hidden px-6">
<div className="flex flex-1 flex-col gap-8 overflow-hidden">
<div
ref={scrollContainerRef}
className="exp flex flex-grow flex-col gap-4 overflow-y-auto"
className="exp flex flex-grow flex-col gap-4 overflow-y-auto px-6"
>
{transactions.map((transactionState, index) => (
<Transaction
Expand All @@ -114,7 +114,7 @@ export const Transactions = () => {
)}
</div>

<div className="flex gap-2">
<div className="flex gap-2 px-6">
{!route.initiator && (
<Button
secondary
Expand All @@ -124,6 +124,7 @@ export const Transactions = () => {
Copy transaction data
</Button>
)}

<Submit />
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion extension/src/panel/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const Root = () => {
<ProvideZodiacRoutes>
<ProvideInjectedWallet>
<ProvideProvider>
<div className="flex flex-1 flex-col">
<div className="flex h-full flex-1 flex-col">
<RouterProvider router={router} />
<ZodiacToastContainer />
</div>
Expand Down

0 comments on commit 3443792

Please sign in to comment.