diff --git a/README.md b/README.md index 8a3a5c8..dd70279 100644 --- a/README.md +++ b/README.md @@ -202,7 +202,7 @@ using Beck; using Beck.Rendering; // Site-wide default (a document's own meta.style overrides it): -string svg = BeckSvg.Render(yaml, new SvgRenderOptions { Style = BeckStyles.ByName["glow"] }); +string svg = BeckSvg.Render(yaml, new SvgRenderOptions { Style = BeckStyles.Glow }); ``` Precedence runs `meta.style` (YAML) → `SvgRenderOptions.Style` (C# default) → `classic` — the C# diff --git a/src/Beck/BeckStyles.cs b/src/Beck/BeckStyles.cs index 96c570c..9d942c1 100644 --- a/src/Beck/BeckStyles.cs +++ b/src/Beck/BeckStyles.cs @@ -3,8 +3,9 @@ namespace Beck; /// -/// The registry of built-in s, keyed by their YAML meta.style token. -/// Phase 2 ships only ; Phase 3/4 append the designed styles. +/// The registry of built-in s, keyed by their YAML meta.style token, +/// with a static shortcut per style for C# callers (BeckStyles.Glow reads better than +/// BeckStyles.ByName["glow"] and survives a rename). /// /// /// A meta.style token (and a custom style's ) must match @@ -14,8 +15,35 @@ namespace Beck; /// public static class BeckStyles { + /// The classic default style; alias of . + public static BeckStyle Classic => BeckStyle.Classic; + + /// The minimal built-in style (). + public static BeckStyle Minimal => MinimalStyle.Instance; + + /// The terminal built-in style (). + public static BeckStyle Terminal => TerminalStyle.Instance; + + /// The blueprint built-in style (). + public static BeckStyle Blueprint => BlueprintStyle.Instance; + + /// The glow built-in style (). + public static BeckStyle Glow => GlowStyle.Instance; + + /// The brutalist built-in style (). + public static BeckStyle Brutalist => BrutalistStyle.Instance; + + /// The sketch built-in style (). + public static BeckStyle Sketch => SketchStyle.Instance; + + /// The extrude built-in style (). + public static BeckStyle Extrude => ExtrudeStyle.Instance; + + /// The circuit built-in style (). + public static BeckStyle Circuit => CircuitStyle.Instance; + /// All built-in styles, in declaration order. - public static IReadOnlyList All { get; } = [BeckStyle.Classic, MinimalStyle.Instance, TerminalStyle.Instance, BlueprintStyle.Instance, GlowStyle.Instance, BrutalistStyle.Instance, SketchStyle.Instance, ExtrudeStyle.Instance, CircuitStyle.Instance, + public static IReadOnlyList All { get; } = [Classic, Minimal, Terminal, Blueprint, Glow, Brutalist, Sketch, Extrude, Circuit, ]; /// Built-in styles keyed by (ordinal, case-sensitive). diff --git a/src/Beck/README.md b/src/Beck/README.md index 0c012a0..cca0644 100644 --- a/src/Beck/README.md +++ b/src/Beck/README.md @@ -52,7 +52,7 @@ and flips with light and dark. Select one per document with `meta: { style: sket site-wide default from C#: ```csharp -string svg = BeckSvg.Render(yaml, new SvgRenderOptions { Style = BeckStyles.ByName["glow"] }); +string svg = BeckSvg.Render(yaml, new SvgRenderOptions { Style = BeckStyles.Glow }); ``` Precedence runs `meta.style` → `SvgRenderOptions.Style` → `classic`. Every built-in is an instance of diff --git a/src/Beck/SvgRenderOptions.cs b/src/Beck/SvgRenderOptions.cs index eff9ef2..ded553d 100644 --- a/src/Beck/SvgRenderOptions.cs +++ b/src/Beck/SvgRenderOptions.cs @@ -75,8 +75,12 @@ public enum TextLengthGuard Off, } -/// Options controlling a call. -public sealed class SvgRenderOptions +/// +/// Options controlling a call. A record, so +/// a host can derive from a base configuration with a with expression — the properties are +/// init-only. +/// +public sealed record SvgRenderOptions { /// Text measurer; defaults to the embedded Inter metrics table. public ITextMeasurer Measurer { get; init; } = InterMetricsMeasurer.Instance;