From 67292f5eb9afcb0fccf231ad4f3eaff96764aa35 Mon Sep 17 00:00:00 2001 From: Phil Scott Date: Sun, 10 Apr 2022 13:37:38 -0400 Subject: [PATCH] Adds stroke-width plugin. --- src/MonorailCss/Plugins/Svg/Fill.cs | 38 -------------------- src/MonorailCss/Plugins/Svg/Stroke.cs | 42 ++++++++++++++++++++++ src/MonorailCss/Plugins/Svg/StrokeWidth.cs | 18 ++++++++++ 3 files changed, 60 insertions(+), 38 deletions(-) create mode 100644 src/MonorailCss/Plugins/Svg/Stroke.cs create mode 100644 src/MonorailCss/Plugins/Svg/StrokeWidth.cs diff --git a/src/MonorailCss/Plugins/Svg/Fill.cs b/src/MonorailCss/Plugins/Svg/Fill.cs index 6c115ac..7887123 100644 --- a/src/MonorailCss/Plugins/Svg/Fill.cs +++ b/src/MonorailCss/Plugins/Svg/Fill.cs @@ -25,44 +25,6 @@ public Fill(DesignSystem designSystem) /// protected override CssNamespaceToPropertyMap NamespacePropertyMapList => new() { { Namespace, "fill" } }; - /// - protected override CssSuffixToValueMap Values - { - get => - _flattenedColors.ToImmutableDictionary(k => k.Key, v => v.Value.AsRgb()).AddRange( - new Dictionary - { - { "inherit", "inherit" }, - { "current", "currentColor" }, - { "transparent", "transparent" }, - { "black", "#000" }, - { "white", "#000" }, - }); - } -} - -/// -/// The fill plugin. -/// -public class Stroke : BaseUtilityNamespacePlugin -{ - private const string Namespace = "stroke"; - private readonly DesignSystem _designSystem; - private readonly ImmutableDictionary _flattenedColors; - - /// - /// Initializes a new instance of the class. - /// - /// The design system. - public Stroke(DesignSystem designSystem) - { - _designSystem = designSystem; - _flattenedColors = designSystem.Colors.Flatten(); - } - - /// - protected override CssNamespaceToPropertyMap NamespacePropertyMapList => new() { { Namespace, "stroke" } }; - /// protected override CssSuffixToValueMap Values { diff --git a/src/MonorailCss/Plugins/Svg/Stroke.cs b/src/MonorailCss/Plugins/Svg/Stroke.cs new file mode 100644 index 0000000..e94a27e --- /dev/null +++ b/src/MonorailCss/Plugins/Svg/Stroke.cs @@ -0,0 +1,42 @@ +using System.Collections.Immutable; +using MonorailCss.Css; + +namespace MonorailCss.Plugins.Svg; + +/// +/// The fill plugin. +/// +public class Stroke : BaseUtilityNamespacePlugin +{ + private const string Namespace = "stroke"; + private readonly DesignSystem _designSystem; + private readonly ImmutableDictionary _flattenedColors; + + /// + /// Initializes a new instance of the class. + /// + /// The design system. + public Stroke(DesignSystem designSystem) + { + _designSystem = designSystem; + _flattenedColors = designSystem.Colors.Flatten(); + } + + /// + protected override CssNamespaceToPropertyMap NamespacePropertyMapList => new() { { Namespace, "stroke" } }; + + /// + protected override CssSuffixToValueMap Values + { + get => + _flattenedColors.ToImmutableDictionary(k => k.Key, v => v.Value.AsRgb()).AddRange( + new Dictionary + { + { "inherit", "inherit" }, + { "current", "currentColor" }, + { "transparent", "transparent" }, + { "black", "#000" }, + { "white", "#000" }, + }); + } +} \ No newline at end of file diff --git a/src/MonorailCss/Plugins/Svg/StrokeWidth.cs b/src/MonorailCss/Plugins/Svg/StrokeWidth.cs new file mode 100644 index 0000000..b80da99 --- /dev/null +++ b/src/MonorailCss/Plugins/Svg/StrokeWidth.cs @@ -0,0 +1,18 @@ +using System.Collections.Immutable; + +namespace MonorailCss.Plugins.Svg; + +/// +/// The stroke-width plugin. +/// +public class StrokeWidth : BaseUtilityPlugin +{ + /// + protected override string Property => "stroke-width"; + + /// + protected override ImmutableDictionary Utilities => new Dictionary() + { + { "stroke-0", "0" }, { "stroke-1", "1" }, { "stroke-2", "2" }, + }.ToImmutableDictionary(); +} \ No newline at end of file