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(components): Add basic textarea component #129

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

Conversation

trucidare
Copy link

@trucidare trucidare commented Dec 29, 2024

Description

Adds a basic textarea component.

#117

Closes #{issue_number}

What's been done?

New component added

  • Added to the docs
  • Tests added

Checklist

  • My code follows the project's coding style and guidelines.
  • I have included inline docs for my changes, where applicable.
  • I have added, updated or removed tests according to my changes.
  • All tests are passing.
  • There's an open issue for the PR that I am making.

Additional Notes

Summary by CodeRabbit

  • New Features

    • Introduced LumexTextArea component with support for:
      • Placeholder text
      • Disabled state
      • Read-only mode
      • Full-width option
      • Value change event handling
  • Documentation

    • Added comprehensive documentation for TextArea component
    • Included usage examples demonstrating different TextArea configurations
  • Tests

    • Created unit tests to validate TextArea component functionality

Copy link

coderabbitai bot commented Dec 29, 2024

Walkthrough

This pull request introduces the LumexTextArea component to the Lumex UI framework. The changes include creating a new textarea component with various features like disabled state, read-only mode, and value change handling. The implementation spans multiple files, adding documentation, styles, and test coverage for the new component. The PR enhances the UI component library by providing a flexible and customizable textarea input element with comprehensive examples and styling.

Changes

File Change Summary
docs/LumexUI.Docs.Client/Common/Navigation/NavigationStore.cs Added LumexTextArea to navigation categories
src/LumexUI/Styles/Textarea.cs New class with static styling methods for textarea
docs/LumexUI.Docs.Client/Pages/Components/TextArea/Examples/* Added example components for Usage, Controlled, Disabled, and ReadOnly states
docs/LumexUI.Docs.Client/Pages/Components/TextArea/PreviewCodes/* Created preview code components for different textarea examples
src/LumexUI/Components/TextArea/LumexTextArea.razor New Razor component for textarea rendering
src/LumexUI/Components/TextArea/LumexTextArea.razor.cs Component code-behind with properties and logic
tests/LumexUI.Tests/Components/Textarea/TextAreaTests.razor Added comprehensive unit tests for textarea component

Sequence Diagram

sequenceDiagram
    participant User
    participant TextArea
    participant ValueChanged Event

    User->>TextArea: Input text
    alt On Input Behavior
        TextArea->>ValueChanged Event: Trigger immediately
    else On Change Behavior
        User->>TextArea: Leaves input
        TextArea->>ValueChanged Event: Trigger after leaving
    end
    ValueChanged Event->>User: Update bound value
Loading

Possibly related PRs

Suggested reviewers

  • desmondinho

Poem

🐰 A Textarea Tale of Delight

Hop, hop, through lines of code so bright,
A textarea springs to digital life,
Flexible, styled with rabbit's might,
Capturing words without any strife!

Squeak! Another component takes flight! 🚀


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 generate docstrings to generate docstrings for this PR. (Beta)
  • @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: 0

🧹 Nitpick comments (15)
docs/LumexUI.Docs.Client/Pages/Components/Textarea/Examples/Disabled.razor (1)

2-3: Consider adding a descriptive label or aria-label for accessibility.
Currently, the component examples only have placeholder text. For improved accessibility, you might consider including a label or aria-label informing screen readers about the intended purpose of the textarea.

docs/LumexUI.Docs.Client/Pages/Components/Textarea/PreviewCodes/Readonly.razor (1)

3-4: Consider consistent naming for your snippet references.

You're referencing "Textarea.Code.Usage" for this read-only example preview. If you plan to use separate snippet names for distinct scenarios (e.g., read-only vs. controlled), consider using snippet names that closely match their examples for easier maintenance.

docs/LumexUI.Docs.Client/Pages/Components/Textarea/PreviewCodes/Controlled.razor (1)

3-4: Confirm snippet organization.

Like the read-only snippet, this references "Textarea.Code.Usage". If you envision more specialized usage examples, consider naming snippet references more clearly to maintain clarity between readonly, disabled, and controlled usage scenarios.

src/LumexUI/Components/Textarea/LumexTextarea.razor (1)

4-16: Add accessibility attributes or provide guidance on labeling.

While this component supports Placeholder, consider discussing or supporting additional ARIA attributes (like aria-label or id + <label for="...">) for enhanced accessibility, especially when placeholders are used in lieu of visible labels.

docs/LumexUI.Docs.Client/Pages/Components/Textarea/Examples/Controlled.razor (1)

14-18: Evaluate necessity of manual StateHasChanged().

If the ValueChanged event is already causing a component re-render, calling StateHasChanged() again may be redundant. Review whether this extra call still adds value by forcing a UI update at precise times.

src/LumexUI/Styles/Textarea.cs (2)

31-36: Redundant opacity declarations.
The styles _disabled define both opacity-disabled and opacity-50. If opacity-disabled merely toggles a 50% opacity, these may conflict or result in unexpected cascades. Consider removing one or consolidating them into a single statement for clarity.

	private readonly static string _disabled = ElementClass.Empty()
-		.Add( "opacity-disabled" )
		.Add( "opacity-50" )
		.Add( "cursor-not-allowed" )
		.Add( "pointer-events-none" )
		.ToString();

Line range hint 53-54: Potential improvement to style composition.
Currently, _base and _focus are always added, even if the textarea is disabled. You might consider conditionally applying the _focus style only when Disabled == false to avoid confusion, though it might not cause functional issues if the class is effectively overridden by the _disabled style.

docs/LumexUI.Docs.Client/Pages/Components/Textarea/Textarea.razor (2)

6-7: Documentation clarity check.
The short description of the textarea component is acceptable, but consider providing a minimal code snippet or usage explanation here in the docs section so newcomers can quickly see how to declare a LumexTextarea in their markup without navigating to the separate Usage.razor file.


21-21: Typographical consistency.
"Changes" should be lowercase for consistency or reworded as "to prevent changes."

	<p>
-	    You can make a textareas value read only to prevent Changes.
+	    You can make a textarea’s value read-only to prevent changes.
	</p>
src/LumexUI/Components/Textarea/LumexTextarea.razor.cs (2)

16-17: Minor grammatical fix in summary.
"Whether the textareas value is readonly" should be "Whether the textarea’s value is read-only."

/// Gets or sets a value indicating whether the textareas value is readonly.
-/// Gets or sets a value indicating whether the textareas value is readonly.
+/// Gets or sets a value indicating whether the textarea’s value is read-only.

26-27: Typo in docstring.
"Gets or sets a value indicating wether" is missing an 'h.'

/// Gets or sets a value indicating wether the ValueChanged event will be fired on input or change.
-/// Gets or sets a value indicating wether the ValueChanged event...
+/// Gets or sets a value indicating whether the ValueChanged event...
tests/LumexUI.Tests/Components/Textarea/TextareaTests.razor (3)

15-21: Good coverage for initial rendering.
The test ensures that no exception is thrown upon rendering. Consider verifying the actual computed CSS class to confirm the expected classes from Textarea.GetStyles() are present. This will further ensure the styling logic is being applied.


47-55: Readonly vs disabled tests are valid.
These tests confirm distinct attributes. If possible, you might add a combined test for both Readonly and Disabled to ensure they don’t conflict.


67-76: Behavior validation is solid.
The test for OnInput behavior is correct. Consider also adding a test for the default (OnChange) scenario to confirm that Value does not update on each keystroke.

Do you want me to provide sample test code for verifying the OnChange behavior?

docs/LumexUI.Docs.Client/Common/Navigation/NavigationStore.cs (1)

82-82: Confirmed that the API docs entry is consistent with other components.

It's important to ensure that additional usage or parameter details for LumexTextarea are properly documented in the component’s own documentation section to help developers fully understand its features.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between f1ae82e and 8b86b31.

📒 Files selected for processing (15)
  • docs/LumexUI.Docs.Client/Common/Navigation/NavigationStore.cs (2 hunks)
  • docs/LumexUI.Docs.Client/LumexUI.Docs.Client.csproj (1 hunks)
  • docs/LumexUI.Docs.Client/Pages/Components/Textarea/Examples/Controlled.razor (1 hunks)
  • docs/LumexUI.Docs.Client/Pages/Components/Textarea/Examples/Disabled.razor (1 hunks)
  • docs/LumexUI.Docs.Client/Pages/Components/Textarea/Examples/Readonly.razor (1 hunks)
  • docs/LumexUI.Docs.Client/Pages/Components/Textarea/Examples/Usage.razor (1 hunks)
  • docs/LumexUI.Docs.Client/Pages/Components/Textarea/PreviewCodes/Controlled.razor (1 hunks)
  • docs/LumexUI.Docs.Client/Pages/Components/Textarea/PreviewCodes/Disabled.razor (1 hunks)
  • docs/LumexUI.Docs.Client/Pages/Components/Textarea/PreviewCodes/Readonly.razor (1 hunks)
  • docs/LumexUI.Docs.Client/Pages/Components/Textarea/PreviewCodes/Usage.razor (1 hunks)
  • docs/LumexUI.Docs.Client/Pages/Components/Textarea/Textarea.razor (1 hunks)
  • src/LumexUI/Components/Textarea/LumexTextarea.razor (1 hunks)
  • src/LumexUI/Components/Textarea/LumexTextarea.razor.cs (1 hunks)
  • src/LumexUI/Styles/Textarea.cs (1 hunks)
  • tests/LumexUI.Tests/Components/Textarea/TextareaTests.razor (1 hunks)
✅ Files skipped from review due to trivial changes (2)
  • docs/LumexUI.Docs.Client/Pages/Components/Textarea/Examples/Readonly.razor
  • docs/LumexUI.Docs.Client/LumexUI.Docs.Client.csproj
🔇 Additional comments (10)
docs/LumexUI.Docs.Client/Pages/Components/Textarea/Examples/Usage.razor (1)

2-3: Usage examples look straightforward.
Showcasing text and placeholders in two different textareas is a clear demonstration of their functionality. This section effectively communicates how to set initial values and placeholders.

docs/LumexUI.Docs.Client/Pages/Components/Textarea/PreviewCodes/Usage.razor (1)

1-1: Verify environment compatibility for @rendermode InteractiveWebAssembly.
If this documentation also targets Blazor Server rendering contexts, ensure that this render mode is suitable or conditionally applied.

docs/LumexUI.Docs.Client/Pages/Components/Textarea/PreviewCodes/Disabled.razor (1)

3-4: Confirm the snippet reference matches the disabled example.
The Code="@new(name: null, snippet: "Textarea.Code.Usage")" references "Textarea.Code.Usage" while the displayed example is the disabled variant. Double-check that the snippet name aligns with the showcased example to prevent confusion for readers.

docs/LumexUI.Docs.Client/Pages/Components/Textarea/PreviewCodes/Readonly.razor (1)

1-1: Good use of @rendermode InteractiveWebAssembly.

This directive cleanly signals that the preview is rendered via WebAssembly, providing an interactive Blazor playback mode.

docs/LumexUI.Docs.Client/Pages/Components/Textarea/PreviewCodes/Controlled.razor (1)

1-1: Great approach to interactive previews.

Similar to the read-only example, using @rendermode InteractiveWebAssembly offers an engaging experience for demonstrating the controlled textarea.

src/LumexUI/Components/Textarea/LumexTextarea.razor (2)

7-7: Validate disabled attribute usage.

Blazor forwards the Disabled Boolean property into HTML's disabled attribute, which is valid. Make sure you consistently handle scenarios where the Disabled property might conflict with other logic or styles.


11-11: Confirm usage of data-disabled.

data-disabled="@Disabled.ToAttributeValue()" can help styling or JavaScript selection. Verify that your styling or scripts rely on this attribute. If not, consider removing it to keep the HTML clean or document its intended purpose.

docs/LumexUI.Docs.Client/Pages/Components/Textarea/Examples/Controlled.razor (1)

2-2: Nice demonstration of two-way data flow.

The ValueChanged callback, along with _newValue, effectively illustrates how to manage controlled inputs. This is a clear example of updates triggered by user input.

src/LumexUI/Components/Textarea/LumexTextarea.razor.cs (1)

53-54: RootClass composition looks good.
Merging styles from the Textarea.GetStyles() method is clear and consistent with your approach. No concerns here.

docs/LumexUI.Docs.Client/Common/Navigation/NavigationStore.cs (1)

42-42: Looks good to include the new component under “Components”.

This maintains consistency with the existing pattern of registering new components. No issues spotted.

@JudeVajira
Copy link

I haven’t delved deeply into the code, but I noticed a couple of points regarding naming conventions:

  1. The casing of "Readonly" seems inconsistent with other usages in this repo, such as this example. It would be more consistent to use "ReadOnly," which aligns with both the repository's conventions and common standards (e.g., IReadOnlyCollection).
  2. The component name LumexTextarea might be better as LumexTextArea to match Blazor's built-in InputTextArea component and improve clarity and the standard conventions.

Hope it makes sense 🙌

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

🧹 Nitpick comments (14)
docs/LumexUI.Docs.Client/Pages/Components/TextArea/PreviewCodes/Usage.razor (1)

3-5: Consider naming consistency for snippet references.

You are using a snippet named "TextArea.Code.Usage" here. Ensure that snippet names across the documentation (e.g., "Controlled.razor", "Disabled.razor") follow a consistent format like "TextArea.Code.Disabled", "TextArea.Code.Controlled", etc. This makes it easier to maintain references across different preview components.

docs/LumexUI.Docs.Client/Pages/Components/TextArea/PreviewCodes/Disabled.razor (1)

3-5: Check snippet reference naming consistency.

Like with Usage.razor, the snippet is "TextArea.Code.Usage" even though this preview is specifically for the disabled example. You might rename it to "TextArea.Code.Disabled" or a similar pattern for clarity.

docs/LumexUI.Docs.Client/Pages/Components/TextArea/PreviewCodes/Controlled.razor (1)

3-5: Ensure snippet references match the example scope.

Similar to the other preview files, consider a more specific snippet name for the controlled example, such as "TextArea.Code.Controlled". This improves maintainability as your codebase grows with more examples.

src/LumexUI/Components/TextArea/LumexTextArea.razor (1)

11-15: Improve accessibility with ARIA attributes.

You already provide data-disabled, but consider adding relevant ARIA attributes (e.g., aria-disabled="@Disabled") or aria-readonly="@ReadOnly" to improve screen reader support.

Apply this diff to add basic ARIA support:

 <textarea
   class="@RootClass"
   style="@RootStyle"
   disabled="@Disabled"
   readonly="@ReadOnly"
+  aria-disabled="@Disabled"
+  aria-readonly="@ReadOnly"
   placeholder="@Placeholder"
   required="@Required"
   data-disabled="@Disabled.ToAttributeValue()"
   @bind="Value" 
   @bind:event="@(Behavior == InputBehavior.OnInput ? "oninput" : "onchange")" 
   @bind:after="OnValueChanged"
   @attributes="@AdditionalAttributes">
 </textarea>
docs/LumexUI.Docs.Client/Pages/Components/TextArea/Examples/Controlled.razor (3)

2-2: Consider switching to an event callback.
While using an Action<string?>? for ValueChanged is valid, Blazor conventionally uses EventCallback<T> for parent-child communication. Converting ValueChanged to EventCallback<string> would allow consumers to exploit built-in Blazor event binding patterns (e.g., @bind-Value).


11-11: Remove unused _value field or utilize it if necessary.
Currently, _value is declared but never used within this example. Eliminate it if it's not needed, or consider using it for demonstration.

-	private string _value = string.Empty;
+	// remove the unused field if not required

14-18: Rename parameter in OnValueChanged for clarity.
The parameter value might be better named newValue or updatedValue to match the _newValue field. This helps distinguish them in more complex scenarios.

docs/LumexUI.Docs.Client/Pages/Components/TextArea/TextArea.razor (2)

21-21: Update phrasing for consistency.
The sentence reads: “You can make a textareas value read only to prevent Changes.” Consider using consistent wording and casing:
“You can make a textarea's value read-only to prevent changes.”

- You can make a textareas value read only to prevent Changes.
+ You can make a textarea's value read-only to prevent changes.

29-31: Clarify the “Intermediate” behavior.
In the Blazor ecosystem, “OnInput” vs. “OnChange” is standard terminology. Consider linking or clarifying how to set these behaviors programmatically using the Behavior property (e.g., InputBehavior.OnInput) to make the documentation more complete.

src/LumexUI/Components/TextArea/LumexTextArea.razor.cs (2)

28-28: Spelling fix: “whether” in documentation.
Minor grammatical enhancement for “wether.”

- /// Gets or sets a value indicating wether the ValueChanged event will be fired on input or change.
+ /// Gets or sets a value indicating whether the ValueChanged event will be fired on input or change.

53-55: Consider merging style in a base class.
Merging styles with TwMerge.Merge is useful, but if multiple components do something similar, moving repeated logic to a base class or utility function might reduce duplication across the codebase.

tests/LumexUI.Tests/Components/Textarea/TextareaTests.razor (3)

1-1: File-level naming consistency.
The file references LumexTextArea but is named TextareaTests. As you are normalizing “TextArea,” consider renaming the file to TextAreaTests.razor to match the component's name.


47-49: Standardize “ReadOnly” test name.
Since the component property is spelled ReadOnly, consider changing the test name from “ShouldRenderReadonly” to “ShouldRenderReadOnly” for uniformity.

-[Fact]
-public void ShouldRenderReadonly()
+[Fact]
+public void ShouldRenderReadOnly()

67-76: Validate two-way binding usage.
While the test ensures the text area changes value on input, you might want to confirm the parent also receives the changed value if using an EventCallback. Expanding this test to verify the event callback usage ensures comprehensive coverage of the controlled scenario.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 81d6baf and bdc240d.

📒 Files selected for processing (15)
  • docs/LumexUI.Docs.Client/Common/Navigation/NavigationStore.cs (2 hunks)
  • docs/LumexUI.Docs.Client/LumexUI.Docs.Client.csproj (1 hunks)
  • docs/LumexUI.Docs.Client/Pages/Components/TextArea/Examples/Controlled.razor (1 hunks)
  • docs/LumexUI.Docs.Client/Pages/Components/TextArea/Examples/Disabled.razor (1 hunks)
  • docs/LumexUI.Docs.Client/Pages/Components/TextArea/Examples/ReadOnly.razor (1 hunks)
  • docs/LumexUI.Docs.Client/Pages/Components/TextArea/Examples/Usage.razor (1 hunks)
  • docs/LumexUI.Docs.Client/Pages/Components/TextArea/PreviewCodes/Controlled.razor (1 hunks)
  • docs/LumexUI.Docs.Client/Pages/Components/TextArea/PreviewCodes/Disabled.razor (1 hunks)
  • docs/LumexUI.Docs.Client/Pages/Components/TextArea/PreviewCodes/ReadOnly.razor (1 hunks)
  • docs/LumexUI.Docs.Client/Pages/Components/TextArea/PreviewCodes/Usage.razor (1 hunks)
  • docs/LumexUI.Docs.Client/Pages/Components/TextArea/TextArea.razor (1 hunks)
  • src/LumexUI/Components/TextArea/LumexTextArea.razor (1 hunks)
  • src/LumexUI/Components/TextArea/LumexTextArea.razor.cs (1 hunks)
  • src/LumexUI/Styles/Textarea.cs (1 hunks)
  • tests/LumexUI.Tests/Components/Textarea/TextareaTests.razor (1 hunks)
✅ Files skipped from review due to trivial changes (3)
  • docs/LumexUI.Docs.Client/Pages/Components/TextArea/Examples/Disabled.razor
  • docs/LumexUI.Docs.Client/Pages/Components/TextArea/Examples/ReadOnly.razor
  • docs/LumexUI.Docs.Client/Pages/Components/TextArea/Examples/Usage.razor
🚧 Files skipped from review as they are similar to previous changes (3)
  • docs/LumexUI.Docs.Client/LumexUI.Docs.Client.csproj
  • src/LumexUI/Styles/Textarea.cs
  • docs/LumexUI.Docs.Client/Common/Navigation/NavigationStore.cs
🔇 Additional comments (9)
docs/LumexUI.Docs.Client/Pages/Components/TextArea/PreviewCodes/ReadOnly.razor (2)

1-1: Clarity on render mode usage

Using @rendermode InteractiveWebAssembly is appropriate for enabling interactive Blazor WebAssembly features. This is a fine approach if the rest of the project expects WebAssembly interactivity.


3-5: Consistent naming and parameter usage

  1. The snippet parameter "TextArea.Code.Usage" helps maintain consistency across documentation examples.
  2. Referencing ReadOnly.razor is consistent with the recommended casing style ("ReadOnly") and aligns with the naming conventions discussed in the PR comments. This fosters clarity and standardization within the codebase.
docs/LumexUI.Docs.Client/Pages/Components/TextArea/PreviewCodes/Usage.razor (1)

1-1: Good use of Blazor’s InteractiveWebAssembly directive.

This directive ensures the preview code sections will be rendered interactively. No issues here.

docs/LumexUI.Docs.Client/Pages/Components/TextArea/PreviewCodes/Disabled.razor (1)

1-1: Confirm the rendering directive is necessary in each preview.

Each example uses @rendermode InteractiveWebAssembly. If these previews are displayed on the same page or within the same scope, consider whether you need the directive on all partials or if you can consolidate it to maintain clarity.

docs/LumexUI.Docs.Client/Pages/Components/TextArea/PreviewCodes/Controlled.razor (1)

1-1: No issues with the render mode usage.

This file follows the same pattern as the other preview examples and is working as intended.

src/LumexUI/Components/TextArea/LumexTextArea.razor (1)

7-8: Good alignment with naming feedback.

Using Disabled="@Disabled" and readonly="@ReadOnly" together maintains logical clarity. This is consistent with the feedback to use “ReadOnly” rather than “Readonly.”

docs/LumexUI.Docs.Client/Pages/Components/TextArea/TextArea.razor (1)

41-47: Ensure section title alignment with headings.
The headings array references “Usage,” “Disabled,” “Readonly,” and “Controlled,” which match the sections above. If you decide to rename “Readonly” to “ReadOnly,” remember to update both the headings array and relevant sections to retain consistency in your docs.

src/LumexUI/Components/TextArea/LumexTextArea.razor.cs (2)

8-8: Component name aligns with feedback.
Good job adjusting the component name to LumexTextArea, ensuring consistency with common Blazor naming like InputTextArea.


13-18: Consistent casing for 'ReadOnly'.
Valid usage here. Matches project-wide usage of “ReadOnly” over “Readonly.”

@desmondinho
Copy link
Contributor

Hey @trucidare,

Thank you so much for submitting the PR! Unfortunately, I haven’t had a chance to review the changes yet, but I’ll make sure to get to it later today.


Hey @JudeVajira, thank you for participating!

Copy link
Contributor

@desmondinho desmondinho left a comment

Choose a reason for hiding this comment

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

@trucidare Thank you for beginning work on the LumexTextarea. While the functional implementation of this component is relatively straightforward, you might encounter some challenges with styling, as it can occasionally be tricky. If you choose to delve deeper into implementing this component, please know that I’m always here to assist you.

Copy link
Contributor

Choose a reason for hiding this comment

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

Please follow the patterns for naming, structure, and etc of the existing examples. For this component, I think, you could follow the textbox examples.

Copy link
Contributor

@desmondinho desmondinho Dec 30, 2024

Choose a reason for hiding this comment

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

Since all the components in this library are highly inspired on the NextUI components, I suggest to keep following their structure.

Copy link
Contributor

Choose a reason for hiding this comment

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

As per functionality, follow the official Blazor InputTextArea

Copy link
Contributor

Choose a reason for hiding this comment

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

As per styles, follow the NextUI's one. They share a single input.ts for the input and textarea styles. We already have the same in the InputField.cs, however the styles for a textarea component are not there yet.

Actually, this task is not so easy at first glance.

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

🧹 Nitpick comments (3)
docs/LumexUI.Docs.Client/Pages/Components/TextArea/Examples/Controlled.razor (3)

2-2: Consider using two-way binding for better state management

Instead of using ValueChanged, consider using two-way binding with @bind-Value for more idiomatic Blazor code.

-<LumexTextArea Placeholder="Enter your email" ValueChanged="@OnValueChanged" />
+<LumexTextArea Placeholder="Enter your email" @bind-Value="_value" />

1-6: Add accessibility attributes for better user experience

The textarea and its associated label should be properly connected using ARIA attributes or HTML labels.

 <div class="w-full flex flex-col flex-wrap gap-4 md:flex-nowrap">
-	<LumexTextArea Placeholder="Enter your email" ValueChanged="@OnValueChanged" />
+	<label for="email-input" class="sr-only">Email Input</label>
+	<LumexTextArea id="email-input" Placeholder="Enter your email" ValueChanged="@OnValueChanged" aria-label="Email input field" />
 	<div class="flex flex-col items-center text-sm">
-		<span>Changed Value:</span>
+		<span id="changed-value-label">Changed Value:</span>
-		<span>@_newValue</span>
+		<span aria-labelledby="changed-value-label">@_newValue</span>
 	</div>
 </div>

14-18: Remove unnecessary StateHasChanged call

The StateHasChanged() call is redundant as Blazor automatically triggers a re-render when a field value changes.

 	private void OnValueChanged( string? value )
 	{
 		_newValue = value;
-		StateHasChanged();
 	}
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between f523dbf and 0993141.

📒 Files selected for processing (7)
  • docs/LumexUI.Docs.Client/Pages/Components/TextArea/Examples/Controlled.razor (1 hunks)
  • docs/LumexUI.Docs.Client/Pages/Components/TextArea/PreviewCodes/Controlled.razor (1 hunks)
  • docs/LumexUI.Docs.Client/Pages/Components/TextArea/PreviewCodes/Disabled.razor (1 hunks)
  • docs/LumexUI.Docs.Client/Pages/Components/TextArea/TextArea.razor (1 hunks)
  • src/LumexUI/Components/TextArea/LumexTextArea.razor (1 hunks)
  • src/LumexUI/Components/TextArea/LumexTextArea.razor.cs (1 hunks)
  • tests/LumexUI.Tests/Components/Textarea/TextAreaTests.razor (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (4)
  • docs/LumexUI.Docs.Client/Pages/Components/TextArea/PreviewCodes/Controlled.razor
  • docs/LumexUI.Docs.Client/Pages/Components/TextArea/PreviewCodes/Disabled.razor
  • src/LumexUI/Components/TextArea/LumexTextArea.razor
  • src/LumexUI/Components/TextArea/LumexTextArea.razor.cs
🔇 Additional comments (16)
docs/LumexUI.Docs.Client/Pages/Components/TextArea/Examples/Controlled.razor (1)

2-2: Verify component naming convention

Based on the PR comments, there's a discussion about the component naming convention (LumexTextArea vs LumexTextArea). Let's verify the usage across the codebase.

✅ Verification successful

Component naming is consistent across the codebase

Based on the search results, the component is consistently named as LumexTextArea throughout the codebase:

  • Component definition in src/LumexUI/Components/TextArea/LumexTextArea.razor.cs
  • All usages in tests under tests/LumexUI.Tests/Components/Textarea/
  • Documentation examples in docs/LumexUI.Docs.Client/Pages/Components/TextArea/Examples/
  • Navigation store references in docs/LumexUI.Docs.Client/Common/Navigation/NavigationStore.cs
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for both naming conventions to determine current usage
echo "Searching for LumexTextArea usage:"
rg "LumexTextArea"

echo -e "\nSearching for LumexTextArea usage:"
rg "LumexTextArea"

# Search for similar component names for consistency
echo -e "\nSearching for similar component names:"
rg "Lumex.*Area"

Length of output: 8590

tests/LumexUI.Tests/Components/Textarea/TextAreaTests.razor (9)

1-6: Great start with project references and test context setup.
Using TestContext and injecting TwMerge demonstrates a solid foundation for Blazor component testing.


7-14: JSInterop setup is well-structured.
The mocking of the input.getValidationMessage function ensures no external dependency disrupts the test flow.


15-22: Test naming aligns with expected behavior.
“ShouldRenderCorrectly” is a clear name indicating the test’s purpose.


23-33: Placeholder attribute checks are correct.
The assertions precisely validate the presence and correctness of the placeholder attribute.


34-46: Comprehensive check for both placeholder and value.
By verifying both attributes, you ensure that user-specified values do not override placeholder text inadvertently—great coverage.


47-55: Read-only attribute validation is straightforward and explicit.
Ensuring the readonly attribute is actually rendered is crucial for preventing unwanted modifications.


57-65: Disabled state testing is well-designed.
This test verifies not only the presence of the disabled attribute but also confirms the environment for visually or functionally blocking user interactions.


67-76: Input behavior test is clear and robust.
The usage of InputBehavior.OnInput to update the value in real time is properly validated. This ensures your component behaves as expected under continuous user input.


78-89: Value binding and ValueChanged event coverage is excellent.
This test method ensures that changes in the component propagate to the bound variable, matching standard Blazor patterns.

docs/LumexUI.Docs.Client/Pages/Components/TextArea/TextArea.razor (6)

1-5: Well-structured page and layout import.
Using DocsContentLayout is consistent with the project’s documentation design, ensuring uniform styling and navigation.


6-8: Clear usage description and example code reference.
Providing a usage snippet helps users quickly understand and visualize how to integrate the textarea component.


19-25: “ReadOnly” section matches the component’s property naming.
This consistency avoids confusion and clarifies how to enable the read-only state within the UI.


27-35: Comprehensive documentation of controlled vs. intermediate states.
Explanation of value events ensures developers understand the component’s behavior.


38-50: Heading structure is intuitive and easy to navigate.
Breaking down the documentation into smaller sections aligns with best practices for discoverability.


52-61: Metadata setup is well-formed for the docs layout.
The OnInitialized method clearly demonstrates how to configure the docs page title, category, and description, providing a good user experience for exploring the docs.

Comment on lines +11 to +12
private string _value = string.Empty;
private string? _newValue = string.Empty;
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Remove unused field and improve null handling

The _value field is never used, and the null handling could be improved.

-	private string _value = string.Empty;
-	private string? _newValue = string.Empty;
+	private string _newValue = string.Empty;
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
private string _value = string.Empty;
private string? _newValue = string.Empty;
private string _newValue = string.Empty;

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.

3 participants