From 26b3a8a733120ba554edab4afa0642f7e8cc746f Mon Sep 17 00:00:00 2001 From: Jubal Mabaquiao Date: Thu, 14 Nov 2024 08:34:57 +0800 Subject: [PATCH] cleanup code --- app/css/interceptor.css | 4 +- .../subcomponents/MultilineCard.tsx | 2 +- app/ts/components/subcomponents/address.tsx | 40 ++++++------------- 3 files changed, 15 insertions(+), 31 deletions(-) diff --git a/app/css/interceptor.css b/app/css/interceptor.css index 59536b78..15945463 100644 --- a/app/css/interceptor.css +++ b/app/css/interceptor.css @@ -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; @@ -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; diff --git a/app/ts/components/subcomponents/MultilineCard.tsx b/app/ts/components/subcomponents/MultilineCard.tsx index 5de0b664..e769a3ae 100644 --- a/app/ts/components/subcomponents/MultilineCard.tsx +++ b/app/ts/components/subcomponents/MultilineCard.tsx @@ -30,7 +30,7 @@ export type ActionableIconProps = { icon: () => JSX.Element hintText?: string action: 'clipboard-copy' - copyValue: string + copyValue?: string copySuccessMessage?: string } | { icon: () => JSX.Element diff --git a/app/ts/components/subcomponents/address.tsx b/app/ts/components/subcomponents/address.tsx index 742cd6cc..6b52a3e1 100644 --- a/app/ts/components/subcomponents/address.tsx +++ b/app/ts/components/subcomponents/address.tsx @@ -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 ? : <>, - ...(!params.noCopying && addressString) ? { - action: 'clipboard-copy', - copyValue: addressString - } : { - action: undefined - } + ...(!params.noCopying && addressString) ? setupCopyAction : { action: undefined } } - return ( - - ) + return } type ActiveAddressParams = {