< Summary

Information
Class: Allyaria.Theming.StyleTypes.StyleOverflow
Assembly: Allyaria.Theming
File(s): /home/runner/work/allyaria/allyaria/src/Allyaria.Theming/StyleTypes/StyleOverflow.cs
Line coverage
100%
Covered lines: 12
Uncovered lines: 0
Coverable lines: 12
Total lines: 102
Line coverage: 100%
Branch coverage
100%
Covered branches: 4
Total branches: 4
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%11100%
Parse(...)100%22100%
TryParse(...)100%11100%
op_Implicit(...)100%11100%
op_Implicit(...)100%22100%

File(s)

/home/runner/work/allyaria/allyaria/src/Allyaria.Theming/StyleTypes/StyleOverflow.cs

#LineLine coverage
 1namespace Allyaria.Theming.StyleTypes;
 2
 3/// <summary>
 4/// Represents a CSS <c>overflow</c>, <c>overflow-x</c>, or <c>overflow-y</c> value within the Allyaria theming system.
 5/// Provides a strongly typed wrapper around standard overflow behaviors controlling how content exceeding its container
 6/// handled.
 7/// </summary>
 8public sealed record StyleOverflow : StyleValueBase
 9{
 10    /// <summary>
 11    /// Initializes a new instance of the <see cref="StyleOverflow" /> record using the specified overflow <see cref="Ki
 12    /// value.
 13    /// </summary>
 14    /// <param name="kind">The overflow behavior to represent.</param>
 15    public StyleOverflow(Kind kind)
 6816        : base(value: kind.GetDescription()) { }
 17
 18    /// <summary>Defines the supported CSS <c>overflow</c> property values.</summary>
 19    public enum Kind
 20    {
 21        /// <summary>
 22        /// Displays scrollbars when content overflows the element’s box. The user agent determines whether to clip or s
 23        /// scrollbars automatically.
 24        /// </summary>
 25        [Description(description: "auto")]
 26        Auto,
 27
 28        /// <summary>
 29        /// Clips the overflowing content without adding scrollbars. Hidden content cannot be scrolled or accessed visua
 30        /// </summary>
 31        [Description(description: "clip")]
 32        Clip,
 33
 34        /// <summary>
 35        /// Clips the content and hides the overflowed portion, similar to <c>clip</c>, but scrollbars may still be rend
 36        /// some browsers for backward compatibility.
 37        /// </summary>
 38        [Description(description: "hidden")]
 39        Hidden,
 40
 41        /// <summary>Always shows scrollbars, allowing users to scroll overflowing content.</summary>
 42        [Description(description: "scroll")]
 43        Scroll,
 44
 45        /// <summary>Content is not clipped and may overflow the element’s box visibly.</summary>
 46        [Description(description: "visible")]
 47        Visible
 48    }
 49
 50    /// <summary>
 51    /// Parses a string representation of a CSS <c>overflow</c> value into a <see cref="StyleOverflow" /> instance.
 52    /// </summary>
 53    /// <param name="value">The string representation of the overflow value.</param>
 54    /// <returns>A new <see cref="StyleOverflow" /> instance representing the parsed value.</returns>
 55    /// <exception cref="AryArgumentException">
 56    /// Thrown when the provided <paramref name="value" /> does not correspond to a valid <see cref="Kind" />.
 57    /// </exception>
 58    public static StyleOverflow Parse(string? value)
 1259        => value.TryParseEnum<Kind>(result: out var kind)
 1260            ? new StyleOverflow(kind: kind)
 1261            : throw new AryArgumentException(message: $"Invalid style: {value}", argName: nameof(value));
 62
 63    /// <summary>Attempts to parse a string into a <see cref="StyleOverflow" /> instance.</summary>
 64    /// <param name="value">The string representation of the overflow value to parse.</param>
 65    /// <param name="result">
 66    /// When this method returns, contains the parsed <see cref="StyleOverflow" /> instance or <see langword="null" /> i
 67    /// parsing failed.
 68    /// </param>
 69    /// <returns><see langword="true" /> if parsing succeeded; otherwise, <see langword="false" />.</returns>
 70    public static bool TryParse(string? value, out StyleOverflow? result)
 71    {
 72        try
 73        {
 374            result = Parse(value: value);
 75
 176            return true;
 77        }
 278        catch
 79        {
 280            result = null;
 81
 282            return false;
 83        }
 384    }
 85
 86    /// <summary>Implicitly converts a string into a <see cref="StyleOverflow" /> instance.</summary>
 87    /// <param name="value">The string representation of the overflow value.</param>
 88    /// <returns>A <see cref="StyleOverflow" /> instance representing the provided value.</returns>
 89    /// <exception cref="AryArgumentException">
 90    /// Thrown when the provided string cannot be parsed into a valid
 91    /// <see cref="Kind" />.
 92    /// </exception>
 293    public static implicit operator StyleOverflow(string? value) => Parse(value: value);
 94
 95    /// <summary>Implicitly converts a <see cref="StyleOverflow" /> instance to its string representation.</summary>
 96    /// <param name="value">The <see cref="StyleOverflow" /> instance to convert.</param>
 97    /// <returns>
 98    /// The underlying CSS <c>overflow</c> string value, or an empty string if <paramref name="value" /> is
 99    /// <see langword="null" />.
 100    /// </returns>
 2101    public static implicit operator string(StyleOverflow? value) => (value?.Value).OrDefaultIfEmpty();
 102}