Skip to content

Commit

Permalink
Adds stroke-width plugin.
Browse files Browse the repository at this point in the history
  • Loading branch information
phil-scott-78 committed Apr 10, 2022
1 parent 3ec757e commit 67292f5
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 38 deletions.
38 changes: 0 additions & 38 deletions src/MonorailCss/Plugins/Svg/Fill.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,44 +25,6 @@ public Fill(DesignSystem designSystem)
/// <inheritdoc />
protected override CssNamespaceToPropertyMap NamespacePropertyMapList => new() { { Namespace, "fill" } };

/// <inheritdoc />
protected override CssSuffixToValueMap Values
{
get =>
_flattenedColors.ToImmutableDictionary(k => k.Key, v => v.Value.AsRgb()).AddRange(
new Dictionary<string, string>
{
{ "inherit", "inherit" },
{ "current", "currentColor" },
{ "transparent", "transparent" },
{ "black", "#000" },
{ "white", "#000" },
});
}
}

/// <summary>
/// The fill plugin.
/// </summary>
public class Stroke : BaseUtilityNamespacePlugin
{
private const string Namespace = "stroke";
private readonly DesignSystem _designSystem;
private readonly ImmutableDictionary<string, CssColor> _flattenedColors;

/// <summary>
/// Initializes a new instance of the <see cref="Stroke"/> class.
/// </summary>
/// <param name="designSystem">The design system.</param>
public Stroke(DesignSystem designSystem)
{
_designSystem = designSystem;
_flattenedColors = designSystem.Colors.Flatten();
}

/// <inheritdoc />
protected override CssNamespaceToPropertyMap NamespacePropertyMapList => new() { { Namespace, "stroke" } };

/// <inheritdoc />
protected override CssSuffixToValueMap Values
{
Expand Down
42 changes: 42 additions & 0 deletions src/MonorailCss/Plugins/Svg/Stroke.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
using System.Collections.Immutable;
using MonorailCss.Css;

namespace MonorailCss.Plugins.Svg;

/// <summary>
/// The fill plugin.
/// </summary>
public class Stroke : BaseUtilityNamespacePlugin
{
private const string Namespace = "stroke";
private readonly DesignSystem _designSystem;
private readonly ImmutableDictionary<string, CssColor> _flattenedColors;

/// <summary>
/// Initializes a new instance of the <see cref="Stroke"/> class.
/// </summary>
/// <param name="designSystem">The design system.</param>
public Stroke(DesignSystem designSystem)
{
_designSystem = designSystem;
_flattenedColors = designSystem.Colors.Flatten();
}

/// <inheritdoc />
protected override CssNamespaceToPropertyMap NamespacePropertyMapList => new() { { Namespace, "stroke" } };

/// <inheritdoc />
protected override CssSuffixToValueMap Values
{
get =>
_flattenedColors.ToImmutableDictionary(k => k.Key, v => v.Value.AsRgb()).AddRange(
new Dictionary<string, string>
{
{ "inherit", "inherit" },
{ "current", "currentColor" },
{ "transparent", "transparent" },
{ "black", "#000" },
{ "white", "#000" },
});
}
}
18 changes: 18 additions & 0 deletions src/MonorailCss/Plugins/Svg/StrokeWidth.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using System.Collections.Immutable;

namespace MonorailCss.Plugins.Svg;

/// <summary>
/// The stroke-width plugin.
/// </summary>
public class StrokeWidth : BaseUtilityPlugin
{
/// <inheritdoc />
protected override string Property => "stroke-width";

/// <inheritdoc />
protected override ImmutableDictionary<string, string> Utilities => new Dictionary<string, string>()
{
{ "stroke-0", "0" }, { "stroke-1", "1" }, { "stroke-2", "2" },
}.ToImmutableDictionary();
}

0 comments on commit 67292f5

Please sign in to comment.