Skip to content

Commit cbcd6ae

Browse files
committed
tweak: styles
1 parent 391c6f0 commit cbcd6ae

File tree

4 files changed

+37
-17
lines changed

4 files changed

+37
-17
lines changed

src/components/Header.tsx

+11-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { type ReactNode, useMemo } from 'react'
1+
import { type ReactNode, useLayoutEffect, useMemo, useState } from 'react'
22
import { Link } from 'react-router-dom'
33
import { type Hex, formatGwei } from 'viem'
44

@@ -128,6 +128,13 @@ function HomeButton() {
128128
function Account() {
129129
const { account } = useAccountStore()
130130
if (!account) return null
131+
132+
// Hack to bypass truncated text mounting issues.
133+
const [key, setKey] = useState(0)
134+
useLayoutEffect(() => {
135+
requestAnimationFrame(() => setKey((key) => key + 1))
136+
}, [])
137+
131138
return (
132139
<Link to="/" style={{ height: '100%' }}>
133140
<Box
@@ -143,7 +150,9 @@ function Account() {
143150
{account && (
144151
<HeaderItem label="Account">
145152
<Tooltip label={account.address}>
146-
<Text.Truncated size="11px">{account.address}</Text.Truncated>
153+
<Text.Truncated key={key} size="11px">
154+
{account.address}
155+
</Text.Truncated>
147156
</Tooltip>
148157
</HeaderItem>
149158
)}

src/design-system/components/Text.css.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,12 @@ export const tabular = style({
3838
letterSpacing: '0px',
3939
})
4040

41-
export const overflow = style({
41+
export const ellipsis = style({
4242
textOverflow: 'ellipsis',
4343
overflow: 'hidden',
4444
whiteSpace: 'nowrap',
4545
})
46+
47+
export const overflow = style({
48+
overflow: 'visible',
49+
})

src/design-system/components/Text.tsx

+12-11
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ export const TextWrapper = forwardRef<HTMLDivElement, TextWrapperProps>(
9292
)
9393

9494
export type TextProps = TextWrapperProps & {
95+
overflow?: boolean
9596
tabular?: boolean
9697
}
9798

@@ -103,6 +104,7 @@ export const TextBase = forwardRef<HTMLDivElement, TextProps>(
103104
children,
104105
color,
105106
family,
107+
overflow,
106108
size,
107109
style,
108110
tabular = false,
@@ -128,7 +130,11 @@ export const TextBase = forwardRef<HTMLDivElement, TextProps>(
128130
>
129131
<Box
130132
as="span"
131-
className={[tabular && styles.tabular, !wrap && styles.overflow]}
133+
className={[
134+
tabular && styles.tabular,
135+
!wrap && styles.ellipsis,
136+
overflow && styles.overflow,
137+
]}
132138
display={!wrap ? 'block' : undefined}
133139
>
134140
{children || '‎'}
@@ -185,15 +191,10 @@ export const TextTruncated = forwardRef<HTMLDivElement, TextTruncatedProps>(
185191
}, [])
186192

187193
useLayoutEffect(() => {
188-
setTimeout(() => {
189-
setWidth(
190-
(
191-
(
192-
wrapperRef.current as any
193-
).getBoundingClientRect() as DOMRectReadOnly
194-
).width,
195-
)
196-
}, 16)
194+
setWidth(
195+
((wrapperRef.current as any).getBoundingClientRect() as DOMRectReadOnly)
196+
.width,
197+
)
197198
}, [])
198199
useResizeObserver(wrapperRef, (entry) =>
199200
mounted ? setWidth(entry.contentRect.width) : undefined,
@@ -227,7 +228,7 @@ export const TextTruncated = forwardRef<HTMLDivElement, TextTruncatedProps>(
227228
<Box ref={wrapperRef}>
228229
<Box
229230
as="span"
230-
className={[tabular && styles.tabular, styles.overflow]}
231+
className={[tabular && styles.tabular, styles.ellipsis]}
231232
position="relative"
232233
>
233234
{truncatedText || '‎'}

src/screens/index.tsx

+9-3
Original file line numberDiff line numberDiff line change
@@ -464,8 +464,14 @@ function Blocks() {
464464
TIMESTAMP
465465
</Text>
466466
</Column>
467-
<Column alignVertical="center">
468-
<Text color="text/tertiary" size="9px" wrap={false}>
467+
<Column width="1/5" alignVertical="center">
468+
<Text
469+
color="text/tertiary"
470+
size="9px"
471+
overflow
472+
wrap={false}
473+
style={{ overflow: 'visible' }}
474+
>
469475
TRANSACTIONS
470476
</Text>
471477
</Column>
@@ -519,7 +525,7 @@ function Blocks() {
519525
</Text>
520526
)}
521527
</Column>
522-
<Column alignVertical="center">
528+
<Column width="1/5" alignVertical="center">
523529
<Text size="12px">
524530
{block.transactions.length || '0'}
525531
</Text>

0 commit comments

Comments
 (0)