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

Updated button, alert card and back button stories #137

Merged
merged 2 commits into from
Oct 15, 2024
Merged

Conversation

rachana-egov
Copy link
Contributor

No description provided.

Copy link

coderabbitai bot commented Oct 15, 2024

Walkthrough

The pull request introduces various modifications across several Dart files within the Flutter project. Key changes include updates to the IframeWidget for improved DOM manipulation, adjustments to the main.dart file for theme settings, and enhancements to story components for buttons and info cards. The changes also involve renaming and restructuring stories for better clarity and functionality, including the addition of new interactive features in the InfoCard and button stories.

Changes

File Path Change Summary
flutter/digit-ui-components/storybook/lib/iframe/iframe_widget.dart Updated DOM manipulation logic, introduced mainContent, added conditional content removal, and improved error handling messages.
flutter/digit-ui-components/storybook/lib/main.dart Added themeMode: ThemeMode.light to MaterialApp, updated localization data, and modified story functions.
flutter/digit-ui-components/storybook/lib/widgets/atoms/Info_card_stories.dart Renamed story names for better categorization, added boolean knobs for widget visibility, and updated InfoCard properties.
flutter/digit-ui-components/storybook/lib/widgets/atoms/back_button_stories.dart Renamed stories and updated DigitBackButton configurations, enhancing customization for back button stories.
flutter/digit-ui-components/storybook/lib/widgets/atoms/button_stories.dart Changed function name to buttonStories, updated button states management, and improved naming conventions for clarity.

Suggested reviewers

  • jagankumar-egov

Poem

🐇 In the meadow where the buttons play,
New stories bloom, brightening the day.
With themes so light and cards that cheer,
Each click and tap brings joy near.
Hopping through code, we dance and sing,
Celebrating the changes that new features bring! 🌼


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

@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: 10

🧹 Outside diff range and nitpick comments (11)
flutter/digit-ui-components/storybook/lib/widgets/atoms/back_button_stories.dart (2)

20-20: Consider a more descriptive name for the story

The story name has been changed from "Double arrow" to "Backlink 1". While this new name is more consistent with the other stories, it loses some descriptive information about the button's appearance. Consider a name that combines both aspects, such as "Backlink 1 - Double Arrow".

The addition of the digitBackButtonThemeData configuration is a good improvement. It allows for more customization and responsiveness:

  1. The icon size adapts to the screen width, which is good for responsiveness.
  2. The color is set using the theme, which ensures consistency with the overall design.

Also applies to: 26-36


Line range hint 43-58: Consider a more descriptive name and potential refactoring

Similar to the previous story, the name has been changed from "Arrow with circle" to "Backlink 2". Consider a name that retains some description of the button's appearance, such as "Backlink 2 - Circled Arrow".

The theme configuration is very similar to the first story, with only the icon changing. To reduce code duplication, consider extracting the common parts of the theme configuration into a separate function or constant. This would make the stories more maintainable and easier to update in the future.

Here's a potential refactor to reduce duplication:

DigitBackButtonThemeData getCommonTheme(BuildContext context) {
  return const DigitBackButtonThemeData().copyWith(
    context: context,
    backDigitButtonIcon: Icon(
      // Icon can be passed as a parameter if needed
      Icons.arrow_circle_left_outlined,
      size: MediaQuery.of(context).size.width < 500
          ? Theme.of(context).spacerTheme.spacer5
          : Theme.of(context).spacerTheme.spacer6,
      color: Theme.of(context).colorTheme.primary.primary2,
    ),
  );
}

// In the story:
digitBackButtonThemeData: getCommonTheme(context),

This approach would make it easier to maintain consistent styling across different back button variants.

flutter/digit-ui-components/storybook/lib/main.dart (1)

79-79: LGTM! Consider dynamic theming for better user experience.

The addition of themeMode: ThemeMode.light ensures a consistent light theme across the app. However, for improved user experience, consider implementing dynamic theming that respects the user's system preferences.

You could use ThemeMode.system instead, which automatically adapts to the user's system settings:

themeMode: ThemeMode.system,
flutter/digit-ui-components/storybook/lib/widgets/atoms/button_stories.dart (5)

22-45: Approved: Enhanced interactivity and clarity for Primary Button story

The changes to the Primary Button story are well-implemented:

  1. The new option knob for disabled states enhances testing capabilities.
  2. The updated label to "Primary Button" and size option to "Size of button" improve clarity.
  3. The isDisabled property is correctly set based on user selection.

These improvements make the story more interactive and user-friendly.

Consider simplifying the isDisabled logic:

- bool isDisabled = false;
- if (fieldState == 'disabled') {
-   isDisabled = true;
- }
+ bool isDisabled = fieldState == 'disabled';

This change would make the code more concise without altering its functionality.


80-107: Approved: Consistent improvements for Secondary Button story

The changes to the Secondary Button story mirror those of the Primary Button story, maintaining consistency across button types:

  1. The new option knob for disabled states enhances testing capabilities.
  2. The updated label to "Secondary Button" improves clarity.
  3. The isDisabled property is correctly set based on user selection.

As with the Primary Button story, consider simplifying the isDisabled logic:

- bool isDisabled = false;
- if (fieldState == 'disabled') {
-   isDisabled = true;
- }
+ bool isDisabled = fieldState == 'disabled';

This change would make the code more concise without altering its functionality.


150-177: Approved: Consistent improvements for Tertiary Button story with minor inconsistency

The changes to the Tertiary Button story are consistent with the Primary and Secondary Button stories:

  1. The new option knob for disabled states enhances testing capabilities.

  2. The updated label to "Tertiary Button" improves clarity.

  3. The isDisabled property is correctly set based on user selection.

  4. Consider simplifying the isDisabled logic:

- bool isDisabled = false;
- if (fieldState == 'disabled') {
-   isDisabled = true;
- }
+ bool isDisabled = fieldState == 'disabled';
  1. Update the size option label to match the other stories:
- label: 'Size of DigitButton',
+ label: 'Size of button',

These changes would improve consistency across all button stories.


220-246: Approved: Consistent improvements for Link Button story with minor inconsistencies

The changes to the Link Button story are consistent with the other button stories:

  1. The new option knob for disabled states enhances testing capabilities.
  2. The isDisabled property is correctly set based on user selection.

Consider the following improvements for consistency:

  1. Simplify the isDisabled logic:
- bool isDisabled = false;
- if (fieldState == 'disabled') {
-   isDisabled = true;
- }
+ bool isDisabled = fieldState == 'disabled';
  1. Update the initial label to match the pattern of other stories:
- initial: 'link'
+ initial: 'Link Button'
  1. Update the size option label to match the other stories:
- label: 'Size of DigitButton',
+ label: 'Size of button',

These changes would improve consistency across all button stories.


Line range hint 1-285: Overall improvements enhance button stories functionality and consistency

The changes made to the buttonStories() function and its individual stories significantly improve the overall functionality and user experience:

  1. The addition of disabled state options across all button types enhances testing capabilities.
  2. Updated labels improve clarity and consistency.
  3. The changes maintain a consistent structure across different button types.

These improvements will make it easier for developers to interact with and test various button states and sizes.

To further enhance consistency, consider addressing the minor inconsistencies in labels and simplifying the isDisabled logic as suggested in the individual story comments. These small adjustments will result in a more uniform and maintainable codebase.

flutter/digit-ui-components/storybook/lib/widgets/atoms/Info_card_stories.dart (3)

60-74: Consider using different images for variety

All stories use the same image URL multiple times. To enhance the visual appeal and demonstrate versatility, consider using different images or varying the number of images displayed.

This can provide a better user experience when showcasing the component's capabilities.

Also applies to: 135-149, 210-224, 285-299, 360-374


173-183: Ensure consistent indentation and formatting

There are inconsistencies in indentation starting from line 173 to line 183. Proper formatting enhances readability and maintainability.

Apply Dart's code formatting guidelines to these lines.


248-258: Correct the initial description in 'Warning' story

The initial description in the 'Warning' story is the same as in other stories. Consider customizing it to better reflect the warning context.

Example:

- initial: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit...',
+ initial: 'Please be cautious! This action may have unintended consequences.',
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between d69cf21 and ebda911.

⛔ Files ignored due to path filters (3)
  • flutter/digit-ui-components/storybook/assets/localized_data.json is excluded by !**/*.json
  • flutter/digit-ui-components/storybook/pubspec.lock is excluded by !**/*.lock, !**/*.lock
  • flutter/digit-ui-components/storybook/pubspec_overrides.yaml is excluded by !**/*.yaml
📒 Files selected for processing (5)
  • flutter/digit-ui-components/storybook/lib/iframe/iframe_widget.dart (1 hunks)
  • flutter/digit-ui-components/storybook/lib/main.dart (2 hunks)
  • flutter/digit-ui-components/storybook/lib/widgets/atoms/Info_card_stories.dart (1 hunks)
  • flutter/digit-ui-components/storybook/lib/widgets/atoms/back_button_stories.dart (2 hunks)
  • flutter/digit-ui-components/storybook/lib/widgets/atoms/button_stories.dart (5 hunks)
🧰 Additional context used
🔇 Additional comments (5)
flutter/digit-ui-components/storybook/lib/main.dart (1)

172-175: LGTM! Verify new story functions.

The addition of infoCardStories() and the replacement of DigitButtonStories() with buttonStories() align with the PR objectives. These changes should improve the organization and clarity of the storybook.

Please ensure that:

  1. The infoCardStories() function is properly implemented and contains the expected stories for info cards.
  2. The buttonStories() function includes all the stories previously in DigitButtonStories() and any new button stories mentioned in the PR objectives.

You can verify this by running the following script:

✅ Verification successful

Verification Successful: New story functions are correctly implemented.

The addition of infoCardStories() and the replacement of DigitButtonStories() with buttonStories() have been verified. These changes enhance the organization and clarity of the Storybook.

  • infoCardStories() is properly implemented and contains the expected stories for info cards.
  • buttonStories() is properly implemented and includes all stories previously in DigitButtonStories().
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the implementation of new story functions

# Test 1: Check if infoCardStories() is implemented
echo "Checking infoCardStories() implementation:"
rg --type dart "function infoCardStories\(\)" ./flutter/digit-ui-components/storybook/

# Test 2: Check if buttonStories() is implemented and contains expected content
echo "Checking buttonStories() implementation:"
rg --type dart "function buttonStories\(\)" ./flutter/digit-ui-components/storybook/

# Test 3: Verify that DigitButtonStories is no longer used
echo "Verifying DigitButtonStories is not used:"
rg --type dart "DigitButtonStories" ./flutter/digit-ui-components/storybook/

Length of output: 531


Script:

#!/bin/bash
# Description: Re-verify the implementation of new story functions with refined search patterns

# Test 1: Check if infoCardStories() exists using a broader search pattern
echo "Re-checking infoCardStories() implementation with broader pattern:"
rg --type dart "infoCardStories" ./flutter/digit-ui-components/storybook/

# Test 2: Check if buttonStories() exists using a broader search pattern
echo "Re-checking buttonStories() implementation with broader pattern:"
rg --type dart "buttonStories" ./flutter/digit-ui-components/storybook/

# Test 3: Verify that DigitButtonStories is not used anywhere
echo "Re-verifying DigitButtonStories is not used:"
rg --type dart "DigitButtonStories" ./flutter/digit-ui-components/storybook/

Length of output: 994

flutter/digit-ui-components/storybook/lib/widgets/atoms/button_stories.dart (2)

8-8: Approved: Function name change improves consistency

The change from DigitButtonStories to buttonStories is a good improvement. It makes the function name more concise and aligns with common Dart naming conventions, enhancing overall code readability.


Line range hint 11-17: Approved: Story name update and documentation approach

The change to use 'Buttons' in plural form in the story name is appropriate, as it better represents the multiple button types covered. The use of an IframeWidget to display external documentation is a good practice, allowing for easy updates and maintenance of the documentation separate from the code.

flutter/digit-ui-components/storybook/lib/widgets/atoms/Info_card_stories.dart (2)

38-45: Verify 'Widget Alignment' option values

The 'Widget Alignment' options assign true to "Vertical" and false to "Horizontal". This might be counterintuitive since "inline" typically refers to horizontal alignment. Ensure that these values correctly reflect the intended behavior of the inline parameter in InfoCard.

Please confirm whether inline: true results in vertical alignment or if the values should be swapped.


113-121: Consistent 'Widget Alignment' option values across stories

Similar to the earlier verification, ensure that the 'Widget Alignment' option values are consistent and correctly mapped in all stories. The mapping should accurately reflect whether inline: true corresponds to vertical or horizontal alignment.

Please confirm the mapping in the following line ranges:

  • Lines 113-121
  • Lines 188-196
  • Lines 263-271
  • Lines 338-346

Adjust the option values if necessary to maintain consistent behavior across all stories.

Also applies to: 188-196, 263-271, 338-346

@naveen-egov
Copy link
Contributor

@coderabbitai can you approve the pr

Copy link

@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

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between ebda911 and f68f295.

📒 Files selected for processing (1)
  • flutter/digit-ui-components/storybook/lib/widgets/atoms/Info_card_stories.dart (1 hunks)
🧰 Additional context used
🔇 Additional comments (3)
flutter/digit-ui-components/storybook/lib/widgets/atoms/Info_card_stories.dart (3)

12-16: Update documentation URL

The URL provided in the 'Documentation' story appears to be a placeholder or potentially outdated. Please ensure that it points to the correct and up-to-date documentation for the InfoCard component.


60-66: 🛠️ Refactor suggestion

Refactor repeated Image.network calls

The current implementation repeats the Image.network call multiple times. Consider refactoring this to improve code maintainability:

if (showAdditionalWidget)
  ...List.generate(
    5,
    (_) => Image.network(
      'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQIGMLufj86aep95KwMzr3U0QShg7oxdAG8gBPJ9ALIFQ&s',
    ),
  ),

This approach reduces code duplication and makes it easier to adjust the number of images in the future.


319-320: 🛠️ Refactor suggestion

Enhance customization options for the Custom story

The Custom story currently has a hardcoded InfoType.info. To make this story truly customizable, consider adding a knob to select the InfoType. Additionally, update the initial title to reflect that this is a custom story.

- title: context.knobs.text(label: "Title", initial: 'Info'),
+ title: context.knobs.text(label: "Title", initial: 'Custom'),
- type: InfoType.info,
+ type: context.knobs.options(
+   label: "Info Type",
+   options: InfoType.values.map((type) => Option(label: type.name, value: type)).toList(),
+   initial: InfoType.info,
+ ),

This change allows users to fully customize the alert type in the Custom story.

Copy link

coderabbitai bot commented Oct 15, 2024

@naveen-egov: Sure, I have approved the PR.

✅ Actions performed

Comments resolved and changes approved.

@naveen-egov naveen-egov merged commit 2d85ec2 into develop Oct 15, 2024
1 check passed
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