Skip to content
This repository was archived by the owner on Sep 18, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,7 @@ namespace DotnetViewComponents.ViewComponents
/// </summary>
public class BreadcrumbsViewComponent : ViewComponent
{
/// <summary>
/// Invokes the ViewComponent and returns the view with the breadcrumb model.
/// </summary>
/// <param name="links">A list of tuples representing the breadcrumb links where each tuple contains a title and a URL.</param>
/// <returns>An <see cref="IViewComponentResult"/> that renders the breadcrumb view.</returns>
public IViewComponentResult Invoke(List<(string Title, string Url)> links)
public IViewComponentResult Invoke(List<(string Title, string spController, string aspAction, Dictionary<string, string>? aspRouteData)> links)
{
var model = new BreadcrumbsViewModel(links);

Expand Down
20 changes: 4 additions & 16 deletions DotnetViewComponents/ViewComponents/ButtonViewComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,17 @@ namespace DotnetViewComponents.ViewComponents
using DotnetViewComponents.ViewModels;

/// <summary>
/// Represents a view component for rendering a button.
/// A ViewComponent that renders a button.
/// </summary>
public class ButtonViewComponent : ViewComponent
{
/// <summary>
/// Invokes the button view component with the specified parameters.
/// </summary>
/// <param name="text">The text to be displayed on the button.</param>
/// <param name="aspController">The asp-controller to dynamically set the controller path of the link.</param>
/// <param name="aspAction">The asp-action to dynamically set the action path of the link..</param>
/// <param name="aspRouteData">The asp-all-route-data to dynamically set the extra parameters to the path of the link.</param>
/// <param name="url">The url for the link.</param>
/// <param name="style">The style attributes for the button.</param><param name="style">The style attributes for the button.</param>
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Have we deliberately removed these, Dalin?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Yes, it was in order to remove duplication in the XML documentation.

/// <param name="styling">The styling class for the button. Receives predefined styles from <see cref="ButtonStyle"/>. Defaults to <see cref="ButtonStyle.PRIMARY"/> if no input is passed to it.</param>
/// <param name="preventDoubleClick">Indicates whether to prevent double-clicking the button. Defaults to <c>false</c>.</param>
/// <returns>An <see cref="IViewComponentResult"/> that renders the button view.</returns>
public IViewComponentResult Invoke(
string text,
string style,
string styling = ButtonStyle.PRIMARY,
string aspController = null,
string aspAction = null,
Dictionary<string, string> aspRouteData = null,
string? aspController = null,
string? aspAction = null,
Dictionary<string, string>? aspRouteData = null,
bool preventDoubleClick = false)
{
var model = new ButtonViewModel(text, aspController, aspAction, aspRouteData, styling, style, preventDoubleClick);
Expand Down
21 changes: 7 additions & 14 deletions DotnetViewComponents/ViewComponents/CardViewComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,20 @@ namespace DotnetViewComponents.ViewComponents
using DotnetViewComponents.ViewModels;

/// <summary>
/// Represents a view component for rendering a card.
/// A ViewComponent that renders a card component.
/// </summary>
public class CardViewComponent : ViewComponent
{
/// <summary>
/// Invokes the card view component with the specified parameters.
/// </summary>
/// <param name="title">The title of the card.</param>
/// <param name="description">The content description of the card. Optional.</param>
/// <param name="imageSrc">The source URL of the image to be displayed on the card. Optional.</param>
/// <param name="headingLevel">The HTML heading level for the title. Defaults to <c>2</c>, which results in h2.</param>
/// <param name="hasArrow">Indicates whether the card should display an arrow. Defaults to <c>false</c>.</param>
/// <param name="isSecondary">Indicates whether the card is styled as a secondary card. Defaults to <c>false</c>.</param>
/// <param name="isClickable">Indicates whether the card is clickable. Defaults to <c>true</c>.</param>
/// <returns>An <see cref="IViewComponentResult"/> that renders the card view.</returns>
public IViewComponentResult Invoke(
string title,
string? description = null,
string? imageSrc = null,
int headingLevel = 2,
bool hasArrow = false,
bool isSecondary = false,
bool isClickable = true)
string? aspController = null,
string? aspAction = null,
Dictionary<string, string>? aspRouteData = null)
{
var model = new CardViewModel
(
Expand All @@ -36,7 +27,9 @@ public IViewComponentResult Invoke(
headingLevel,
hasArrow,
isSecondary,
isClickable
aspController,
aspAction,
aspRouteData
);
return View(model);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,10 @@ namespace DotnetViewComponents.ViewComponents
using DotnetViewComponents.ViewModels;

/// <summary>
/// Represents a view component for rendering a character-count input.
/// A ViewComponent that renders a character-count input.
/// </summary>
public class CharacterCountViewComponent : ViewComponent
{
/// <summary>
/// Invokes the character count view component with the specified parameters.
/// </summary>
/// <param name="id">The unique identifier for the character count component.</param>
/// <param name="maxLength">The maximum number of characters allowed.</param>
/// <param name="maxWords">The optional maximum number of words allowed. Defaults to <c>null</c>.</param>
/// <param name="threshold">The optional threshold for character count warnings. Defaults to <c>null</c>.</param>
/// <param name="label">The label for the character count component. Optional.</param>
/// <param name="hint">A hint or instruction for the user. Defaults to a predefined message.</param>
/// <param name="errorMessage">An optional error message to display when validation fails. Defaults to <c>null</c>.</param>
/// <param name="hasError">Indicates whether there is a validation error. Defaults to <c>false</c>.</param>
/// <returns>An <see cref="IViewComponentResult"/> that renders the character count view.</returns>
public IViewComponentResult Invoke(
string id,
int maxLength,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,11 @@ namespace DotnetViewComponents.ViewComponents
using Microsoft.AspNetCore.Mvc;
using DotnetViewComponents.ViewModels;

/// <summary>
/// A ViewComponent that renders a list of contents based on the provided name and list of content items.
/// </summary>
public class ContentsListViewComponent : ViewComponent
{
/// <summary>
/// Invokes the contents list view component with the specified parameters.
/// </summary>
/// <param name="name">The title of the contents list.</param>
/// <param name="listItems">The set of items in the contents list.</param>
/// <returns>An <see cref="IViewComponentResult"/> that renders the contents-list view.</returns>
public IViewComponentResult Invoke(
string name,
IEnumerable<ContentsListItemViewModel> listItems)
Expand Down
8 changes: 1 addition & 7 deletions DotnetViewComponents/ViewComponents/DetailsViewComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,10 @@ namespace DotnetViewComponents.ViewComponents
using DotnetViewComponents.ViewModels;

/// <summary>
/// Represents a view component that displays details using a summary and content.
/// A ViewComponent that displays details using a summary and content.
/// </summary>
public class DetailsViewComponent : ViewComponent
{
/// <summary>
/// Invokes the view component with the specified summary and content.
/// </summary>
/// <param name="summary">The summary to be displayed.</param>
/// <param name="content">The content to displayed.</param>
/// <returns>An <see cref="IViewComponentResult"/> that renders details view.</returns>
public IViewComponentResult Invoke(
string summary,
string content
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ namespace DotnetViewComponents.ViewComponents
using Microsoft.AspNetCore.Mvc;
using DotnetViewComponents.ViewModels;

/// <summary>
/// A ViewComponent that renders a "Do" or "Don't" list based on the provided rules.
/// </summary>
public class DoDontListViewComponent : ViewComponent
{
public IViewComponentResult Invoke(
Expand Down
3 changes: 3 additions & 0 deletions DotnetViewComponents/ViewComponents/FooterViewComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ namespace DotnetViewComponents.ViewComponents
using Microsoft.AspNetCore.Mvc;
using DotnetViewComponents.ViewModels;

/// <summary>
/// A ViewComponent that renders a footer with links.
/// </summary>
public class FooterViewComponent : ViewComponent
{
public IViewComponentResult Invoke(
Expand Down
3 changes: 3 additions & 0 deletions DotnetViewComponents/ViewComponents/ImageViewComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ namespace DotnetViewComponents.ViewComponents
using Microsoft.AspNetCore.Mvc;
using DotnetViewComponents.ViewModels;

/// <summary>
/// A ViewComponent that renders an image with a caption and optional attributes.
/// </summary>
public class ImageViewComponent : ViewComponent
{
public IViewComponentResult Invoke(
Expand Down
3 changes: 3 additions & 0 deletions DotnetViewComponents/ViewComponents/InsetTextViewComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ namespace DotnetViewComponents.ViewComponents
using Microsoft.AspNetCore.Mvc;
using DotnetViewComponents.ViewModels;

/// <summary>
/// A ViewComponent that renders inset text based on the provided HTML content.
/// </summary>
public class InsetTextViewComponent : ViewComponent
{
public IViewComponentResult Invoke(string contentHtml)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ namespace DotnetViewComponents.ViewComponents
using Microsoft.AspNetCore.Mvc;
using DotnetViewComponents.ViewModels;

/// <summary>
/// A ViewComponent that renders pagination controls based on the current page and total pages.
/// </summary>
public class PaginationViewComponent : ViewComponent
{
public IViewComponentResult Invoke(
Expand Down
3 changes: 3 additions & 0 deletions DotnetViewComponents/ViewComponents/SkipLinkViewComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ namespace DotnetViewComponents.ViewComponents
using Microsoft.AspNetCore.Mvc;
using DotnetViewComponents.ViewModels;

/// <summary>
/// A ViewComponent that renders a skip link to allow users to jump to the main content of a page.
/// </summary>
public class SkipLinkViewComponent : ViewComponent
{
public IViewComponentResult Invoke(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ namespace DotnetViewComponents.ViewComponents
using Microsoft.AspNetCore.Mvc;
using DotnetViewComponents.ViewModels;

/// <summary>
/// A ViewComponent that renders a list of summary items with an optional border.
/// </summary>
public class SummaryListViewComponent : ViewComponent
{
public IViewComponentResult Invoke(IEnumerable<SummaryListItemViewModel> summaryListItem,
Expand Down
3 changes: 3 additions & 0 deletions DotnetViewComponents/ViewComponents/TableViewComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ namespace DotnetViewComponents.ViewComponents
using Microsoft.AspNetCore.Mvc;
using DotnetViewComponents.ViewModels;

/// <summary>
/// A ViewComponent that renders a table based on the provided title and rows of data.
/// </summary>
public class TableViewComponent : ViewComponent
{
public IViewComponentResult Invoke(
Expand Down
3 changes: 3 additions & 0 deletions DotnetViewComponents/ViewComponents/TabsViewComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ namespace DotnetViewComponents.ViewComponents
using Microsoft.AspNetCore.Mvc;
using DotnetViewComponents.ViewModels;

/// <summary>
/// A ViewComponent that renders a set of tabs based on the provided title and list of tabs.
/// </summary>
public class TabsViewComponent : ViewComponent
{
public IViewComponentResult Invoke(
Expand Down
3 changes: 3 additions & 0 deletions DotnetViewComponents/ViewComponents/TagViewComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ namespace DotnetViewComponents.ViewComponents
using Microsoft.AspNetCore.Mvc;
using DotnetViewComponents.ViewModels;

/// <summary>
/// A ViewComponent that renders a tag based on the provided name and styling.
/// </summary>
public class TagViewComponent : ViewComponent
{
public IViewComponentResult Invoke(
Expand Down
3 changes: 3 additions & 0 deletions DotnetViewComponents/ViewComponents/TaskListViewComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ namespace DotnetViewComponents.ViewComponents
using Microsoft.AspNetCore.Mvc;
using DotnetViewComponents.ViewModels;

/// <summary>
/// A ViewComponent that renders a list of tasks based on the provided list of task items.
/// </summary>
public class TaskListViewComponent : ViewComponent
{
public IViewComponentResult Invoke(
Expand Down
11 changes: 8 additions & 3 deletions DotnetViewComponents/ViewModels/BreadcrumbsViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,18 @@ public class BreadcrumbsViewModel
/// Initializes a new instance of the <see cref="BreadcrumbsViewModel"/> class.
/// It receives a list of of string tuples containing the name/title of the link and the url path to it.
/// </summary>
/// <param name="links">A list of tuples representing the breadcrumb links where each tuple contains a title and a URL.</param>
public BreadcrumbsViewModel(List<(string Title, string Url)> links)
/// <param name="links">A list of tuples representing the breadcrumb links where each tuple contains a title
/// and a URL in the form of asp-controller, asp-action and asp-routeData.</param>
public BreadcrumbsViewModel(List<(string title, string aspController, string aspAction, Dictionary<string, string>? aspRouteData)> links)
{
Links = links;
}

public List<(string Title, string Url)> Links { get; set; }
/// <summary>
/// Gets or sets the list of breadcrumb links.
/// Each link is represented as a tuple containing the title, ASP.NET controller, ASP.NET action, and optional route data.
/// </summary>
public List<(string Title, string aspController, string aspAction, Dictionary<string, string>? aspRouteData)> Links { get; set; }

}
}
14 changes: 7 additions & 7 deletions DotnetViewComponents/ViewModels/ButtonViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ public class ButtonViewModel
/// <param name="preventDoubleClick">Indicates whether to prevent double-clicking the button. Defaults to <c>false</c>.</param>
public ButtonViewModel(
string text,
string aspController,
string aspAction,
Dictionary<string, string> aspRouteData,
string? aspController,
string? aspAction,
Dictionary<string, string>? aspRouteData,
string styling,
string style,
bool preventDoubleClick)
Expand All @@ -39,17 +39,17 @@ public ButtonViewModel(
/// <summary>
/// Gets or sets the asp-controller of the link.
/// </summary>
public string AspController { get; set; }
public string? AspController { get; set; }

/// <summary>
/// Gets or sets the as-action of the link.
/// Gets or sets the asp-action of the link.
/// </summary>
public string AspAction { get; set; }
public string? AspAction { get; set; }

/// <summary>
/// Gets or sets the asp-all-route-data of the link.
/// </summary>
public Dictionary<string, string> AspRouteData { get; set; }
public Dictionary<string, string>? AspRouteData { get; set; }

/// <summary>
/// Gets or sets the styling for the button.
Expand Down
36 changes: 26 additions & 10 deletions DotnetViewComponents/ViewModels/CardViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,29 @@ public class CardViewModel
/// <param name="headingLevel">The HTML heading level for the title. Defaults to <c>2</c>, which results in h2.</param>
/// <param name="hasArrow">Indicates whether the card should display an arrow. Defaults to <c>false</c>.</param>
/// <param name="isSecondary">Indicates whether the card is styled as a secondary card. Defaults to <c>false</c>.</param>
/// <param name="isClickable">Indicates whether the card is clickable. Defaults to <c>true</c>.</param>
/// <param name="aspController">The asp-controller to dynamically set the controller path of the link.</param>
/// <param name="aspAction">The asp-action to dynamically set the action path of the link..</param>
/// <param name="aspRouteData">The asp-all-route-data to dynamically set the extra parameters to the path of the link.</param>
public CardViewModel(
string title,
string? description = null,
string? imageSrc = null,
int headingLevel = 2,
bool hasArrow = false,
bool isSecondary = false,
bool isClickable = true)
string? description,
string? imageSrc,
int headingLevel,
bool hasArrow,
bool isSecondary,
string? aspController,
string? aspAction,
Dictionary<string, string>? aspRouteData)
{
Title = title;
Description = description;
ImageSrc = imageSrc;
HeadingLevel = headingLevel;
HasArrow = hasArrow;
IsSecondary = isSecondary;
IsClickable = isClickable;
AspController = aspController;
AspAction = aspAction;
AspRouteData = aspRouteData;
}

/// <summary>
Expand Down Expand Up @@ -62,8 +68,18 @@ public CardViewModel(
public bool IsSecondary { get; set; }

/// <summary>
/// Gets or sets a value indicating whether the card is clickable.
/// Gets or sets the asp-controller of the link.
/// </summary>
public bool IsClickable { get; set; }
public string? AspController { get; set; }

/// <summary>
/// Gets or sets the asp-action of the link.
/// </summary>
public string? AspAction { get; set; }

/// <summary>
/// Gets or sets the asp-all-route-data of the link.
/// </summary>
public Dictionary<string, string>? AspRouteData { get; set; }
}
}
12 changes: 6 additions & 6 deletions DotnetViewComponents/ViewModels/CharacterCountViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ public class CharacterCountViewModel
public CharacterCountViewModel(
string id,
int maxLength,
int? maxWords = null,
int? threshold = null,
string? label = null,
string hint = "Do not include personal information like your name, date of birth or NHS number.",
string? errorMessage = null,
bool hasError = false)
int? maxWords,
int? threshold,
string? label,
string hint,
string? errorMessage,
bool hasError)
{
Id = id;
MaxLength = maxLength;
Expand Down
Loading