-
Notifications
You must be signed in to change notification settings - Fork 12
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
base: main
Are you sure you want to change the base?
Conversation
WalkthroughThis pull request introduces the Changes
Sequence DiagramsequenceDiagram
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
Possibly related PRs
Suggested reviewers
Poem
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? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this 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 betweenreadonly
,disabled
, andcontrolled
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 (likearia-label
orid
+<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 manualStateHasChanged()
.If the
ValueChanged
event is already causing a component re-render, callingStateHasChanged()
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 bothopacity-disabled
andopacity-50
. Ifopacity-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 whenDisabled == 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 aLumexTextarea
in their markup without navigating to the separateUsage.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 fromTextarea.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 bothReadonly
andDisabled
to ensure they don’t conflict.
67-76
: Behavior validation is solid.
The test forOnInput
behavior is correct. Consider also adding a test for the default (OnChange
) scenario to confirm thatValue
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
📒 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.
I haven’t delved deeply into the code, but I noticed a couple of points regarding naming conventions:
Hope it makes sense 🙌 |
There was a problem hiding this 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"
) oraria-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 anAction<string?>?
forValueChanged
is valid, Blazor conventionally usesEventCallback<T>
for parent-child communication. ConvertingValueChanged
toEventCallback<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 inOnValueChanged
for clarity.
The parametervalue
might be better namednewValue
orupdatedValue
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 theBehavior
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 withTwMerge.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 referencesLumexTextArea
but is namedTextareaTests
. As you are normalizing “TextArea,” consider renaming the file toTextAreaTests.razor
to match the component's name.
47-49
: Standardize “ReadOnly” test name.
Since the component property is spelledReadOnly
, 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 anEventCallback
. 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
📒 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
- The snippet parameter
"TextArea.Code.Usage"
helps maintain consistency across documentation examples. - 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.”
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! |
There was a problem hiding this 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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
src/LumexUI/Styles/Textarea.cs
Outdated
There was a problem hiding this comment.
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.
There was a problem hiding this 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 managementInstead 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 experienceThe 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 callThe
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
📒 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 conventionBased 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.
UsingTestContext
and injectingTwMerge
demonstrates a solid foundation for Blazor component testing.
7-14
: JSInterop setup is well-structured.
The mocking of theinput.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 thereadonly
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 thedisabled
attribute but also confirms the environment for visually or functionally blocking user interactions.
67-76
: Input behavior test is clear and robust.
The usage ofInputBehavior.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 andValueChanged
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.
UsingDocsContentLayout
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.
TheOnInitialized
method clearly demonstrates how to configure the docs page title, category, and description, providing a good user experience for exploring the docs.
private string _value = string.Empty; | ||
private string? _newValue = string.Empty; |
There was a problem hiding this comment.
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.
private string _value = string.Empty; | |
private string? _newValue = string.Empty; | |
private string _newValue = string.Empty; |
Description
Adds a basic textarea component.
#117
Closes #{issue_number}
What's been done?
New component added
Checklist
Additional Notes
Summary by CodeRabbit
New Features
LumexTextArea
component with support for:Documentation
Tests