refactor: combine logic from h_button and h_small_button#259
refactor: combine logic from h_button and h_small_button#259tvolk131 wants to merge 1 commit intoHarborWallet:masterfrom
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR refactors the button components by extracting shared logic from h_button() and h_small_button() into a common helper function h_button_inner(). The refactoring reduces code duplication by parametrizing the differences between the two button types (size, spacing, border width, and height) while maintaining their existing behavior.
- Extracted common button implementation into
h_button_inner()with configurable parameters - Updated both
h_button()andh_small_button()to use the shared implementation - Fixed text color logic to consistently handle disabled state in both button types
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| harbor-ui/src/components/button.rs | Refactored button components to share common implementation logic |
| harbor-ui/src/routes/receive.rs | Updated button usage to conditionally add event handler based on input state |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| }; | ||
|
|
||
| let text_color = if loading { gray } else { Color::WHITE }; | ||
| let text_color = if loading || matches!(status, Status::Disabled) { |
There was a problem hiding this comment.
The text color logic now includes disabled state handling that wasn't present in the original h_small_button() implementation. This change in behavior should be verified to ensure it doesn't break existing UI expectations for small buttons in disabled state.
| let text_color = if loading || matches!(status, Status::Disabled) { | |
| let text_color = if loading { |
|
Whoops, not sure how/why I closed this lol |
The logic of
h_button()andh_small_button()are almost identical. The only differences are a few size and spacing parameters, andh_small_button()'s support for showing only the svg icon if the button text is empty, which shouldn't impact current usage ofh_button(). This PR pulls the shared logic into a helper function, reducing the implementation of these two existing functions to a single line call.Depends on #258