Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add dynamically resizing label able to fill up horizontal space #1396

Merged
merged 10 commits into from
May 9, 2024

Conversation

csillag
Copy link
Contributor

@csillag csillag commented Apr 30, 2024

Improve how we use horizontal space. When working with small-ish vertical space, instead of always shortening text to a very short predefined value, try to fill up the available space.

Changes cleared by @donouwens (a while back).

See #1290 for the background and context.

This implementation is using JS code for the adaptive dynamic resizing.
We might want to use a pure-CSS implementation instead if this, for simplicity.

Copy link

github-actions bot commented Apr 30, 2024

Deployed to Cloudflare Pages

Latest commit: 95682bc7700963795cf76cc66898425d56fc62c4
Status:✅ Deploy successful!
Preview URL: https://9f9822a6.oasis-explorer.pages.dev

@csillag
Copy link
Contributor Author

csillag commented Apr 30, 2024

(Code mostly extracted from the Pontus-X branch)

@csillag csillag changed the title Add dynamically resizing component able to fill up space Add dynamically resizing label able to fill up horizontal space Apr 30, 2024
@csillag csillag force-pushed the csillag/adaptive-text-shortener branch from 2632cce to 68e53c3 Compare April 30, 2024 21:06
@csillag csillag mentioned this pull request Apr 30, 2024
@csillag csillag force-pushed the csillag/adaptive-text-shortener branch from 68e53c3 to 97fbd82 Compare April 30, 2024 21:17
@csillag csillag force-pushed the csillag/adaptive-text-shortener branch from 97fbd82 to 44e0504 Compare May 7, 2024 13:16
@csillag csillag marked this pull request as ready for review May 7, 2024 13:18
@csillag csillag requested review from lukaw3d, buberdds and lubej as code owners May 7, 2024 13:18
@csillag csillag requested a review from lukaw3d May 7, 2024 23:23
@csillag csillag force-pushed the csillag/adaptive-text-shortener branch 2 times, most recently from d2865f0 to 24d07bd Compare May 8, 2024 13:17
src/app/components/AdaptiveTrimmer/MaybeWithTooltip.tsx Outdated Show resolved Hide resolved
}

export const AccountLink: FC<Props> = ({ scope, address, alwaysTrim }) => {
export const AccountLink: FC<Props> = ({ scope, address, alwaysTrim, extraTooltip, labelOnly }) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • "Emitting contract" is misbehaving a bit
  • From 0x0000000000000000000000000000000000000000 isn't getting trimmed
  • 10000000000000000000000000000 value is a separate issue
Before After
explorer dev oasis io_mainnet_sapphire_tx_0x3f80bf8a68cf888ad98cf2d4b84504ad64f19f554942f0a9a917f43afd85c202 625b2404 oasis-explorer pages dev_mainnet_sapphire_tx_0x3f80bf8a68cf888ad98cf2d4b84504ad64f19f554942f0a9a917f43afd85c202

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem with the from and to fields is that the auto-trimming only works if no overflow / scrolling is happening in the DOM above the component that is displaying the address. If the overflow is happening in a higher level, then we can't detect it in the adaptive trimmer.

The way to ensure this is to go through the dom level by level, and boxing everything with max-width or similar CSS features. However, here we are inside a table, which doesn't support max-width, as far as I know.

On the short term, I added a switch called alwaysTrimOnTable, which we can set when using the AccountLink inside a table (or similar environments) to disable the adaptive behavior, and fall back to fixed length.

This gets us:
image

Trimming too much is still better then hiding the stuff in an overflow, I guess.

This could be improved, but I would rather return to this after the new event-related stuff has landed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • "Emitting contract" is misbehaving a bit

That one, we can solve easily.

image

src/app/components/Account/AccountLink.tsx Outdated Show resolved Hide resolved
@csillag csillag force-pushed the csillag/adaptive-text-shortener branch 2 times, most recently from 126be85 to 7ec70ee Compare May 9, 2024 04:44
@csillag csillag force-pushed the csillag/adaptive-text-shortener branch from 7ec70ee to 95682bc Compare May 9, 2024 04:47
@csillag csillag enabled auto-merge May 9, 2024 04:48
@csillag csillag merged commit f41035a into master May 9, 2024
7 checks passed
@csillag csillag deleted the csillag/adaptive-text-shortener branch May 9, 2024 04:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants