Skip to content

Commit

Permalink
cleanup code
Browse files Browse the repository at this point in the history
  • Loading branch information
jubalm committed Nov 14, 2024
1 parent 9507d94 commit 26b3a8a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 31 deletions.
4 changes: 2 additions & 2 deletions app/css/interceptor.css
Original file line number Diff line number Diff line change
Expand Up @@ -1740,7 +1740,7 @@ header:has(form[role='search']) h1 {
--bg-color: transparent;
--button-color: #77738ccc;
--image-size: 2.25rem;
--min-text-width: 3ch;
--min-text-width: 0;
--pad-x: 0;
--pad-y: 0;
--gap-x: 0.5rem;
Expand All @@ -1757,7 +1757,7 @@ header:has(form[role='search']) h1 {
padding-inline: var(--pad-x);
background-color: var(--bg-color);
border-radius: var(--edge-roundness);
min-width: calc(var(--min-text-width) + var(--image-size) + (var(-pad-x) * 2) + var(--gap-x));
min-width: calc(var(--min-text-width) + var(--image-size) + (var(--pad-x) * 2) + var(--gap-x));

data {
line-height: 1em;
Expand Down
2 changes: 1 addition & 1 deletion app/ts/components/subcomponents/MultilineCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export type ActionableIconProps = {
icon: () => JSX.Element
hintText?: string
action: 'clipboard-copy'
copyValue: string
copyValue?: string
copySuccessMessage?: string
} | {
icon: () => JSX.Element
Expand Down
40 changes: 12 additions & 28 deletions app/ts/components/subcomponents/address.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,46 +68,30 @@ export function BigAddress(params: BigAddressParams) {
onClick: () => params.addressBookEntry && params.renameAddressCallBack(params.addressBookEntry)
}

const setupCopyAction = {
action: 'clipboard-copy' as const,
copyValue: addressString,
copySuccessMessage: 'Address copied!'
}

const setupEditAction = { action: !params.noEditAddress ? renameAddressAction : undefined }

const labelConfig: ActionableTextProps = {
displayText: labelText,
...(labelText === addressString && params.noCopying === undefined) ? {
action: 'clipboard-copy',
copyValue: addressString,
copySuccessMessage: 'Address copied!'
} : {
action: params.noEditAddress === undefined ? renameAddressAction : undefined
}
...(labelText === addressString && !params.noCopying) ? setupCopyAction : setupEditAction
}

const noteConfig: ActionableTextProps = {
displayText: noteText,
...(noteText === addressString && !params.noCopying) ? {
action: 'clipboard-copy',
copyValue: addressString,
copySuccessMessage: 'Address copied!'
} : {
action: params.noEditAddress === undefined ? renameAddressAction : undefined
}
...(noteText === addressString && !params.noCopying) ? setupCopyAction : setupEditAction
}

const iconConfig: ActionableIconProps = {
icon: () => params.addressBookEntry ? <Blockie address = { params.addressBookEntry.address } /> : <></>,
...(!params.noCopying && addressString) ? {
action: 'clipboard-copy',
copyValue: addressString
} : {
action: undefined
}
...(!params.noCopying && addressString) ? setupCopyAction : { action: undefined }
}

return (
<MultilineCard
label = { labelConfig }
note = { noteConfig }
icon = { iconConfig }
style = { params.style }
/>
)
return <MultilineCard label = { labelConfig } note = { noteConfig } icon = { iconConfig } style = { params.style } />
}

type ActiveAddressParams = {
Expand Down

0 comments on commit 26b3a8a

Please sign in to comment.