Skip to content

Migrate UI components from partial views to TagHelpers - #836

Merged
poppastring merged 6 commits into
mainfrom
partialview-taghelper-refactor
May 13, 2026
Merged

poppastring merged 6 commits into
mainfrom
partialview-taghelper-refactor

Conversation

@poppastring

Copy link
Copy Markdown
Owner

PR Classification

Code cleanup and modernization: migrates UI components from partial views to TagHelpers and ViewComponents for improved maintainability and reusability.

PR Summary

This PR replaces legacy partial views with new TagHelpers and ViewComponents for common UI elements, updates all references, and retains obsolete partials for backward compatibility.

  • Adds new TagHelpers for meta tags, social cards, alerts, modals, and theme stylesheets.
  • Adds new ViewComponents for comment blocks and cookie consent.
  • Updates layout and content files (e.g., _Layout.cshtml, _BlogItem.cshtml) to use the new TagHelpers and ViewComponents.
  • Marks old partials as obsolete and rewrites them to invoke the new components.
  • Updates integration tests to verify the new elements in rendered output.

Replaces Razor partials with backward-compatibility shims that delegate to new Tag Helpers and View Components for layout, meta, alerts, and comments. Moves rendering logic into C# classes, introduces strongly-typed view models, and encourages direct use of new components. No business logic changes; improves maintainability and reusability.
Replaced several Razor partials in _Layout.cshtml and _BlogItem.cshtml with custom Tag Helpers and View Components for improved maintainability. Introduced DefaultCredentialsWarningTagHelper to render admin security alerts, replacing the old partial. Modernized meta, RSS, and consent components for consistency.
Replaced Razor partial views with tag helpers and view components in _BlogItem.cshtml and _Layout.cshtml. Updated delete modal, comment block, head/meta, and cookie consent to use modern components for improved maintainability and consistency.
Renamed and expanded main page test to check title, meta, feed links, and cookie consent banner. Added TagHelperMigrationSmokeTests for Open Graph, Twitter Card, JSON-LD schema, comment toggle, and admin warning behaviors. Included helper methods for meta assertions and login.

Expand Playwright tests for head/meta and TagHelpers

Refactored and expanded PlaywrightPageTests to check for key <head> elements including title, meta description, RSS/Atom links, and cookie consent. Added TagHelperMigrationSmokeTests to verify Open Graph, Twitter Card, JSON-LD schema, comment toggles, and dev-only suppression of default credentials warning. Includes helper methods for meta tag checks and login.
Updated comments in Razor partials to explicitly mark them as obsolete and retained only for backward compatibility. Each now recommends using the corresponding TagHelper or ViewComponent in new code, with a note that removal is not planned. No functional changes were made.
- Move CookieConsent and TagHelper styles from inline to site.css
- Add default CSS hooks for TagHelpers/ViewComponents
- Use Bootstrap d-none for comment success alert visibility
- Update JS to toggle d-none instead of display style
- Apply dbc-delete-post-form class for modal form layout
@poppastring poppastring self-assigned this May 13, 2026
@poppastring
poppastring merged commit b4c81ac into main May 13, 2026
3 checks passed
@poppastring
poppastring deleted the partialview-taghelper-refactor branch May 13, 2026 17:53
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.

1 participant