Skip to content
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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#
Expand Down
34 changes: 31 additions & 3 deletions src/Beck/BeckStyles.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
namespace Beck;

/// <summary>
/// The registry of built-in <see cref="BeckStyle"/>s, keyed by their YAML <c>meta.style</c> token.
/// Phase 2 ships only <see cref="BeckStyle.Classic"/>; Phase 3/4 append the designed styles.
/// The registry of built-in <see cref="BeckStyle"/>s, keyed by their YAML <c>meta.style</c> token,
/// with a static shortcut per style for C# callers (<c>BeckStyles.Glow</c> reads better than
/// <c>BeckStyles.ByName["glow"]</c> and survives a rename).
/// </summary>
/// <remarks>
/// A <c>meta.style</c> token (and a custom style's <see cref="BeckStyle.Name"/>) must match
Expand All @@ -14,8 +15,35 @@ namespace Beck;
/// </remarks>
public static class BeckStyles
{
/// <summary>The <c>classic</c> default style; alias of <see cref="BeckStyle.Classic"/>.</summary>
public static BeckStyle Classic => BeckStyle.Classic;

/// <summary>The <c>minimal</c> built-in style (<see cref="Styles.MinimalStyle"/>).</summary>
public static BeckStyle Minimal => MinimalStyle.Instance;

/// <summary>The <c>terminal</c> built-in style (<see cref="Styles.TerminalStyle"/>).</summary>
public static BeckStyle Terminal => TerminalStyle.Instance;

/// <summary>The <c>blueprint</c> built-in style (<see cref="Styles.BlueprintStyle"/>).</summary>
public static BeckStyle Blueprint => BlueprintStyle.Instance;

/// <summary>The <c>glow</c> built-in style (<see cref="Styles.GlowStyle"/>).</summary>
public static BeckStyle Glow => GlowStyle.Instance;

/// <summary>The <c>brutalist</c> built-in style (<see cref="Styles.BrutalistStyle"/>).</summary>
public static BeckStyle Brutalist => BrutalistStyle.Instance;

/// <summary>The <c>sketch</c> built-in style (<see cref="Styles.SketchStyle"/>).</summary>
public static BeckStyle Sketch => SketchStyle.Instance;

/// <summary>The <c>extrude</c> built-in style (<see cref="Styles.ExtrudeStyle"/>).</summary>
public static BeckStyle Extrude => ExtrudeStyle.Instance;

/// <summary>The <c>circuit</c> built-in style (<see cref="Styles.CircuitStyle"/>).</summary>
public static BeckStyle Circuit => CircuitStyle.Instance;

/// <summary>All built-in styles, in declaration order.</summary>
public static IReadOnlyList<BeckStyle> All { get; } = [BeckStyle.Classic, MinimalStyle.Instance, TerminalStyle.Instance, BlueprintStyle.Instance, GlowStyle.Instance, BrutalistStyle.Instance, SketchStyle.Instance, ExtrudeStyle.Instance, CircuitStyle.Instance,
public static IReadOnlyList<BeckStyle> All { get; } = [Classic, Minimal, Terminal, Blueprint, Glow, Brutalist, Sketch, Extrude, Circuit,
];

/// <summary>Built-in styles keyed by <see cref="BeckStyle.Name"/> (ordinal, case-sensitive).</summary>
Expand Down
2 changes: 1 addition & 1 deletion src/Beck/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 6 additions & 2 deletions src/Beck/SvgRenderOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,12 @@ public enum TextLengthGuard
Off,
}

/// <summary>Options controlling a <see cref="BeckSvg.Render(string, SvgRenderOptions?)"/> call.</summary>
public sealed class SvgRenderOptions
/// <summary>
/// Options controlling a <see cref="BeckSvg.Render(string, SvgRenderOptions?)"/> call. A record, so
/// a host can derive from a base configuration with a <c>with</c> expression — the properties are
/// init-only.
/// </summary>
public sealed record SvgRenderOptions
{
/// <summary>Text measurer; defaults to the embedded Inter metrics table.</summary>
public ITextMeasurer Measurer { get; init; } = InterMetricsMeasurer.Instance;
Expand Down
Loading