1
0
mirror of https://github.com/kremalicious/blog.git synced 2024-11-22 09:56:51 +01:00

preview tweaks

This commit is contained in:
Matthias Kretschmann 2023-11-05 16:40:44 +00:00
parent 324d032326
commit 73d966e3be
Signed by: m
GPG Key ID: 606EEEF3C479A91F
12 changed files with 106 additions and 78 deletions

View File

@ -1,19 +1,8 @@
.conversion { .conversion {
font-size: var(--font-size-mini); font-size: var(--font-size-mini);
color: var(--text-color-light); color: var(--text-color-light);
text-align: center;
margin-top: calc(var(--spacer) / 6);
animation: fadeIn 0.5s 0.8s ease-out backwards;
}
@media screen and (min-width: 40rem) {
.conversion {
text-align: left;
margin-top: 0;
margin-left: calc(var(--spacer) * 2.4);
}
} }
.conversion span { .conversion span {
margin-left: calc(var(--spacer) / 2); margin-left: calc(var(--spacer) / 3);
} }

View File

@ -78,7 +78,7 @@
.submit { .submit {
width: 100%; width: 100%;
max-width: none; max-width: none;
height: calc(var(--height) - 2px); height: var(--height);
border-top-left-radius: 0; border-top-left-radius: 0;
border-top-right-radius: 0; border-top-right-radius: 0;
border: 0; border: 0;
@ -90,10 +90,7 @@
.submit { .submit {
width: fit-content; width: fit-content;
padding: 0 calc(var(--spacer) / 1.5); padding: 0 calc(var(--spacer) / 1.5);
border-top-right-radius: var(--border-radius); border-radius: 0;
border-top-left-radius: 0;
border-bottom-left-radius: 0;
margin-right: 1px;
} }
} }
@ -113,3 +110,17 @@
width: 100%; width: 100%;
text-align: right; text-align: right;
} }
.conversion {
text-align: center;
margin-top: calc(var(--spacer) / 6);
animation: fadeIn 0.5s 0.8s ease-out backwards;
}
@media screen and (min-width: 40rem) {
.conversion {
text-align: left;
margin-top: 0;
margin-left: calc(var(--spacer) * 3);
}
}

View File

@ -60,7 +60,9 @@ export function InputGroup({
{error ? <span className={styles.errorOutput}>{error}</span> : null} {error ? <span className={styles.errorOutput}>{error}</span> : null}
</div> </div>
<div className={styles.conversion}>
<Conversion /> <Conversion />
</div>
</> </>
) )
} }

View File

@ -1,26 +1,6 @@
.to,
.from {
display: block;
word-break: break-all;
background: none;
padding: 0;
}
code.to,
code.from {
font-size: var(--font-size-mini);
}
.to:last-child {
padding-left: 14px;
}
.to:last-child::first-letter {
margin-left: -14px;
}
.table { .table {
/* max-width: 386px; */ width: 100%;
display: table;
margin-bottom: calc(var(--spacer) / 1.5); margin-bottom: calc(var(--spacer) / 1.5);
} }
@ -33,8 +13,27 @@ table[aria-disabled='true'] {
padding: calc(var(--spacer) / 4) calc(var(--spacer) / 3); padding: calc(var(--spacer) / 4) calc(var(--spacer) / 3);
} }
.to,
.from {
display: block;
word-break: break-all;
background: none;
padding: 0;
}
.label { .label {
color: var(--text-color-light); color: var(--text-color-light);
vertical-align: top; vertical-align: top;
width: 6rem; width: 6rem;
} }
.amount {
display: flex;
align-items: center;
}
.table :global(.TokenLogo),
.table :global(.TokenLogo) img {
width: 18px;
height: 18px;
}

View File

@ -7,6 +7,7 @@ import type {
import styles from './Data.module.css' import styles from './Data.module.css'
import { useStore } from '@nanostores/react' import { useStore } from '@nanostores/react'
import { $selectedToken } from '@features/Web3/stores' import { $selectedToken } from '@features/Web3/stores'
import { truncateAddress } from '@features/Web3/lib/truncateAddress'
export function Data({ export function Data({
to, to,
@ -42,20 +43,28 @@ export function Data({
<tbody> <tbody>
<tr> <tr>
<td className={styles.label}>You are</td> <td className={styles.label}>You are</td>
{ensFrom ? (
<td title={`${ensFrom} successfully resolved to ${from}`}>
<span className={styles.from}>{ensFrom}</span>
</td>
) : (
<td> <td>
<code className={styles.from}>{from}</code> {ensFrom ? (
</td> <abbr title={`${ensFrom} successfully resolved to ${from}`}>
<span className={styles.from}>{ensFrom}</span>
</abbr>
) : (
<code className={styles.from}>
{from ? truncateAddress(from) : ''}
</code>
)} )}
</td>
</tr> </tr>
<tr> <tr>
<td className={styles.label}>sending</td> <td className={styles.label}>sending</td>
<td> <td className={styles.amount}>
<div className="TokenLogo">
<img
src={selectedToken?.logo || ''}
alt={selectedToken?.name || ''}
/>
</div>
<span className={styles.amount}> <span className={styles.amount}>
{displayAmountFromConfig} {selectedToken?.symbol} {displayAmountFromConfig} {selectedToken?.symbol}
</span> </span>
@ -71,9 +80,10 @@ export function Data({
<tr> <tr>
<td className={styles.label}>to</td> <td className={styles.label}>to</td>
<td title={`${ensResolved} successfully resolved to ${to}`}> <td>
<abbr title={`${ensResolved} successfully resolved to ${to}`}>
<span className={styles.to}>{ensResolved}</span> <span className={styles.to}>{ensResolved}</span>
<code className={styles.to}>{`${to}`}</code> </abbr>
</td> </td>
</tr> </tr>
</tbody> </tbody>

View File

@ -39,6 +39,8 @@ export function Preview() {
isDisabled={isLoading} isDisabled={isLoading}
/> />
{console.log(txConfig)}
{error || prepareError ? ( {error || prepareError ? (
<div className={styles.alert}>{error || prepareError}</div> <div className={styles.alert}>{error || prepareError}</div>
) : null} ) : null}

View File

@ -2,21 +2,6 @@
padding-left: 0 !important; padding-left: 0 !important;
} }
/* hide the account icon, and hope nothing else */
.rainbowkit button [aria-hidden] {
display: none;
}
.rainbowkit [aria-label='Chain Selector'],
.rainbowkit [data-testid='rk-account-button'] div {
font-weight: var(--font-weight-base);
}
/* hide the network icon, and hope nothing else */
.rainbowkit [aria-label='Chain Selector'] [role='img'] {
display: none;
}
.rainbowkit > div:first-child { .rainbowkit > div:first-child {
display: flex; display: flex;
flex-direction: row-reverse; flex-direction: row-reverse;
@ -24,6 +9,32 @@
font-size: var(--font-size-small); font-size: var(--font-size-small);
} }
/* hide the account icon, and hope nothing else */
/* .rainbowkit button [aria-hidden] {
display: none;
} */
.rainbowkit [aria-label='Chain Selector'],
.rainbowkit [data-testid='rk-account-button'] div {
font-weight: var(--font-weight-base);
}
.rainbowkit [aria-label='Chain Selector']:hover,
.rainbowkit [data-testid='rk-account-button']:hover,
.rainbowkit [data-testid='rk-account-button']:hover div,
.rainbowkit [aria-label='Chain Selector']:focus,
.rainbowkit [data-testid='rk-account-button']:focus,
.rainbowkit [data-testid='rk-account-button']:focus div {
transform: none !important;
color: var(--link-color-hover) !important;
}
/* hide the network icon, and hope nothing else */
.rainbowkit [aria-label='Chain Selector'] [role='img'] {
display: none;
}
/* connect button */ /* connect button */
.rainbowkit [data-testid='rk-connect-button'] { .rainbowkit [data-testid='rk-connect-button'] {
margin-right: auto; margin-right: auto;

View File

@ -6,8 +6,6 @@
height: 100%; height: 100%;
font-size: var(--font-size-small); font-size: var(--font-size-small);
line-height: 1; line-height: 1;
border-top-left-radius: var(--border-radius);
border-bottom-left-radius: var(--border-radius);
} }
.SelectTrigger:hover { .SelectTrigger:hover {
@ -16,10 +14,6 @@
.SelectTrigger:focus { .SelectTrigger:focus {
background-color: var(--text-color-dimmed); background-color: var(--text-color-dimmed);
/* box-shadow: 0 0 0 var(--border-width) var(--input-border-focus); */
/* border-color: var(--input-border-focus) !important; */
} }
.SelectTrigger[data-disabled] { .SelectTrigger[data-disabled] {

View File

@ -1,4 +1,3 @@
import type { GetToken } from '@features/Web3/stores/tokens'
import { parseEther, parseUnits } from 'viem' import { parseEther, parseUnits } from 'viem'
import { import {
prepareSendTransaction, prepareSendTransaction,
@ -7,6 +6,7 @@ import {
type WriteContractPreparedArgs type WriteContractPreparedArgs
} from 'wagmi/actions' } from 'wagmi/actions'
import { abiErc20Transfer } from './abiErc20Transfer' import { abiErc20Transfer } from './abiErc20Transfer'
import type { GetToken } from '../useFetchTokens'
export async function prepare( export async function prepare(
selectedToken: GetToken | undefined, selectedToken: GetToken | undefined,

View File

@ -31,8 +31,8 @@ export function useSend({
// only expose useful errors in UI // only expose useful errors in UI
const terribleErrorMessages = [ const terribleErrorMessages = [
'User rejected the request.', 'User rejected the request',
'User denied transaction signature.', 'User denied transaction signature',
'Cannot read properties of undefined' 'Cannot read properties of undefined'
] ]

View File

@ -0,0 +1,9 @@
export function truncateAddress(
address: `0x${string}`,
startLength = 6,
endLength = 4
) {
return `${address.substring(0, startLength)}...${address.substring(
address.length - endLength
)}`
}

View File

@ -257,9 +257,10 @@ em,
abbr[title], abbr[title],
dfn { dfn {
text-transform: none; text-transform: none;
text-decoration-color: var(--text-color-dimmed);
text-underline-offset: 0.15em;
font-style: normal; font-style: normal;
font-size: inherit; font-size: inherit;
border-bottom: 1px dashed var(--brand-grey-dimmed);
cursor: help; cursor: help;
font-feature-settings: inherit; font-feature-settings: inherit;
} }