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

fix(mobile): width display overflow #990

Merged
merged 7 commits into from
Jun 21, 2024
Merged

fix(mobile): width display overflow #990

merged 7 commits into from
Jun 21, 2024

Conversation

thinkasany
Copy link
Collaborator

[中文版模板 / Chinese template]

💡 Background and solution

  1. 移动端宽度不到400px, 去掉card中配置的width
  2. connect-modal footer mask 被left 挤出去了,既然用了绝对定位可以用transform: 'translateX(-50%)' 来水平居中。
    image

🔗 Related issue link

#989

Copy link

vercel bot commented Jun 20, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
ant-design-web3 ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 20, 2024 3:15pm

Copy link

changeset-bot bot commented Jun 20, 2024

🦋 Changeset detected

Latest commit: 9d37353

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 4 packages
Name Type
@ant-design/web3 Patch
@example/eth-web3js Patch
@example/ethers-v5 Patch
@example/ethers Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

github-actions bot commented Jun 20, 2024

Preview is ready

Copy link

codecov bot commented Jun 20, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (c73b22c) to head (9d37353).

Additional details and impacted files
@@            Coverage Diff            @@
##              main      #990   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          720       720           
  Lines        22209     22210    +1     
  Branches      1287      1287           
=========================================
+ Hits         22209     22210    +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -218,7 +218,8 @@ const getThemeStyle = (token: ConnectModalToken): CSSInterpolation => {
position: 'absolute',
bottom: '100%',
width: token.walletListWidth - token.paddingMD * 2,
Copy link
Collaborator

Choose a reason for hiding this comment

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

感觉这样治标不治本,如果外面的宽度再小一点,还是会露出来的,因为这个宽度还是比较大。

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

试了一下用 98%,在se下都不会超出

image

@@ -38,7 +38,7 @@ const App: React.FC = () => {
<div className={styles.cardBg}>
<span className={styles.title}>Crypto Input</span>
<Card>
<Flex vertical align="center" style={{ width: 400 }} gap={16}>
<Flex vertical align="center" gap={16}>
Copy link
Collaborator

Choose a reason for hiding this comment

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

这个会影响 PC 上面的显示吗?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

看了一下官网和preivew pc是一致的

image
image

@@ -217,8 +217,9 @@ const getThemeStyle = (token: ConnectModalToken): CSSInterpolation => {
content: '""',
position: 'absolute',
bottom: '100%',
width: token.walletListWidth - token.paddingMD * 2,
left: token.paddingMD,
width: '98%',
Copy link
Collaborator

Choose a reason for hiding this comment

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

直接用 walletListWidth 是不是就可以了?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

token.walletListWidth 是328,所以超出了,上面没超出是因为还有一个 100%在。
image

image

Copy link
Collaborator

Choose a reason for hiding this comment

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

有没有办法可以设置为实际的宽度,98% 有点 hack,理论上宽度很小的时候也会超出去,最好是样式可以设置为实际的宽度,不知道好不好搞,可以再看看

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

确实好像98看着不太严谨,我想到两种方案,或者可以看看有没有更好的建议:
方案一:100%,测试效果如下,这个颜色比较浅其实影响应该不大。
image

方案二:
width: calc(100% - ${token.paddingMD * 2});
未来token还方便通过config让用户自己定制这个的宽度间距。
这个api在antd中应用还挺多的,看起来表现也能解决问题。

image

为了展示的更明显,我改成了红色展示,专门测试的是最小的设备苹果se。

image image

Copy link
Collaborator

Choose a reason for hiding this comment

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

calc(100% - ${token.paddingMD * 2}); 这个可以的话就用这个,看上去语义上也合理

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

@thinkasany thinkasany merged commit 868e6fc into main Jun 21, 2024
12 checks passed
@thinkasany thinkasany deleted the fix-mobile branch June 21, 2024 03:25
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