Skip to main content

BnAutoLength

Namespace: BlazorNative.Components

A layout length that may also be auto. Composes BnLength so the grammar is implemented once; this type adds only the auto case.

public readonly record struct BnAutoLength

Inheritance Object → ValueType → BnAutoLength
Implements IEquatable<BnAutoLength>
Attributes IsReadOnlyAttribute

Remarks:

Use it as BnAutoLength? on a parameter, never bare, and note that the two nulls mean different things. The OUTER null (the ?) is unset — no attribute, so the shell resets the style. The INNER null (BnAutoLength.Length) is auto. The shells already draw that distinction: resetting a removed margin to auto would move the node rather than restore it, which is why null and auto cannot be the same value.

It follows that default(BnAutoLength) is auto, not unset. That is the reason parameters are nullable and never bare.

Properties​

Length​

The length, or null for auto.

public BnLength? Length { get; init; }

Property Value​

BnLength?

Auto​

Absorb the free space — the auto value.

public static BnAutoLength Auto { get; }

Property Value​

BnAutoLength

Constructors​

BnAutoLength(BnLength?)​

A layout length that may also be auto. Composes BnLength so the grammar is implemented once; this type adds only the auto case.

public BnAutoLength(BnLength? Length)

Parameters​

Length BnLength?
The length, or null for auto.

Remarks:

Use it as BnAutoLength? on a parameter, never bare, and note that the two nulls mean different things. The OUTER null (the ?) is unset — no attribute, so the shell resets the style. The INNER null (BnAutoLength.Length) is auto. The shells already draw that distinction: resetting a removed margin to auto would move the node rather than restore it, which is why null and auto cannot be the same value.

It follows that default(BnAutoLength) is auto, not unset. That is the reason parameters are nullable and never bare.

Methods​

Percent(Single)​

A length as a percentage of the parent's corresponding dimension.

public static BnAutoLength Percent(float value)

Parameters​

value Single
The percentage, without the sign.

Returns​

BnAutoLength
A percentage-valued length.

ToStyleValue()​

The wire form, INVARIANTLY — see BnLength.ToStyleValue().

public string ToStyleValue()

Returns​

String
"auto", a bare number, or a number with a trailing percent sign.

Operators​

implicit operator BnAutoLength(Single)​

A length in points.

public static implicit operator BnAutoLength(float points)

Parameters​

points Single
The magnitude, in density-independent points.

Returns​

BnAutoLength

implicit operator BnAutoLength(Double)​

A length in points, from a double. See BnLength for why this exists.

public static implicit operator BnAutoLength(double points)

Parameters​

points Double
The magnitude, in density-independent points.

Returns​

BnAutoLength

implicit operator BnAutoLength(BnLength)​

Widens a BnLength into the auto-capable type.

public static implicit operator BnAutoLength(BnLength length)

Parameters​

length BnLength
The length to widen.

Returns​

BnAutoLength