Skip to content

refactor(suite): update layout size handling #19107

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

Merged
merged 7 commits into from
Jun 4, 2025

Conversation

seibei-iguchi
Copy link
Contributor

@seibei-iguchi seibei-iguchi commented May 22, 2025

πŸ”πŸ–₯️ Suite web test results: View in Currents

πŸ”πŸ–₯️ Suite desktop test results: View in Currents

@seibei-iguchi seibei-iguchi force-pushed the refactor/layout-size-change branch from 534d74b to ef7fe94 Compare May 22, 2025 12:58
@trezor-bot
Copy link

trezor-bot bot commented May 22, 2025

βœ… Previously successful run of [Test] PR Suite Desktop e2e tests workflow has been found.
⏭️ Skipping tests for this run.
πŸ’‘ If you are unsure about your latest changes, please rerun the workflow manually. (Use the Re-run all jobs option)

@seibei-iguchi seibei-iguchi self-assigned this May 22, 2025
@seibei-iguchi seibei-iguchi force-pushed the refactor/layout-size-change branch from 03060df to f0149da Compare May 22, 2025 16:39
@trezor-bot
Copy link

trezor-bot bot commented May 22, 2025

βœ… Previously successful run of [Test] PR Suite Desktop e2e tests workflow has been found.
⏭️ Skipping tests for this run.
πŸ’‘ If you are unsure about your latest changes, please rerun the workflow manually. (Use the Re-run all jobs option)

@seibei-iguchi seibei-iguchi force-pushed the refactor/layout-size-change branch from f0149da to 50bd138 Compare May 23, 2025 08:09
@trezor-bot
Copy link

trezor-bot bot commented May 23, 2025

βœ… Previously successful run of [Test] PR Suite Desktop e2e tests workflow has been found.
⏭️ Skipping tests for this run.
πŸ’‘ If you are unsure about your latest changes, please rerun the workflow manually. (Use the Re-run all jobs option)

2 similar comments
@trezor-bot
Copy link

trezor-bot bot commented May 23, 2025

βœ… Previously successful run of [Test] PR Suite Desktop e2e tests workflow has been found.
⏭️ Skipping tests for this run.
πŸ’‘ If you are unsure about your latest changes, please rerun the workflow manually. (Use the Re-run all jobs option)

@trezor-bot
Copy link

trezor-bot bot commented May 23, 2025

βœ… Previously successful run of [Test] PR Suite Desktop e2e tests workflow has been found.
⏭️ Skipping tests for this run.
πŸ’‘ If you are unsure about your latest changes, please rerun the workflow manually. (Use the Re-run all jobs option)

@seibei-iguchi seibei-iguchi force-pushed the refactor/layout-size-change branch from ad77368 to 5fc51f0 Compare May 27, 2025 07:33
@trezor-bot
Copy link

trezor-bot bot commented May 27, 2025

βœ… Previously successful run of [Test] PR Suite Desktop e2e tests workflow has been found.
⏭️ Skipping tests for this run.
πŸ’‘ If you are unsure about your latest changes, please rerun the workflow manually. (Use the Re-run all jobs option)

@seibei-iguchi seibei-iguchi moved this to πŸ”Ž Needs review in Suite Desktop May 27, 2025
@seibei-iguchi
Copy link
Contributor Author

@coderabbitai summary

@seibei-iguchi seibei-iguchi marked this pull request as ready for review May 27, 2025 07:37
@seibei-iguchi seibei-iguchi requested a review from a team as a code owner May 27, 2025 07:37
Copy link

coderabbitai bot commented May 27, 2025

Walkthrough

This update refactors responsive layout and breakpoint handling across the codebase. It removes the legacy system that relied on window size categories, pixel thresholds, and custom media query utilities, replacing it with a new, theme-driven breakpoint system defined in a central @trezor/theme module. The new system introduces standardized breakpoint constants, types, and helper functions for generating media queries and managing breakpoint flags. Redux state and selectors for window size are updated to store and expose breakpoint flags instead of raw dimensions or size labels. The Resize component now dispatches breakpoint flag updates based on media query listeners rather than window size events. Throughout the application, direct media query hooks and pixel-based checks are replaced with a unified useLayoutSize hook that provides boolean flags for each breakpoint. Related test files and deprecated style utilities are removed, and component logic is updated to use the new breakpoint flags for responsive rendering and layout.


πŸ“œ Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

πŸ“₯ Commits

Reviewing files that changed from the base of the PR and between f5633f9 and 5fc51f0.

πŸ“’ Files selected for processing (56)
  • packages/components/src/components/ResizableBox/ResizableBox.stories.tsx (0 hunks)
  • packages/components/src/components/ResizableBox/ResizableBox.tsx (5 hunks)
  • packages/components/src/components/Tabs/Tabs.tsx (2 hunks)
  • packages/components/src/config/variables.ts (1 hunks)
  • packages/styles/src/breakpoints.test.ts (0 hunks)
  • packages/styles/src/breakpoints.ts (0 hunks)
  • packages/styles/src/createRenderer.ts (0 hunks)
  • packages/styles/src/index.ts (0 hunks)
  • packages/styles/src/plugins/responsiveValues.test.ts (0 hunks)
  • packages/styles/src/plugins/responsiveValues.ts (0 hunks)
  • packages/styles/src/types.ts (1 hunks)
  • packages/styles/src/useStyles.ts (0 hunks)
  • packages/suite/src/actions/suite/__tests__/windowActions.test.ts (0 hunks)
  • packages/suite/src/actions/suite/constants/windowConstants.ts (1 hunks)
  • packages/suite/src/actions/suite/windowActions.ts (2 hunks)
  • packages/suite/src/components/guide/GuideRouter.tsx (3 hunks)
  • packages/suite/src/components/settings/SettingsSection.tsx (2 hunks)
  • packages/suite/src/components/suite/ChangeDeviceLabelForm.tsx (2 hunks)
  • packages/suite/src/components/suite/SecurityCheck/SecurityCheckLayout.tsx (2 hunks)
  • packages/suite/src/components/suite/layouts/LoggedOutLayout.tsx (2 hunks)
  • packages/suite/src/components/suite/layouts/SuiteLayout/PageHeader/HeaderActionButton.tsx (2 hunks)
  • packages/suite/src/components/suite/layouts/SuiteLayout/PageHeader/HeaderDropdown.tsx (2 hunks)
  • packages/suite/src/components/suite/layouts/SuiteLayout/PageHeader/TradeActions.tsx (3 hunks)
  • packages/suite/src/components/suite/layouts/SuiteLayout/Sidebar/NotificationDropdown.tsx (2 hunks)
  • packages/suite/src/components/suite/layouts/SuiteLayout/Sidebar/Sidebar.tsx (2 hunks)
  • packages/suite/src/components/suite/layouts/SuiteLayout/SuiteLayout.tsx (5 hunks)
  • packages/suite/src/components/suite/modals/ReduxModal/UserContextModal/StakeModal/StakeModal.tsx (2 hunks)
  • packages/suite/src/components/suite/modals/ReduxModal/UserContextModal/UnstakeModal/UnstakeModal.tsx (2 hunks)
  • packages/suite/src/components/suite/notifications/Notifications/NotificationGroup/NotificationList/NotificationView.tsx (2 hunks)
  • packages/suite/src/components/suite/section/SectionItem.tsx (1 hunks)
  • packages/suite/src/hooks/guide/useGuide.ts (1 hunks)
  • packages/suite/src/hooks/suite/useLayoutSize.ts (1 hunks)
  • packages/suite/src/reducers/suite/windowReducer.ts (3 hunks)
  • packages/suite/src/support/suite/Resize.tsx (1 hunks)
  • packages/suite/src/views/dashboard/AssetsView/AssetsView.tsx (3 hunks)
  • packages/suite/src/views/dashboard/PromoBanner.tsx (2 hunks)
  • packages/suite/src/views/dashboard/StakeEthCard/StakeEthCard.tsx (2 hunks)
  • packages/suite/src/views/onboarding/steps/SecurityCheck/SecurityCheck.tsx (4 hunks)
  • packages/suite/src/views/onboarding/steps/SelectBackupType/DefaultTag.tsx (1 hunks)
  • packages/suite/src/views/onboarding/steps/SelectBackupType/OptionWithContent.tsx (2 hunks)
  • packages/suite/src/views/onboarding/steps/SelectBackupType/SelectBackupType.tsx (3 hunks)
  • packages/suite/src/views/onboarding/steps/SelectBackupType/ShamirOptions.tsx (1 hunks)
  • packages/suite/src/views/settings/SettingsGeneral/SettingsGeneral.tsx (2 hunks)
  • packages/suite/src/views/wallet/send/Outputs/Amount/Amount.tsx (2 hunks)
  • packages/suite/src/views/wallet/send/index.tsx (3 hunks)
  • packages/suite/src/views/wallet/staking/components/EthStakingDashboard/components/EthStakingDashboard.tsx (2 hunks)
  • packages/suite/src/views/wallet/staking/components/SolStakingDashboard/SolStakingDashboard.tsx (2 hunks)
  • packages/suite/src/views/wallet/staking/components/StakingDashboard/components/EmptyStakingCard.tsx (1 hunks)
  • packages/suite/src/views/wallet/staking/components/StakingDashboard/components/StakingCard.tsx (2 hunks)
  • packages/suite/src/views/wallet/tokens/common/TokensTable/TokenRow.tsx (7 hunks)
  • packages/suite/src/views/wallet/trading/DCA/TradingDCALanding.tsx (3 hunks)
  • packages/suite/src/views/wallet/trading/common/TradingTransactions/TradingTransaction/TradingTransactionContainer.tsx (3 hunks)
  • packages/suite/src/views/wallet/trading/common/TradingTransactions/TradingTransaction/TradingTransactionProvider.tsx (2 hunks)
  • packages/suite/src/views/wallet/transactions/TradeBox/TradeBox.tsx (2 hunks)
  • packages/theme/src/breakpoints.ts (1 hunks)
  • packages/theme/src/index.ts (1 hunks)
✨ Finishing Touches
  • πŸ“ Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❀️ Share
πŸͺ§ Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@seibei-iguchi seibei-iguchi force-pushed the refactor/layout-size-change branch from 5fc51f0 to 56ec2ff Compare May 27, 2025 08:41
@trezor-bot
Copy link

trezor-bot bot commented May 27, 2025

βœ… Previously successful run of [Test] PR Suite Web e2e tests workflow has been found.
⏭️ Skipping tests for this run.
πŸ’‘ If you are unsure about your latest changes, please rerun the workflow manually. (Use the Re-run all jobs option)

@trezor-bot
Copy link

trezor-bot bot commented May 27, 2025

βœ… Previously successful run of [Test] PR Suite Desktop e2e tests workflow has been found.
⏭️ Skipping tests for this run.
πŸ’‘ If you are unsure about your latest changes, please rerun the workflow manually. (Use the Re-run all jobs option)

Copy link
Contributor

@jvaclavik jvaclavik left a comment

Choose a reason for hiding this comment

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

I like it very much! πŸ‘Œ

Just thinking if we can unify breakpoints, screen_query and useLayout to similar style and package. See my comment below

}: ResizableBoxProps) => {
const resizableBoxRef = useRef<HTMLDivElement>(null);
const rafRef = useRef<number | null>(null);
Copy link
Contributor

Choose a reason for hiding this comment

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

raf? royal air force? :D

Copy link
Contributor Author

Choose a reason for hiding this comment

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

requestAnimationFrame:)

@@ -3,7 +3,7 @@ import { ReactNode } from 'react';
import styled from 'styled-components';

import { Banner, Column } from '@trezor/components';
import { breakpointMediaQueries } from '@trezor/styles';
import { SCREEN_QUERY } from '@trezor/components/src/config/variables';
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: I suggest to import just the package:

import { variables } from '@trezor/components';

...

${variables.SCREEN_QUERY.ABOVE_DESKTOP} {

or export it explicitly in @trezor/components

Copy link
Contributor

Choose a reason for hiding this comment

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

Also thinking about refactoring naming and structure without keeping in mind our previous state.
It would be really nice have everything on the same place and not import it from 3 different packages with different naming conventions:

  • SCREEN_QUERY from @trezor/components
  • useLayoutSize from @trezor/hooks
  • breakpoints from @trezor/theme

Not sure if we are able to unify all of these or useLayoutSize must be somewhere else. In ideal world I would suggest to do something like this:

import { media } from '@trezor/???'; 

// media object
{
  query: {
    mobile: `@media ...`,
    aboveMobile: `@media ...`,
    ...
  }
  breakpoints: {
    mobile: 576,
    table: 768,
    ...
  }
  useQuery: fn
}

WDYT?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't want to touch SCREEN_QUERY as it's deprecated:) breakpoints are in theme to follow suit with other similar constants. useLayoutSize must be in hooks, because it depends on Redux.

};
default:
return state;
}
};

export const ResizableBox = ({
Copy link
Contributor

@jvaclavik jvaclavik Jun 3, 2025

Choose a reason for hiding this comment

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

Good job here, this component needed some love. Reducer and 100% values look much better than before

[layoutSize],
);
// The guide should be on top for smaller screens (below laptop size)
const isGuideOnTop = isBelowLaptop;
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: I suggest isGuideOverlayContent

Why: I had to test it in the app because I though it does overlay content all the time. This seems to me more descriptive what's actually hapening. Up to you.

@seibei-iguchi seibei-iguchi merged commit 4b8dbc0 into develop Jun 4, 2025
21 checks passed
@seibei-iguchi seibei-iguchi deleted the refactor/layout-size-change branch June 4, 2025 11:33
@github-project-automation github-project-automation bot moved this from πŸ”Ž Needs review to 🀝 Needs QA in Suite Desktop Jun 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: 🀝 Needs QA
Development

Successfully merging this pull request may close these issues.

2 participants