Skip to content

Commit

Permalink
feat (Component Meta Data): adds Section and non-section for backward…
Browse files Browse the repository at this point in the history
…s comp
  • Loading branch information
jamiepollock committed Jan 16, 2024
1 parent 9ccabae commit 603886f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
11 changes: 10 additions & 1 deletion src/Rhythm.Drop.Models/Components/ComponentMetaData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
/// <param name="Total">The total number of components within the current collection of components.</param>
/// <param name="Theme">The theme of the component.</param>
/// <param name="Attributes">The additional HTML attributes.</param>
/// <param name="Section">The optional section of where this component is rendered.</param>
/// <remarks>
/// <para>
/// This type exists to make it easier to construct and return a generic Component Meta Data.
Expand All @@ -18,8 +19,16 @@
/// It should not be used to create other types.
/// </para>
/// </remarks>
public abstract record ComponentMetaData(int Level, int Index, int Total, string Theme, IReadOnlyHtmlAttributeCollection Attributes)
public abstract record ComponentMetaData(int Level, int Index, int Total, string Theme, IReadOnlyHtmlAttributeCollection Attributes, string? Section)
{
/// <summary>
/// An abstract non-generic type for Component Meta Data.
/// </summary>
/// <remarks>This creates a component meta data without a section for backward compatability.</remarks>
public ComponentMetaData(int Level, int Index, int Total, string Theme, IReadOnlyHtmlAttributeCollection Attributes) : this(Level, Index, Total, Theme, Attributes, default)
{
}

/// <summary>
/// The absolute lowest level a component can be.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@
/// <param name="Total">The total number of components within the current collection of components.</param>
/// <param name="Theme">The theme of the component.</param>
/// <param name="Attributes">The attributes to be passed to the component.</param>
public sealed record ComponentMetaData<TComponent>(TComponent Component, int Level, int Index, int Total, string Theme, IReadOnlyHtmlAttributeCollection Attributes) : ComponentMetaData(Level, Index, Total, Theme, Attributes) where TComponent : IComponent
/// <param name="Section">The optional section of where this component is rendered.</param>
public sealed record ComponentMetaData<TComponent>(TComponent Component, int Level, int Index, int Total, string Theme, IReadOnlyHtmlAttributeCollection Attributes, string? Section) : ComponentMetaData(Level, Index, Total, Theme, Attributes, Section) where TComponent : IComponent
{
/// <summary>
/// A generic type for Component Meta Data
/// </summary>
/// <remarks>This creates a component meta data without a section for backward compatability.</remarks>
public ComponentMetaData(TComponent Component, int Level, int Index, int Total, string Theme, IReadOnlyHtmlAttributeCollection Attributes) : this(Component, Level, Index, Total, Theme, Attributes, default)
{
}
}

0 comments on commit 603886f

Please sign in to comment.