Skip to content

Conversation

@arika0093
Copy link
Owner

@arika0093 arika0093 commented Jun 30, 2025

Summary

  • Add optional HTML <time> element wrapper to LocalTimeText component with proper datetime attribute for improved accessibility and semantic HTML
  • Introduce DisableTimeElement parameter to maintain backward compatibility
  • Update tests and documentation to reflect new default behavior

Changes

  • LocalTimeText component: Now wraps output in <time datetime="ISO-8601">formatted-time</time> by default
  • DisableTimeElement parameter: Allows users to disable the <time> wrapper and get plain text (previous behavior)
  • ISO-8601 datetime attribute: Provides machine-readable time format for accessibility tools and browsers
  • Updated tests: All component tests now expect the new semantic markup
  • Enhanced documentation: Sample app includes usage examples and explanation of the new parameter

Test plan

  • All existing unit tests pass with updated expectations
  • Component renders semantic <time> element with proper datetime attribute by default
  • DisableTimeElement=true produces plain text output (backward compatibility)
  • Sample application demonstrates both usage patterns
  • Public API includes new DisableTimeElement parameter

close #6

Summary by CodeRabbit

  • New Features
    • Added a parameter to the local time display component allowing users to disable the semantic HTML <time> element wrapper.
  • Documentation
    • Expanded usage instructions to clarify the default output and new configuration option for the local time component.
  • Tests
    • Updated and added tests to verify both the default and new rendering behaviors of the local time component.

@coderabbitai
Copy link

coderabbitai bot commented Jun 30, 2025

Walkthrough

The changes introduce a new DisableTimeElement parameter to the LocalTimeText Blazor component, allowing control over whether the output is wrapped in a semantic <time> HTML element with a datetime attribute. Documentation and tests were updated to reflect and verify this new behavior.

Changes

File(s) Change Summary
src/BlazorLocalTime/Components/LocalTimeText.razor, .razor.cs Added DisableTimeElement parameter; component now conditionally wraps output in <time> with datetime attribute.
example/BlazorLocalTimeSample/Pages/Home.razor Expanded documentation to explain <time> element usage and new parameter; added example output comment.
tests/BlazorLocalTimeTest/Approvals/PublicApiCheckTest.Run.net8.approved.txt
tests/BlazorLocalTimeTest/Approvals/PublicApiCheckTest.Run.net9.approved.txt
Public API approval files updated to include new DisableTimeElement property.
tests/BlazorLocalTimeTest/Component/LocalTimeTotal1.razor Updated usage of <LocalTimeText> to include DisableTimeElement attribute.
tests/BlazorLocalTimeTest/LocalTimeTextTest.razor Updated assertions for <time> element; added test for DisableTimeElement parameter.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant LocalTimeText Component
    participant Browser

    User->>LocalTimeText Component: Render with Value, Format, [DisableTimeElement]
    alt DisableTimeElement is false (default)
        LocalTimeText Component->>Browser: Output <time datetime="...">formatted value</time>
    else DisableTimeElement is true
        LocalTimeText Component->>Browser: Output formatted value (no <time>)
    end
Loading

Assessment against linked issues

Objective Addressed Explanation
Generate accessible <time> tags with ISO-8601 datetime attribute (#6)
Provide a component that automatically generates <time> with datetime populated (#6)

Assessment against linked issues: Out-of-scope changes

No out-of-scope changes detected.

Poem

In the garden of code, a new sprout appears,
A toggle for time, for browsers and peers.
With or without tags, your moments can shine,
Wrapped up in <time>, or left as plain line.
Hooray for new options—so neat and so prime!
—From a rabbit who’s always on time. 🐇⏰


📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 51a18a4 and 7a4130b.

📒 Files selected for processing (1)
  • src/BlazorLocalTime/Components/LocalTimeText.razor.cs (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/BlazorLocalTime/Components/LocalTimeText.razor.cs
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: build
✨ 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.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 explain its main purpose.
    • @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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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 generate sequence diagram to generate a sequence diagram of the changes in 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.

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 (1)
src/BlazorLocalTime/Components/LocalTimeText.razor.cs (1)

28-34: Improve parameter documentation for clarity.

The documentation should explicitly state what happens for both true and false values to avoid ambiguity.

 /// <summary>
-/// Gets or sets whether to wrap the output in an HTML &lt;time&gt; element with a datetime attribute.
-/// When false, generates a semantic &lt;time&gt; tag with ISO-8601 datetime attribute for accessibility.
-/// The default value is false.
+/// Gets or sets whether to disable wrapping the output in an HTML &lt;time&gt; element.
+/// When false (default), generates a semantic &lt;time&gt; tag with ISO-8601 datetime attribute for accessibility.
+/// When true, renders plain text output for backward compatibility.
 /// </summary>
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 891d424 and 51a18a4.

📒 Files selected for processing (7)
  • example/BlazorLocalTimeSample/Pages/Home.razor (1 hunks)
  • src/BlazorLocalTime/Components/LocalTimeText.razor (1 hunks)
  • src/BlazorLocalTime/Components/LocalTimeText.razor.cs (2 hunks)
  • tests/BlazorLocalTimeTest/Approvals/PublicApiCheckTest.Run.net8.approved.txt (1 hunks)
  • tests/BlazorLocalTimeTest/Approvals/PublicApiCheckTest.Run.net9.approved.txt (1 hunks)
  • tests/BlazorLocalTimeTest/Component/LocalTimeTotal1.razor (1 hunks)
  • tests/BlazorLocalTimeTest/LocalTimeTextTest.razor (4 hunks)
🔇 Additional comments (8)
src/BlazorLocalTime/Components/LocalTimeText.razor (1)

3-10: All properties implemented; changes approved

I’ve confirmed that both FormattedValue and IsoDateTime are properly defined in src/BlazorLocalTime/Components/LocalTimeText.razor.cs. The conditional rendering now cleanly wraps the formatted time in a semantic <time> element by default, falling back to plain text when disabled—excellent for accessibility and backward compatibility.

No further changes required.

tests/BlazorLocalTimeTest/Component/LocalTimeTotal1.razor (1)

5-5: LGTM! Proper test usage of the new parameter.

The test correctly demonstrates usage of the DisableTimeElement parameter, ensuring the component behavior is validated when the semantic HTML wrapper is disabled.

tests/BlazorLocalTimeTest/Approvals/PublicApiCheckTest.Run.net8.approved.txt (1)

66-67: LGTM! Correctly structured public API addition.

The new DisableTimeElement parameter is properly defined with the appropriate component parameter attribute and boolean type. This represents a clean, non-breaking API extension.

tests/BlazorLocalTimeTest/Approvals/PublicApiCheckTest.Run.net9.approved.txt (1)

66-67: LGTM! Consistent API across target frameworks.

The DisableTimeElement parameter definition is consistent between .NET 8 and .NET 9, ensuring proper cross-framework compatibility.

example/BlazorLocalTimeSample/Pages/Home.razor (1)

56-64: Excellent documentation update with clear examples.

The updated documentation effectively explains the new semantic HTML behavior, including:

  • Clear explanation of the default <time> element wrapping
  • Purpose and usage of the DisableTimeElement parameter
  • Concrete example showing the expected HTML output with datetime attribute

This will help users understand both the accessibility benefits and practical usage.

tests/BlazorLocalTimeTest/LocalTimeTextTest.razor (2)

15-15: LGTM! Test assertions correctly updated for semantic HTML output.

The updated assertions properly verify the new default behavior where the component wraps output in a semantic <time> element with ISO-8601 datetime attribute.

Also applies to: 30-30, 44-44, 57-57


60-72: Excellent test coverage for the new DisableTimeElement parameter.

This test properly verifies that when DisableTimeElement is true, the component renders plain text output without the semantic <time> wrapper, ensuring backward compatibility.

src/BlazorLocalTime/Components/LocalTimeText.razor.cs (1)

59-60: LGTM! ISO-8601 datetime formatting implemented correctly.

The IsoDateTime property properly uses the round-trip format specifier ("O") to generate ISO-8601 formatted UTC datetime for the <time> element's datetime attribute.

@arika0093 arika0093 merged commit b29a7a2 into main Jun 30, 2025
2 checks passed
@arika0093 arika0093 deleted the feat/issue-6 branch June 30, 2025 18:02
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.

feat: generate a <time> tag

2 participants