Skip to content

feat: move textarea to UI#2973

Merged
chronark merged 2 commits intomainfrom
move-textarea-to-ui
Mar 14, 2025
Merged

feat: move textarea to UI#2973
chronark merged 2 commits intomainfrom
move-textarea-to-ui

Conversation

@ogzhanolguncu
Copy link
Contributor

@ogzhanolguncu ogzhanolguncu commented Mar 14, 2025

What does this PR do?

Fixes # (issue)

If there is not an issue for this, please create one first. This is used to tracking purposes and also helps use understand why this PR exists

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • Chore (refactoring code, technical debt, workflow improvements)
  • Enhancement (small improvements)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How should this be tested?

  • Test A
  • Test B

Checklist

Required

  • Filled out the "How to test" section in this PR
  • Read Contributing Guide
  • Self-reviewed my own code
  • Commented on my code in hard-to-understand areas
  • Ran pnpm build
  • Ran pnpm fmt
  • Checked for warnings, there are none
  • Removed all console.logs
  • Merged the latest changes from main onto my branch with git pull origin main
  • My changes don't cause any responsiveness issues

Appreciated

  • If a UI change was made: Added a screen recording or screenshots to this PR
  • Updated the Unkey Docs if changes were necessary

Summary by CodeRabbit

  • New Features
    • Enhanced dashboard loading screens now include structured layouts with navigation, search controls, and interactive card grids for improved data visibility.
    • The API creation button label has been updated for consistent presentation.
    • New form component variants offer interactive feedback for required, optional, and error states, with icon support to enhance the user input experience.
  • Documentation
    • Expanded design guidelines now detail the usage and variations of form inputs and textareas, including interactive examples like character count and icon integration.

@vercel
Copy link

vercel bot commented Mar 14, 2025

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

Name Status Preview Comments Updated (UTC)
dashboard ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 14, 2025 3:57pm
engineering ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 14, 2025 3:57pm
play ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 14, 2025 3:57pm
www ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 14, 2025 3:57pm

@changeset-bot
Copy link

changeset-bot bot commented Mar 14, 2025

⚠️ No Changeset found

Latest commit: be0fcce

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

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 14, 2025

📝 Walkthrough

Walkthrough

This pull request updates several dashboard and UI components along with their documentation. In the dashboard, the create API button label is updated while the loading pages for APIs and rate limits are overhauled to include navigation bars, search controls, icons, and card grids. The authorization component’s import is consolidated. Additionally, new documentation and variant examples for FormInput, FormTextarea, and Textarea components are introduced. Internal UI components are refactored to support an optional property with structured tag rendering and a new Textarea component with variant styling and icon support.

Changes

File(s) Change Summary
apps/dashboard/app/(app)/apis/_components/create-api-button.tsx, apps/dashboard/app/(app)/apis/loading.tsx, apps/dashboard/app/(app)/authorization/_components/rbac-form.tsx, apps/dashboard/app/(app)/ratelimits/loading.tsx Updated UI labels and overhauled loading pages: modified button text, introduced navigation bars, search controls, card grids with new icons, and consolidated import statements.
apps/engineering/content/design/components/form-input.mdx, apps/engineering/content/design/components/form-textarea.mdx, apps/engineering/content/design/components/form/form-input.variants.tsx, apps/engineering/content/design/components/form/form-textarea.variants.tsx, apps/engineering/content/design/components/textarea.mdx, apps/engineering/content/design/components/textarea/textarea.variants.tsx Added new documentation files and variant examples demonstrating multiple states (e.g., required with error, optional, success, warning) for FormInput, FormTextarea, and Textarea components.
internal/ui/src/components/form/form-input.tsx, internal/ui/src/components/form/form-textarea.tsx, internal/ui/src/components/form/index.tsx, internal/ui/src/components/textarea.tsx, internal/ui/src/index.ts Introduced an optional prop with conditional tag rendering in FormInput, refactored FormTextarea to use a new Textarea component with enhanced props (including left/right icons), and added the new Textarea component with variant styling.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant DashboardPage
    participant Navbar
    participant SearchControls
    participant CardGrid

    User->>DashboardPage: Navigate to Dashboard
    DashboardPage->>Navbar: Render navigation bar with breadcrumbs and action buttons
    DashboardPage->>SearchControls: Render search inputs and icon buttons
    DashboardPage->>CardGrid: Render grid layout with cards
    Note right of DashboardPage: Refresh button is displayed but disabled
Loading
sequenceDiagram
    participant Parent
    participant FormInput
    participant TagComponent

    Parent->>FormInput: Render FormInput with props (required/optional)
    alt Optional prop is true
        FormInput->>TagComponent: Render OptionalTag
    else if Required prop is true
        FormInput->>TagComponent: Render RequiredTag
    end
Loading

Possibly related PRs

Suggested labels

Feature, Improvement, Dashboard, Needs Approval

Suggested reviewers

  • mcstepp
  • chronark
  • perkinsjr
  • MichaelUnkey
✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ 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 generate docstrings to generate docstrings for this 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.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 14, 2025

Thank you for following the naming conventions for pull request titles! 🙏

@vercel vercel bot temporarily deployed to Preview – play March 14, 2025 15:53 Inactive
@vercel vercel bot temporarily deployed to Preview – www March 14, 2025 15:53 Inactive
Copy link
Contributor Author

@perkinsjr @chronark that

@vercel vercel bot temporarily deployed to Preview – engineering March 14, 2025 15:56 Inactive
@vercel vercel bot temporarily deployed to Preview – dashboard March 14, 2025 15:57 Inactive
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

🧹 Nitpick comments (15)
apps/dashboard/app/(app)/apis/_components/create-api-button.tsx (1)

62-62: Consider consistent capitalization between button and dialog.

The button label now uses "Create new API" (lowercase "new"), but the dialog title at line 68 still uses "Create New API" (uppercase "New"). Consider making the capitalization consistent across both elements.

apps/engineering/content/design/components/form-textarea.mdx (1)

114-123: Fix grammar in best practices list.

There's a minor grammatical inconsistency in the list of best practices.

 - Always provide clear, concise labels
 - Use description text to provide additional context when needed
-- Keep error messages specific and actionable
+- To keep error messages specific and actionable
 - Use required fields sparingly and logically
 - Group related form elements using fieldset and legend when appropriate

Alternatively, for consistency with the other bullet points that start with verbs:

 - Always provide clear, concise labels
 - Use description text to provide additional context when needed
-- Keep error messages specific and actionable
+- Provide error messages that are specific and actionable
 - Use required fields sparingly and logically
🧰 Tools
🪛 LanguageTool

[grammar] ~115-~115: The verb “Keep” needs to be in the to-infinitive form.
Context: ...text to provide additional context when needed - Keep error messages specific and actionable ...

(MISSING_TO_BEFORE_A_VERB)

apps/engineering/content/design/components/textarea.mdx (1)

19-25: Consider enhancing the usage examples.
While the default dropdown variant is shown, it may be helpful to include a snippet illustrating how to integrate this TextareaDefaultVariant in a form, helping developers understand usage in real contexts.

apps/dashboard/app/(app)/ratelimits/loading.tsx (1)

8-29: Avoid nesting multiple <nav> elements for accessibility.
It’s generally recommended to keep only one <nav> element for primary navigation and use lists or <div> wrappers for breadcrumb items. This helps assistive technologies parse the document structure more consistently.

internal/ui/src/components/textarea.tsx (1)

49-53: Props are well-structured and documented.
Consider adding optional ARIA-related props (like aria-label) for cases where a visible label might be absent. This would help ensure better accessibility.

apps/dashboard/app/(app)/apis/loading.tsx (3)

6-44: Consider consolidating nested navigation elements.
Using <nav> within another <nav> can be valid but sometimes confusing from an accessibility standpoint; consider using a <div> for sub-navigation or employing a dedicated breadcrumb component for clarity.


45-106: Enhance search accessibility.
Currently, there's no actual <input> element for the search field, so assistive technologies might have difficulty recognizing it as a search control. Consider using <input type="search" /> with an associated label or suitable ARIA attributes to improve accessibility.


109-157: Review array index usage for keys in placeholder mapping.
Using the array index as a key can cause subtle issues if the array content changes out of order. For purely decorative placeholders in a static list, this is typically acceptable. Otherwise, consider a stable, unique identifier if items may reorder.

apps/engineering/content/design/components/textarea/textarea.variants.tsx (1)

1-87: Add accessible labeling or ARIA attributes for better usability.
All variants rely primarily on the placeholder for user guidance. For real-world usage, consider providing explicit labels or aria-label/aria-labelledby attributes to ensure accessibility and clarity for screen readers.

internal/ui/src/components/form/form-textarea.tsx (4)

46-46: Label styling is appropriate.
You may optionally add htmlFor and a more descriptive class name if further styling or targeting is needed.


111-113: Structured approach to handle error states.
Extending this for other states like success/warning can further unify the design language.


115-126: OptionalTag component is straightforward.
Consider i18n if you need localization later.


128-142: RequiredTag component follows the same pattern.
Similarly, i18n or shared styling might be beneficial if extended across multiple tags.

apps/engineering/content/design/components/form/form-textarea.variants.tsx (2)

87-98: Consider consistent variant pattern for error states

I noticed that success and warning states use the variant prop (variant="success" and variant="warning"), while the error state uses a separate error prop instead of variant="error". This may be intentional to support custom error messages, but it creates an inconsistency in the API pattern.

- <FormTextarea
-   label="Code Snippet"
-   error="Invalid syntax in your code"
-   placeholder="function castRing() { ... }"
- />
+ <FormTextarea
+   label="Code Snippet"
+   variant="error"
+   description="Invalid syntax in your code"
+   placeholder="function castRing() { ... }"
+ />

Alternatively, document why this inconsistency exists if it's by design.


4-14: Consider adding JSDoc comments for each variant

Adding JSDoc comments to each exported component would improve documentation and provide better IDE tooltips for developers using these components. For example:

+ /**
+  * Default FormTextarea variant with label, description, and placeholder
+  */
export const DefaultFormTextareaVariant = () => {
  // ...
};

Also applies to: 17-28, 31-42, 45-56, 59-71, 74-85, 88-98, 101-113, 116-127, 130-142, 145-159

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f8c5e83 and be0fcce.

📒 Files selected for processing (15)
  • apps/dashboard/app/(app)/apis/_components/create-api-button.tsx (1 hunks)
  • apps/dashboard/app/(app)/apis/loading.tsx (1 hunks)
  • apps/dashboard/app/(app)/authorization/_components/rbac-form.tsx (1 hunks)
  • apps/dashboard/app/(app)/ratelimits/loading.tsx (1 hunks)
  • apps/engineering/content/design/components/form-input.mdx (3 hunks)
  • apps/engineering/content/design/components/form-textarea.mdx (1 hunks)
  • apps/engineering/content/design/components/form/form-input.variants.tsx (1 hunks)
  • apps/engineering/content/design/components/form/form-textarea.variants.tsx (1 hunks)
  • apps/engineering/content/design/components/textarea.mdx (1 hunks)
  • apps/engineering/content/design/components/textarea/textarea.variants.tsx (1 hunks)
  • internal/ui/src/components/form/form-input.tsx (2 hunks)
  • internal/ui/src/components/form/form-textarea.tsx (4 hunks)
  • internal/ui/src/components/form/index.tsx (1 hunks)
  • internal/ui/src/components/textarea.tsx (1 hunks)
  • internal/ui/src/index.ts (1 hunks)
🧰 Additional context used
🪛 LanguageTool
apps/engineering/content/design/components/form-textarea.mdx

[grammar] ~115-~115: The verb “Keep” needs to be in the to-infinitive form.
Context: ...text to provide additional context when needed - Keep error messages specific and actionable ...

(MISSING_TO_BEFORE_A_VERB)

⏰ Context from checks skipped due to timeout of 90000ms (16)
  • GitHub Check: Test Go API Local / Test
  • GitHub Check: Test Packages / Test ./packages/nextjs
  • GitHub Check: Test Packages / Test ./packages/rbac
  • GitHub Check: Test Packages / Test ./internal/keys
  • GitHub Check: Test Packages / Test ./packages/hono
  • GitHub Check: Test Packages / Test ./packages/cache
  • GitHub Check: Test Packages / Test ./internal/clickhouse
  • GitHub Check: Test Packages / Test ./packages/api
  • GitHub Check: Test Packages / Test ./internal/resend
  • GitHub Check: Test Packages / Test ./internal/id
  • GitHub Check: Test Packages / Test ./internal/hash
  • GitHub Check: Test Packages / Test ./internal/billing
  • GitHub Check: Build / Build
  • GitHub Check: Test API / API Test Local
  • GitHub Check: autofix
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (34)
internal/ui/src/index.ts (1)

8-8: Appropriate export for the textarea component.

This export makes the textarea component available to other parts of the application, which aligns with the PR objective of moving the textarea to UI.

internal/ui/src/components/form/index.tsx (1)

2-2: Appropriate export for the form-textarea component.

This export statement makes the form-textarea component accessible from the form module, which is necessary for the component to be used throughout the application.

apps/dashboard/app/(app)/authorization/_components/rbac-form.tsx (1)

8-8: Good consolidation of imports.

This change appropriately consolidates the FormTextarea import with other UI components, which is cleaner and more maintainable than having separate import statements.

apps/engineering/content/design/components/form-input.mdx (4)

8-9: New input variants added for enhanced form states.

The addition of RequiredWithErrorFormInputVariant and OptionalFormInputVariant improves the component documentation by covering more form field scenarios.


33-33: Description update for required fields.

Good clarification that required prop adds a "Required" tag instead of an asterisk, which matches the updated implementation.


37-47: New documentation sections for form field states.

The added sections for "Required Field with Error" and "Optional Field" provide clear explanations of these field states and their visual treatment. This enhances the component documentation.


130-130: Updated layout guideline to reflect new optional tag.

The guideline now correctly refers to the "optional tag" instead of an asterisk, aligning with the component's new visual treatment.

internal/ui/src/components/form/form-input.tsx (4)

5-5: Import tags from form-textarea component.

I notice the tags are now imported from the form-textarea component. This suggests a refactoring where these shared UI elements have been moved to a single location.


12-12: Added optional property to form input props.

The new optional?: boolean property enhances the FormInput component by allowing explicit indication of non-mandatory fields.


19-19: Updated props destructuring to include optional flag.

The component now properly destructures the new optional property alongside existing props.


34-35: Replaced inline asterisk with structured tag components.

The implementation now uses dedicated tag components for required and optional fields, which improves consistency and allows for better styling of these indicators. The error state of required tags is also handled appropriately.

apps/engineering/content/design/components/form/form-input.variants.tsx (2)

30-42: Added variant for required field with error state.

The new RequiredWithErrorFormInputVariant demonstrates how the required tag's appearance changes when an error occurs, providing a useful visual example for documentation.


44-56: Added variant for optional field state.

The new OptionalFormInputVariant provides a clear example of how optional fields are displayed with their descriptive tag, maintaining consistency with other form variants.

apps/engineering/content/design/components/form-textarea.mdx (4)

1-4: Well-structured documentation for new FormTextarea component.

The documentation follows the same format as FormInput, providing consistency across component documentation.


21-26: Clear component description and usage guidance.

The introduction effectively explains the purpose and benefits of the FormTextarea component for multi-line text input scenarios.


37-48: Comprehensive documentation of required and optional states.

The documentation clearly explains how the required and optional states are visually represented, including error handling for required fields.


126-130: Consistent layout guidelines with FormInput.

The layout guidelines properly match those in the FormInput documentation, maintaining consistency across components.

apps/engineering/content/design/components/textarea.mdx (2)

1-4: Great documentation introduction.
The front matter and overall structure look good.


84-93: Icon guidelines are well-documented.
Providing clear recommendations around icon sizing, color inheritance, and best practices ensures consistent and accessible usage.

apps/dashboard/app/(app)/ratelimits/loading.tsx (1)

124-170: Placeholders for rate limit cards look good.
This grid-based skeleton structure provides a more realistic preview of the final UI compared to generic Skeleton components. No further concerns here.

internal/ui/src/components/textarea.tsx (2)

1-4: Good approach using class-variance-authority.
This setup keeps variant logic consistent and maintainable.


58-81: Verify accessibility compliance.
When adding icons as purely decorative elements, confirm that screen readers ignore them (e.g., using aria-hidden="true" or equivalent). If icons convey meaning or allow user interaction, ensure label or title attributes are present.

apps/dashboard/app/(app)/apis/loading.tsx (2)

2-2: No issues with the icon imports.


159-159: Closing container node looks good.
No concerns.

internal/ui/src/components/form/form-textarea.tsx (8)

2-4: Imports and utility usage look fine.
No concerns here.


7-13: Type definitions accurately extend document-based props.
This addition is consistent with your architecture.


15-15: Merged prop type definition is straightforward.
Looks good for maintaining clarity and reusability.


28-29: Icon props are well-integrated.
Passing leftIcon and rightIcon aligns with a flexible UI design pattern.


49-50: Conditional tags for required/optional states are simple and clear.
No implementation concerns.


53-53: Textarea usage is consistent with the existing patterns.
No functional concerns here.


56-59: Variant and icon props are cleanly passed down.
This effectively toggles the component’s styles depending on validation state.


107-109: Generic tag props are well-defined.
They enable flexibility for further customization if needed.

apps/engineering/content/design/components/form/form-textarea.variants.tsx (2)

1-159: Well-structured variant examples with thematic references

Great job creating a comprehensive set of variants for the FormTextarea component. The Lord of the Rings themed examples make the documentation both informative and engaging. The file is well-organized with clear comments for each variant.


153-156: Great use of additional props in the complex example

The complex example effectively demonstrates how to use additional props like className, id, and rows. This helps developers understand the full range of customization options available.

@chronark chronark merged commit 59f52eb into main Mar 14, 2025
29 of 31 checks passed
@chronark chronark deleted the move-textarea-to-ui branch March 14, 2025 17:13
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