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

[WEB-4082] Include example for input field prefix usage, rename poorly named icon #544

Merged
merged 2 commits into from
Nov 15, 2024

Conversation

jamiehenson
Copy link
Member

@jamiehenson jamiehenson commented Nov 14, 2024

Relates to #543 but removes the parts where the icon CSS classes are generated.

Summary by CodeRabbit

  • New Features
    • Introduced a new input field variation with a character insert feature, enhancing user interaction.
    • Added a visually integrated dollar sign icon within the input field for improved usability.

Copy link
Contributor

coderabbitai bot commented Nov 14, 2024

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

The changes introduce a new input field variation in the Forms.stories.tsx file, specifically adding a label and an input field designed to accommodate a currency icon. The icon, represented by a dollar sign, is positioned absolutely within a relative container, allowing the input field to adjust its padding accordingly. This enhancement does not modify existing exported entities or their signatures.

Changes

File Change Summary
src/core/styles/Forms.stories.tsx Added a new input field variation with a currency icon prefix and adjusted styles.

Assessment against linked issues

Objective Addressed Explanation
Allow input fields to have currency input icon prefix in Ably UI (WEB-4118)

Possibly related PRs

Suggested reviewers

  • aralovelace
  • kennethkalmer

🐰 In a field of dreams, I hop with glee,
A new input style, as sweet as can be!
With a dollar sign shining, oh what a sight,
My little paws dance in pure delight!
Let's fill in the forms, make them bright! 🌟


🪧 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
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: 2

🧹 Outside diff range and nitpick comments (2)
src/core/styles/Forms.stories.tsx (2)

85-95: Make the currency prefix implementation more flexible

The current implementation has hardcoded dimensions and positioning which might not work well with different font sizes or icon sizes. Consider making it more flexible and reusable.

- <div className="relative">
-   <div className="h-32 w-32 absolute left-8 top-8 flex items-center justify-center">
-     $
-   </div>
-   <input
-     type="search"
-     className="ui-input pl-40"
-     placeholder="With icon"
-     autoComplete="off"
-   />
- </div>
+ <div className="relative">
+   <div className="absolute left-2 top-1/2 -translate-y-1/2 flex items-center justify-center pointer-events-none">
+     <Icon name="icon-gui-currency-dollar" size="1rem" />
+   </div>
+   <input
+     type="search"
+     className="ui-input pl-8"
+     style={{ paddingLeft: 'calc(2rem + 0.5em)' }}
+     placeholder="With icon"
+     autoComplete="off"
+   />
+ </div>

83-96: Consider creating a reusable InputWithPrefix component

Since this is a common pattern that might be used across different forms, consider extracting it into a reusable component that can handle different types of prefixes (not just currency).

Example implementation:

interface InputWithPrefixProps extends React.InputHTMLAttributes<HTMLInputElement> {
  prefix: React.ReactNode;
  prefixAriaLabel: string;
}

const InputWithPrefix: React.FC<InputWithPrefixProps> = ({
  prefix,
  prefixAriaLabel,
  className,
  ...props
}) => (
  <div className="relative">
    <span id={`${props.id}-prefix`} className="sr-only">{prefixAriaLabel}</span>
    <div className="absolute left-2 top-1/2 -translate-y-1/2 flex items-center justify-center pointer-events-none">
      {prefix}
    </div>
    <input
      {...props}
      className={`ui-input ${className}`}
      style={{ paddingLeft: 'calc(2rem + 0.5em)' }}
      aria-describedby={`${props.id}-prefix`}
    />
  </div>
);
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 44b39b8 and 6997313.

⛔ Files ignored due to path filters (3)
  • src/core/Icon/__snapshots__/Icon.stories.tsx.snap is excluded by !**/*.snap
  • src/core/icons/icon-display-connection-state-recovery.svg is excluded by !**/*.svg
  • src/core/styles/__snapshots__/Forms.stories.tsx.snap is excluded by !**/*.snap
📒 Files selected for processing (1)
  • src/core/styles/Forms.stories.tsx (1 hunks)

src/core/styles/Forms.stories.tsx Show resolved Hide resolved
src/core/styles/Forms.stories.tsx Outdated Show resolved Hide resolved
@jamiehenson jamiehenson force-pushed the web-4118-input-field-prefix-example branch from 6997313 to 1732e0a Compare November 14, 2024 16:33
@jamiehenson
Copy link
Member Author

@matt423 The other PR linked in the description has all the CSS icon class generation stuff I mentioned this morning, but that has proven somewhat problematic to get working - as such, I've closed that and this PR just has the part that may be helpful to you in the form of an example of how to recreate what's requested in that design.

Best way to see this is in Storybook under the "with character insert" entry in Forms. Clicking "show code" under the unit will show the CSS. You probably would have reached this point anyway without me but I at least may as well share what I had from the previous PR

@jamiehenson jamiehenson requested a review from matt423 November 14, 2024 17:02
@jamiehenson jamiehenson merged commit c3d69e5 into main Nov 15, 2024
5 checks passed
@jamiehenson jamiehenson deleted the web-4118-input-field-prefix-example branch November 15, 2024 09:45
@jamiehenson jamiehenson changed the title [WEB-4118] Include example for input field prefix usage, rename poorly named icon [WEB-4082] Include example for input field prefix usage, rename poorly named icon Nov 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging this pull request may close these issues.

2 participants