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

feat/phoneInput: added phoneInput Form Feature #1334

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

dhavalveera
Copy link
Contributor

@dhavalveera dhavalveera commented Mar 31, 2024

Implemented the phone input component from Flowbite package into our Flowbite React project. This enhancement empowers users to conveniently input phone numbers within forms. The integration seamlessly aligns with Flowbite's design principles and ensures consistency across the project.

Summary by CodeRabbit

  • New Features

    • Introduced a new React phone input component with examples, supporting responsiveness, dark mode, and RTL layout.
    • Added documentation for the phone input component, including usage and customization options.
    • Integrated phone input component into the app with examples demonstrating basic usage and additional features like helper text.
    • Enhanced theming capabilities for the phone input component, allowing for customization of appearance and behavior.
  • Documentation

    • Updated the documentation sidebar to include a new entry for the phone input component.
  • Tests

    • Added test cases for the phone input component to ensure accessibility and functionality of icons.
  • Refactor

    • Expanded the UI theme configuration to include new styling options for the phone input component.

Copy link

changeset-bot bot commented Mar 31, 2024

⚠️ No Changeset found

Latest commit: cff0a50

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

Copy link

vercel bot commented Mar 31, 2024

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

Name Status Preview Comments Updated (UTC)
flowbite-react ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 3, 2024 8:20am
flowbite-react-storybook ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 3, 2024 8:20am

Copy link
Contributor

coderabbitai bot commented Mar 31, 2024

Walkthrough

The update introduces a new PhoneInput component for React applications, enhancing forms with a phone number input field. This component, part of the Flowbite library, supports customization through themes, includes responsiveness, dark mode, right-to-left layout compatibility, and is accompanied by documentation, example usage, and Storybook stories. Additionally, it incorporates unit tests and theming options to ensure accessibility and consistent styling across applications.

Changes

File Path Change Summary
apps/web/content/docs/forms/phone-input.mdx Introduced documentation for the new React phone input component.
apps/web/data/docs-sidebar.ts Added "Phone Input" entry to documentation sidebar.
apps/web/examples/.../index.ts, .../phoneInput/index.ts Exported phoneInput component and its variations.
packages/ui/src/components/PhoneInput/... Introduced PhoneInput component, its stories, tests, and theming.
packages/ui/src/.../Flowbite/FlowbiteTheme.ts Added phoneInput property to FlowbiteTheme interface.
packages/ui/src/components/PhoneInput/PhoneInput.spec.tsx Added tests for PhoneInput component.
packages/ui/src/components/PhoneInput/PhoneInput.stories.tsx Added Storybook stories for PhoneInput.
packages/ui/src/components/PhoneInput/PhoneInput.tsx Created PhoneInput component for phone number input.
packages/ui/src/components/PhoneInput/index.ts Exported PhoneInput component and related types.

Possibly related issues

  • Add docs page: Forms -> Search Input #187: The addition of the PhoneInput component with comprehensive documentation, examples, and testing could serve as a model for addressing the request for a Search Input documentation page. Both involve enhancing the library with new components and ensuring they are well-documented and tested.

Poem

In the world of forms and UI delight,
A PhoneInput component steps into the light.
With icons and themes, it makes its claim,
To simplify inputs, that's its main aim.
🐇 Hops around, with a coder's glee,
For making forms better, as easy as can be.
🎉 Celebrate this code, both clean and bright,
Enhancing the web, with every byte.

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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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.

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 as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration 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/coderabbit-overrides.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
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

Review Status

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between cccda3e and 34b3732.
Files selected for processing (14)
  • apps/web/content/docs/forms/phone-input.mdx (1 hunks)
  • apps/web/data/docs-sidebar.ts (1 hunks)
  • apps/web/examples/index.ts (1 hunks)
  • apps/web/examples/phoneInput/index.ts (1 hunks)
  • apps/web/examples/phoneInput/phoneInput.root.tsx (1 hunks)
  • apps/web/examples/phoneInput/phoneInput.withHelperText.tsx (1 hunks)
  • packages/ui/src/components/Flowbite/FlowbiteTheme.ts (2 hunks)
  • packages/ui/src/components/PhoneInput/PhoneInput.spec.tsx (1 hunks)
  • packages/ui/src/components/PhoneInput/PhoneInput.stories.tsx (1 hunks)
  • packages/ui/src/components/PhoneInput/PhoneInput.tsx (1 hunks)
  • packages/ui/src/components/PhoneInput/index.ts (1 hunks)
  • packages/ui/src/components/PhoneInput/theme.ts (1 hunks)
  • packages/ui/src/index.ts (1 hunks)
  • packages/ui/src/theme.ts (2 hunks)
Files skipped from review due to trivial changes (2)
  • apps/web/examples/phoneInput/index.ts
  • packages/ui/src/components/PhoneInput/PhoneInput.stories.tsx
Additional Context Used
Additional comments not posted (12)
packages/ui/src/components/PhoneInput/index.ts (1)

1-2: The export statements for the PhoneInput component and its associated types are correctly structured and align with the project's conventions.

packages/ui/src/components/PhoneInput/PhoneInput.spec.tsx (1)

6-29: The test cases provided focus on accessibility and icon functionality, which is a good start. However, consider adding more comprehensive tests to cover the PhoneInput component's functionality, such as input validation and response to user interactions.

apps/web/examples/phoneInput/phoneInput.root.tsx (1)

1-52: The example provided for the PhoneInput component is clear and demonstrates its basic usage effectively. Ensure that examples like this are regularly updated to reflect any changes or enhancements to the component.

packages/ui/src/components/PhoneInput/theme.ts (1)

1-24: The theming for the PhoneInput component is well-defined and consistent with the project's design principles. The use of Tailwind CSS classes ensures a cohesive look and feel.

apps/web/content/docs/forms/phone-input.mdx (1)

1-34: The documentation for the PhoneInput component is comprehensive and informative. Consider the following minor grammatical corrections and improvements for readability:

  • Near line 6: Consider rephrasing to "The PhoneInput component from Flowbite React allows users to input a phone number inside a form field."
  • Near line 8: Use a comma before "and" if it connects two independent clauses.
  • Near line 10: A comma might be missing after "project".
apps/web/examples/phoneInput/phoneInput.withHelperText.tsx (1)

1-52: The example showcasing the PhoneInput component with helper text is clear and effectively demonstrates its usage. This is a valuable addition to the documentation, providing users with a practical example of how to use the component with additional context.

apps/web/examples/index.ts (1)

24-24: The addition of the phoneInput component to the examples index is correctly implemented and aligns with the project's conventions.

packages/ui/src/index.ts (1)

28-28: The export of the PhoneInput component is correctly implemented and aligns with the project's conventions.

packages/ui/src/components/PhoneInput/PhoneInput.tsx (1)

1-78: The implementation of the PhoneInput component in PhoneInput.tsx is well-structured and follows best practices for component design in React. A few points to consider:

  1. Props Spread on Input Element (Lines 62-70): Ensure that all props spread on the input element are intended and do not unintentionally override internal component logic. It's good practice to explicitly handle or omit props that might conflict with the component's internal state or logic.

  2. Accessibility (Lines 52-59): The use of aria-hidden on icons is appropriate. However, consider adding aria-label or aria-labelledby attributes to the input element if the icons convey meaningful actions or information to improve accessibility further.

  3. Theming and Customization (Lines 45, 47): The theming approach using mergeDeep and getTheme is robust, allowing for deep customization. Ensure that the theme structure and default values are well-documented to aid developers in customizing the component.

  4. Icon Components (Lines 34-35): The use of FC<ComponentProps<"svg">> for icons is flexible but consider documenting the expected properties for custom icons, such as className, to ensure they integrate seamlessly with the component's styling.

  5. Helper Text Integration (Line 72): The integration of HelperText component for displaying helper text is a good practice. Ensure that the color and positioning of the helper text are consistent with the overall design system of Flowbite.

Overall, the component is well-implemented with attention to detail in theming, accessibility, and extensibility. Consider the points above to further refine the component.

packages/ui/src/theme.ts (1)

26-26: The addition of phoneInputTheme to the theme object in theme.ts is correctly implemented and follows the established pattern for integrating component themes. This ensures that the PhoneInput component is fully supported by the Flowbite theming system. Good job on maintaining consistency with the existing theming structure.

Also applies to: 70-70

apps/web/data/docs-sidebar.ts (1)

93-93: The addition of the "Phone Input" entry to the DOCS_SIDEBAR in docs-sidebar.ts is correctly implemented. This update ensures that the documentation for the new PhoneInput component is easily accessible to developers. It's good practice to mark new features as isNew: true to highlight them in the documentation, which has been done here.

packages/ui/src/components/Flowbite/FlowbiteTheme.ts (1)

26-26: The integration of FlowbitePhoneInputTheme into the FlowbiteTheme interface in FlowbiteTheme.ts is correctly implemented. This change is crucial for ensuring that the theming capabilities of the new PhoneInput component are fully supported within the Flowbite theme system. Consistency with the existing structure of the theme interface has been maintained, which is excellent.

Also applies to: 72-72

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: 4

Review Status

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 34b3732 and d9752f7.
Files selected for processing (5)
  • apps/web/content/docs/forms/phone-input.mdx (1 hunks)
  • apps/web/examples/phoneInput/index.ts (1 hunks)
  • apps/web/examples/phoneInput/phoneInput.root.tsx (1 hunks)
  • apps/web/examples/phoneInput/phoneInput.withHelperText.tsx (1 hunks)
  • apps/web/examples/phoneInput/phoneInput.withRightIcon.tsx (1 hunks)
Files skipped from review as they are similar to previous changes (3)
  • apps/web/examples/phoneInput/index.ts
  • apps/web/examples/phoneInput/phoneInput.root.tsx
  • apps/web/examples/phoneInput/phoneInput.withHelperText.tsx
Additional comments not posted (1)
apps/web/examples/phoneInput/phoneInput.withRightIcon.tsx (1)

29-41: Validate the pattern attribute for correctness and completeness.

+ // Ensure the pattern attribute matches the desired phone number format accurately.

Consider adding a comment to verify the correctness of the regex pattern used in the pattern attribute to ensure it accurately matches the intended phone number format.

apps/web/content/docs/forms/phone-input.mdx Outdated Show resolved Hide resolved
apps/web/content/docs/forms/phone-input.mdx Outdated Show resolved Hide resolved
apps/web/content/docs/forms/phone-input.mdx Outdated Show resolved Hide resolved
apps/web/examples/phoneInput/phoneInput.withRightIcon.tsx Outdated Show resolved Hide resolved
function Component() {
return (
<form className="max-w-sm mx-auto">
<PhoneInput />
Copy link
Collaborator

Choose a reason for hiding this comment

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

not same content

Copy link
Contributor Author

@dhavalveera dhavalveera Apr 3, 2024

Choose a reason for hiding this comment

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

Sorry @SutuSebastian Sir, I am not clear on this, need little bit more info on this

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@SutuSebastian Sorry for follow up, awaiting for the clarification for this review.

@themesberg themesberg deleted a comment from stackblitz bot Apr 3, 2024
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: 3

Review Status

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between d9752f7 and 45be937.
Files selected for processing (7)
  • apps/web/content/docs/forms/phone-input.mdx (1 hunks)
  • apps/web/examples/phoneInput/phoneInput.root.tsx (1 hunks)
  • apps/web/examples/phoneInput/phoneInput.withHelperText.tsx (1 hunks)
  • apps/web/examples/phoneInput/phoneInput.withRightIcon.tsx (1 hunks)
  • packages/ui/src/components/Flowbite/FlowbiteTheme.ts (2 hunks)
  • packages/ui/src/components/PhoneInput/PhoneInput.tsx (1 hunks)
  • packages/ui/src/components/PhoneInput/theme.ts (1 hunks)
Files skipped from review as they are similar to previous changes (6)
  • apps/web/examples/phoneInput/phoneInput.root.tsx
  • apps/web/examples/phoneInput/phoneInput.withHelperText.tsx
  • apps/web/examples/phoneInput/phoneInput.withRightIcon.tsx
  • packages/ui/src/components/Flowbite/FlowbiteTheme.ts
  • packages/ui/src/components/PhoneInput/PhoneInput.tsx
  • packages/ui/src/components/PhoneInput/theme.ts
Additional comments not posted (1)
apps/web/content/docs/forms/phone-input.mdx (1)

38-38: Verify the hyperlink to ensure it directs to the correct page.

Ensure the link to the Flowbite Phone Input documentation is correct and accessible.

apps/web/content/docs/forms/phone-input.mdx Outdated Show resolved Hide resolved
apps/web/content/docs/forms/phone-input.mdx Show resolved Hide resolved
apps/web/content/docs/forms/phone-input.mdx Outdated Show resolved Hide resolved
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

Review Status

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 45be937 and cff0a50.
Files selected for processing (1)
  • apps/web/content/docs/forms/phone-input.mdx (1 hunks)

@dhavalveera
Copy link
Contributor Author

@SutuSebastian - can you please review?

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