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 page header buttons #3491

Merged
merged 9 commits into from
Sep 24, 2024
Merged

Fix mobile page header buttons #3491

merged 9 commits into from
Sep 24, 2024

Conversation

joel-jeremy
Copy link
Contributor

No description provided.

@actual-github-bot actual-github-bot bot changed the title Fix button2 styles [WIP] Fix button2 styles Sep 23, 2024
Copy link
Contributor

coderabbitai bot commented Sep 23, 2024

Walkthrough

The pull request introduces several modifications across various components in the desktop client. Key changes include the addition of a new utility function for managing hover styles in the Button2.tsx file, updates to styling approaches by removing the glamor library in favor of inline styles, and a transition from hover to pressed interaction states for multiple button components. The overall focus is on refining style management and improving the interaction model across the application.

Changes

File Path Change Summary
packages/desktop-client/src/components/common/Button2.tsx Introduces _getHoveredStyles utility function for hover styles, refactors defaultButtonClassName to use useMemo for performance optimization.
packages/desktop-client/src/components/mobile/MobileBackButton.tsx Removes glamor for styling, replaces hover styles with inline styles, retaining only the margin property.
packages/desktop-client/src/components/mobile/accounts/AccountTransactions.jsx Replaces Text component with Button for account name, allowing dynamic styling and handling of click events.
packages/desktop-client/src/components/mobile/accounts/Accounts.jsx Removes glamor for styling, simplifies button styling to inline styles with only margin.
packages/desktop-client/src/components/mobile/budget/BudgetTable.jsx Removes noTapHighlight style, updates button styling to apply background color only on data-pressed state, and modifies SvgLogo component styling.
packages/desktop-client/src/components/mobile/transactions/AddTransactionButton.tsx Eliminates glamor styling, simplifies button styling to inline styles with only margin.
packages/desktop-client/src/components/Page.tsx Modifies MobilePageHeader styles to apply child element styles using a new CSS-like syntax, removing direct color property from the View.
packages/desktop-client/src/components/mobile/transactions/FocusableAmountInput.tsx Changes styling trigger from :hover to &[data-pressed], adjusting background color behavior based on pressed state.
packages/desktop-client/src/components/mobile/MobileNavTabs.tsx Updates inline style from background to backgroundColor for better clarity in CSS property usage.

Possibly related PRs

  • Fix React Aria Button hover styles  #3453: The changes in Button2.tsx regarding the management of hover and pressed states using custom data attributes are related to the modifications made in the same file, which also focuses on optimizing hover styles.
  • [Mobile] Fix #3214 - Pull down to refresh triggering clicks on budget cells #3374: The refactor of the CellValue component to enhance its composability and styling approach is relevant as it aligns with the main PR's focus on improving the Button component's styling and interaction logic.
  • fix modals on mobile BudgetTable #3487: The changes in BudgetTable.jsx that involve updating modal references and ensuring consistent behavior may relate to the overall improvements in user interaction and component behavior, similar to the enhancements made in the main PR for the Button component.

Suggested labels

#sparkles: Merged, #white_check_mark: Approved

Suggested reviewers

  • youngcw
  • MatissJanis

Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between ad8e27e and fd54c52.

Files ignored due to path filters (4)
  • packages/desktop-client/e2e/mobile.test.js-snapshots/Mobile-loads-the-budget-page-with-budgeted-amounts-1-chromium-linux.png is excluded by !**/*.png
  • packages/desktop-client/e2e/mobile.test.js-snapshots/Mobile-loads-the-budget-page-with-budgeted-amounts-2-chromium-linux.png is excluded by !**/*.png
  • packages/desktop-client/e2e/mobile.test.js-snapshots/Mobile-loads-the-budget-page-with-budgeted-amounts-3-chromium-linux.png is excluded by !**/*.png
  • upcoming-release-notes/3491.md is excluded by !**/*.md
Files selected for processing (9)
  • packages/desktop-client/src/components/Page.tsx (1 hunks)
  • packages/desktop-client/src/components/common/Button2.tsx (3 hunks)
  • packages/desktop-client/src/components/mobile/MobileBackButton.tsx (2 hunks)
  • packages/desktop-client/src/components/mobile/MobileNavTabs.tsx (1 hunks)
  • packages/desktop-client/src/components/mobile/accounts/AccountTransactions.jsx (2 hunks)
  • packages/desktop-client/src/components/mobile/accounts/Accounts.jsx (1 hunks)
  • packages/desktop-client/src/components/mobile/budget/BudgetTable.jsx (4 hunks)
  • packages/desktop-client/src/components/mobile/transactions/AddTransactionButton.tsx (1 hunks)
  • packages/desktop-client/src/components/mobile/transactions/FocusableAmountInput.tsx (1 hunks)
Files skipped from review as they are similar to previous changes (9)
  • packages/desktop-client/src/components/Page.tsx
  • packages/desktop-client/src/components/common/Button2.tsx
  • packages/desktop-client/src/components/mobile/MobileBackButton.tsx
  • packages/desktop-client/src/components/mobile/MobileNavTabs.tsx
  • packages/desktop-client/src/components/mobile/accounts/AccountTransactions.jsx
  • packages/desktop-client/src/components/mobile/accounts/Accounts.jsx
  • packages/desktop-client/src/components/mobile/budget/BudgetTable.jsx
  • packages/desktop-client/src/components/mobile/transactions/AddTransactionButton.tsx
  • packages/desktop-client/src/components/mobile/transactions/FocusableAmountInput.tsx

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

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.
    -- Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    -- @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 generate unit testing code.
    -- @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.

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 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.

Copy link

netlify bot commented Sep 23, 2024

Deploy Preview for actualbudget ready!

Name Link
🔨 Latest commit fd54c52
🔍 Latest deploy log https://app.netlify.com/sites/actualbudget/deploys/66f31683b3d7c10008a33f60
😎 Deploy Preview https://deploy-preview-3491.demo.actualbudget.org
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link
Contributor

github-actions bot commented Sep 23, 2024

Bundle Stats — desktop-client

Hey there, this message comes from a GitHub action that helps you and reviewers to understand how these changes affect the size of this project's bundle.

As this PR is updated, I'll keep you updated on how the bundle size is impacted.

Total

Files count Total bundle size % Changed
9 5.29 MB → 5.29 MB (-1.46 kB) -0.03%
Changeset
File Δ Size
src/components/Page.tsx 📈 +121 B (+4.43%) 2.67 kB → 2.78 kB
src/components/mobile/accounts/AccountTransactions.jsx 📈 +146 B (+2.26%) 6.3 kB → 6.44 kB
src/components/mobile/transactions/FocusableAmountInput.tsx 📈 +9 B (+0.15%) 5.88 kB → 5.89 kB
src/components/mobile/MobileNavTabs.tsx 📈 +5 B (+0.10%) 4.81 kB → 4.82 kB
src/components/mobile/budget/BudgetTable.jsx 📉 -768 B (-1.43%) 52.47 kB → 51.72 kB
src/components/mobile/accounts/Accounts.jsx 📉 -226 B (-2.98%) 7.4 kB → 7.18 kB
src/components/common/Button2.tsx 📉 -323 B (-5.97%) 5.28 kB → 4.97 kB
src/components/mobile/MobileBackButton.tsx 📉 -256 B (-26.10%) 981 B → 725 B
src/components/mobile/transactions/AddTransactionButton.tsx 📉 -202 B (-28.33%) 713 B → 511 B
View detailed bundle breakdown

Added

No assets were added

Removed

No assets were removed

Bigger

No assets were bigger

Smaller

Asset File Size % Changed
static/js/narrow.js 81.24 kB → 80.41 kB (-848 B) -1.02%
static/js/index.js 3.31 MB → 3.31 MB (-646 B) -0.02%

Unchanged

Asset File Size % Changed
static/js/resize-observer.js 18.37 kB 0%
static/js/usePreviewTransactions.js 1.59 kB 0%
static/js/BackgroundImage.js 122.29 kB 0%
static/js/indexeddb-main-thread-worker-e59fee74.js 13.5 kB 0%
static/js/AppliedFilters.js 20.97 kB 0%
static/js/wide.js 225.27 kB 0%
static/js/ReportRouter.js 1.5 MB 0%

Copy link
Contributor

github-actions bot commented Sep 23, 2024

Bundle Stats — loot-core

Hey there, this message comes from a GitHub action that helps you and reviewers to understand how these changes affect the size of this project's bundle.

As this PR is updated, I'll keep you updated on how the bundle size is impacted.

Total

Files count Total bundle size % Changed
1 1.19 MB 0%

Changeset

No files were changed

View detailed bundle breakdown

Added

No assets were added

Removed

No assets were removed

Bigger

No assets were bigger

Smaller

No assets were smaller

Unchanged

Asset File Size % Changed
kcab.worker.js 1.19 MB 0%

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Outside diff range and nitpick comments (4)
packages/desktop-client/src/components/mobile/accounts/Accounts.jsx (1)

180-182: Approved: Improved mobile interaction and style consistency

The changes enhance the mobile user experience by switching from a hover effect to a pressed state, which is more appropriate for touch devices. Additionally, the use of backgroundColor instead of background improves consistency with React and JavaScript naming conventions.

For consistency, consider applying similar changes to other buttons in the component if they haven't been updated yet. This will ensure a uniform interaction model across the mobile interface.

packages/desktop-client/src/components/mobile/accounts/AccountTransactions.jsx (1)

130-152: Great improvement to user interaction and accessibility.

The replacement of the Text component with a Button component significantly enhances the user experience and accessibility of the account name element. The use of glamor for styling and the onPress prop are well-suited for mobile interactions.

A minor suggestion for improvement:

Consider extracting the inline styles for the Text component (lines 143-148) into a separate style object or using a styled component for better maintainability. For example:

const accountNameTextStyle = {
  fontSize: 17,
  fontWeight: 500,
  ...styles.underlinedText,
  ...styles.lineClamp(2),
};

// Then in the JSX:
<Text style={accountNameTextStyle}>
  {`${account.closed ? 'Closed: ' : ''}${account.name}`}
</Text>

This change would improve code readability and make it easier to maintain or update the text styles in the future.

packages/desktop-client/src/components/mobile/budget/BudgetTable.jsx (2)

788-791: Consider enhancing the pressed state visual feedback.

The removal of noTapHighlight and addition of data-pressed state improves consistency. However, the current implementation uses a transparent background for the pressed state, which might not provide sufficient visual feedback to users.

Consider adding a subtle background color or other visual indicator for the pressed state to improve user experience. For example:

 '&[data-pressed]': {
-  backgroundColor: 'transparent',
+  backgroundColor: theme.buttonBackgroundHover,
 },

1938-1960: Enhanced month selection with improved interaction

The replacement of the Text component with a Button component improves accessibility and user interaction. The styling is consistent with other buttons in the component, and the underlined text maintains the visual cue for interaction.

Consider adding an aria-label to the button to improve accessibility further. For example:

 <Button
   variant="bare"
+  aria-label={`Select month: ${monthUtils.format(month, 'MMMM yyyy')}`}
   className={String(
     // ... (existing code)
   )}
   onPress={() => {
     onOpenMonthMenu?.(month);
   }}
 >
   // ... (existing code)
 </Button>
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 09e3721 and b2a6c27.

Files selected for processing (8)
  • packages/desktop-client/src/components/common/Button2.tsx (3 hunks)
  • packages/desktop-client/src/components/mobile/MobileBackButton.tsx (1 hunks)
  • packages/desktop-client/src/components/mobile/MobileNavTabs.tsx (1 hunks)
  • packages/desktop-client/src/components/mobile/accounts/AccountTransactions.jsx (3 hunks)
  • packages/desktop-client/src/components/mobile/accounts/Accounts.jsx (1 hunks)
  • packages/desktop-client/src/components/mobile/budget/BudgetTable.jsx (5 hunks)
  • packages/desktop-client/src/components/mobile/transactions/AddTransactionButton.tsx (1 hunks)
  • packages/desktop-client/src/components/mobile/transactions/FocusableAmountInput.tsx (1 hunks)
Files skipped from review due to trivial changes (1)
  • packages/desktop-client/src/components/mobile/MobileNavTabs.tsx
Additional comments not posted (11)
packages/desktop-client/src/components/mobile/transactions/AddTransactionButton.tsx (1)

31-33: Improved button interaction and styling

The changes to the button styling are well-implemented and align with the PR objectives:

  1. Replacing :hover with &[data-pressed] improves the mobile user experience by providing appropriate feedback for touch interactions.
  2. Changing background to backgroundColor is more specific and follows CSS best practices.
  3. The use of theme variables (theme.mobileHeaderText and theme.mobileHeaderTextHover) maintains consistency in the design system.

These updates enhance both the functionality and maintainability of the component.

packages/desktop-client/src/components/mobile/MobileBackButton.tsx (1)

29-31: Improved mobile interaction and CSS naming

These changes enhance the button's behavior and styling:

  1. Switching from data-hovered to data-pressed improves the mobile user experience, as it's more relevant for touch interfaces.
  2. Updating background to backgroundColor adheres to the camelCase convention, improving code consistency.

These modifications align well with the PR objective to fix button2 styles and enhance overall code quality.

packages/desktop-client/src/components/mobile/accounts/AccountTransactions.jsx (2)

10-10: LGTM: New imports support the component changes.

The addition of css from 'glamor' and Button from '../../common/Button2' aligns well with the modifications made to the AccountName component, supporting the shift from a Text component to a styled Button component.

Also applies to: 36-36


Line range hint 1-290: Summary: Positive enhancement to mobile user experience.

The changes in this file, particularly to the AccountName component, represent a significant improvement in the mobile user experience. By converting the account name from a simple text element to an interactive button, the code now provides better accessibility and clearer user interaction cues. The use of glamor for styling and the implementation of a pressed state further enhance the mobile-friendly nature of the component.

These modifications align well with modern React and mobile development best practices, improving both the functionality and the maintainability of the code. The overall impact of these changes is positive, contributing to a more robust and user-friendly mobile interface for account transactions.

packages/desktop-client/src/components/mobile/budget/BudgetTable.jsx (3)

983-986: Consistent styling with ExpenseGroupHeader

The changes here mirror those in the ExpenseGroupHeader component, maintaining consistency in the UI.

Please refer to the previous comment about enhancing the pressed state visual feedback, as the same suggestion applies here.


1929-1932: Improved user feedback for button interaction

The addition of pressed state styles enhances the user experience by providing clear visual feedback. The use of theme variables ensures consistency with the overall design.


1973-1976: Consistent styling with previous month button

The changes here mirror those made to the previous month button, maintaining consistency in the UI and user interaction. The use of theme variables ensures a cohesive design.

packages/desktop-client/src/components/common/Button2.tsx (4)

3-3: Importing useCallback

The addition of useCallback to the imports is appropriate for optimizing performance through memoization.


108-113: Refactoring hover styles into _getHoveredStyles

Encapsulating hover styles within the _getHoveredStyles function enhances code readability and reusability.


157-185: Memoization of defaultButtonClassName with useCallback

Using useCallback to memoize defaultButtonClassName is effective. The dependency array [Icon, bounce, variant, variantWithDisabled] correctly includes all external variables used within the callback.


187-198: Memoization of buttonClassName with useCallback

The useCallback hook for buttonClassName correctly optimizes the function by memoizing it based on the className prop. This prevents unnecessary recalculations when className remains unchanged.

Comment on lines +259 to 261
'&[data-pressed]': {
backgroundColor: 'transparent',
},
Copy link
Contributor

Choose a reason for hiding this comment

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

Approved: Improved interaction model for button styles

The change from hover to pressed state is a good improvement, especially for mobile devices. This aligns well with the PR objective of fixing button2 styles.

Consider adding a subtle transition effect for smoother visual feedback:

 '&[data-pressed]': {
   backgroundColor: 'transparent',
+  transition: 'background-color 0.2s ease',
 },

This will create a smooth fade effect when the button is pressed, enhancing the user experience.

For better accessibility, consider adding an aria-pressed attribute to the button that changes with the pressed state. This will improve the experience for users relying on screen readers.

Committable suggestion was skipped due to low confidence.

@joel-jeremy joel-jeremy changed the title [WIP] Fix button2 styles Fix button2 styles Sep 23, 2024
@joel-jeremy joel-jeremy changed the title Fix button2 styles Fix mobile page header buttons Sep 23, 2024
@joel-jeremy joel-jeremy added this to the v24.10.0 milestone Sep 23, 2024
Comment on lines -199 to -201
{Icon && (
<Icon style={{ height: 15, paddingLeft: 5, paddingRight: 3 }} />
)}
Copy link
Member

Choose a reason for hiding this comment

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

❓ question: ‏intentionally removing this? If so: might as well remove the Icon prop.

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 think we should just remove this Icon since we can just pass the Icon as part of the children prop:

<Button>
   <Icon />
    ....
</Button>

Copy link
Member

Choose a reason for hiding this comment

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

We can definitely remove it now since it's not used.

The main reason for adding it as a prop instead of passing in children was the visual appearance. The icon didn't really look nice because of the large left margin the button automatically applies.

@MatissJanis MatissJanis self-assigned this Sep 24, 2024
@MatissJanis
Copy link
Member

@CodeRabbit review

Copy link
Contributor

coderabbitai bot commented Sep 24, 2024

Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Outside diff range and nitpick comments (1)
packages/desktop-client/src/components/Page.tsx (1)

60-66: Improved styling approach for mobile header buttons

The changes effectively address the PR objective of fixing mobile page header buttons. The new styling approach using CSS-in-JS syntax for child elements improves maintainability and separation of concerns. The addition of a pressed state for buttons enhances user feedback, which is crucial for mobile interfaces.

Consider extracting the styles into a separate constant or using a CSS-in-JS library like styled-components for better organization. For example:

const mobileHeaderStyles = {
  backgroundColor: theme.mobileHeaderBackground,
  '& *': {
    color: theme.mobileHeaderText,
  },
  '& button[data-pressed]': {
    backgroundColor: theme.mobileHeaderTextHover,
  },
};

// Then in the component:
<View style={{ ...mobileHeaderStyles, ...style }}>

This approach would make the component more readable and easier to maintain.

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between b2a6c27 and ad8e27e.

Files ignored due to path filters (4)
  • packages/desktop-client/e2e/mobile.test.js-snapshots/Mobile-loads-the-budget-page-with-budgeted-amounts-1-chromium-linux.png is excluded by !**/*.png
  • packages/desktop-client/e2e/mobile.test.js-snapshots/Mobile-loads-the-budget-page-with-budgeted-amounts-2-chromium-linux.png is excluded by !**/*.png
  • packages/desktop-client/e2e/mobile.test.js-snapshots/Mobile-loads-the-budget-page-with-budgeted-amounts-3-chromium-linux.png is excluded by !**/*.png
  • upcoming-release-notes/3491.md is excluded by !**/*.md
Files selected for processing (7)
  • packages/desktop-client/src/components/Page.tsx (1 hunks)
  • packages/desktop-client/src/components/common/Button2.tsx (3 hunks)
  • packages/desktop-client/src/components/mobile/MobileBackButton.tsx (2 hunks)
  • packages/desktop-client/src/components/mobile/accounts/AccountTransactions.jsx (2 hunks)
  • packages/desktop-client/src/components/mobile/accounts/Accounts.jsx (1 hunks)
  • packages/desktop-client/src/components/mobile/budget/BudgetTable.jsx (4 hunks)
  • packages/desktop-client/src/components/mobile/transactions/AddTransactionButton.tsx (1 hunks)
Files skipped from review as they are similar to previous changes (6)
  • packages/desktop-client/src/components/common/Button2.tsx
  • packages/desktop-client/src/components/mobile/MobileBackButton.tsx
  • packages/desktop-client/src/components/mobile/accounts/AccountTransactions.jsx
  • packages/desktop-client/src/components/mobile/accounts/Accounts.jsx
  • packages/desktop-client/src/components/mobile/budget/BudgetTable.jsx
  • packages/desktop-client/src/components/mobile/transactions/AddTransactionButton.tsx

@joel-jeremy joel-jeremy merged commit 2acf996 into master Sep 24, 2024
20 checks passed
@joel-jeremy joel-jeremy deleted the button2-fix-styles branch September 24, 2024 20:02
This was referenced Oct 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants