Skip to content

Commit 7e54ea4

Browse files
authored
Feat: Task Listitem Inapplicable State (#131)
* Feat: Add inapplicable state handling for list items and refine CSS utility classes * Extend Markdown tests to include task lists with inapplicable state validation.
1 parent 9706227 commit 7e54ea4

6 files changed

Lines changed: 160 additions & 165 deletions

File tree

src/InfiniLore.InfiniBlazor.Core.Components/InfiniCheckBox/InfiniCheckbox.razor

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,24 @@
1616
type="checkbox"
1717
class="sr-only"
1818
checked="@IsChecked"
19-
disabled="@IsDisabled"
19+
disabled="@(IsDisabled || IsInapplicable)"
2020
@onfocus="@OnFocusAsync"
2121
@onblur="@OnBlurAsync"
22-
tabindex="@(IsDisabled ? -1 : 0)"
22+
tabindex="@(IsDisabled || IsInapplicable ? -1 : 0)"
2323
@onkeydown="@OnKeyDownAsync"
2424
/>
2525
<!-- Custom checkbox appearance -->
26-
<div
27-
class="@ConcatClasses(BackgroundClasses,ContainerBorderClasses, FocusClasses, Size.ToTailwindRounded()) border-2 p-0.5"
26+
<div
27+
class="@ConcatClasses(BackgroundClasses, ContainerBorderClasses, FocusClasses, Size.ToTailwindRounded()) border-2 p-0.5"
2828
@onclick="@OnToggleAsync">
29-
@if (IsChecked) {
29+
@if (IsInapplicable) {
30+
<LiMinus Size="@Size.ToLucideIconSize()" Class="@WhenDisabled("text-(--color-base-50)", "text-(--color-base-20)")"/>
31+
}
32+
else if (IsChecked) {
3033
<LiCheck Size="@Size.ToLucideIconSize()" Class="@WhenDisabled("text-(--color-base-10)", "text-(--color-base-20)")"/>
3134
}
3235
else {
33-
<LiSlash Size="@Size.ToLucideIconSize()" Class="@WhenDisabled("text-(--color-base-50) p-1", "text-(--color-base-70) p-1")"/>
36+
<LiSlash Size="@Size.ToLucideIconSize()" Class="@WhenDisabled("text-(--color-base-50) p-1", "text-(--color-base-70) p-1")"/>
3437
}
3538
</div>
3639
@ChildContent
@@ -42,7 +45,8 @@
4245
@code {
4346
[Parameter] public bool IsChecked { get; set; }
4447
[Parameter] public EventCallback<bool> IsCheckedChanged { get; set; }
45-
48+
[Parameter] public bool IsInapplicable { get; set; }
49+
4650
[Parameter] public Size Size { get; set; } = Size.M;
4751
private bool _isFocused;
4852

src/InfiniLore.InfiniBlazor.Core.Markdown.Components/MdBlazorComponents/MdInfiniListItem.razor

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,21 @@
1717
<li class="my-2 [&:has(>[data-checkbox])]:list-none [&>ul]:mt-2 [&>ol]:mt-2">
1818
@if (SyntaxNode.IsCheckable) {
1919
<InfiniCheckbox
20+
IsInapplicable="@SyntaxNode.IsInapplicable"
2021
Size="Size.S"
2122
Class="-ml-6 mr-2 align-bottom"
2223
IsChecked="@SyntaxNode.IsChecked"
2324
IsCheckedChanged="@OnCheckChanged"/>
2425
}
25-
@ComponentConverter.RenderChildComponents(SyntaxNode)
26+
@if (SyntaxNode.IsInapplicable) {
27+
<CascadingIsDisabled>
28+
<span class="text-(--color-base-20) line-through">@ComponentConverter.RenderChildComponents(SyntaxNode)</span>
29+
</CascadingIsDisabled>
30+
}
31+
else {
32+
@ComponentConverter.RenderChildComponents(SyntaxNode)
33+
}
34+
2635
</li>
2736
@* ------------------------------------------------------------------------------------------------------------------ *@
2837
@* Code

src/InfiniLore.InfiniBlazor.Core.Markdown/Parsers/MarkdownString/Serializer/RegexLib/MdRegexLib.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,13 @@ public static partial class MdRegexLib {
7676
(?<htmlPost>.+)?
7777
)
7878
| (?<horizontalRule>^(?<hr>\ *?(\-{3,}?|_{3,}?)\ *?)$)
79-
| (?<paragraph>(?<p>.+?)$)
79+
| (?<paragraph>^(?<p>.+?)$)
8080
| (?<newLine>\n)
8181
8282
""", RegexOptions.IgnorePatternWhitespace | RegexOptions.Multiline | RegexOptions.ExplicitCapture | RegexOptions.Compiled)]
8383
public static partial Regex MultilineStructuresRegex { get; }
8484

85-
[GeneratedRegex(@"^ *(?:-|(?<lIndex>\d*)\.)(?:(?<lTaskSpace> *)\[(?<lTask>[ xX])])?(?:(?<lSpace> *)(?<lHead>.+)|(?<lHead> )|(?<lHead>))(?<lBody>(?:\n +.*)*)", RegexOptions.Multiline | RegexOptions.ExplicitCapture | RegexOptions.Compiled)]
85+
[GeneratedRegex(@"^ *(?:-|(?<lIndex>\d*)\.)(?:(?<lTaskSpace> *)\[(?<lTask>[ xX~])])?(?:(?<lSpace> *)(?<lHead>.+)|(?<lHead> )|(?<lHead>))(?<lBody>(?:\n +.*)*)", RegexOptions.Multiline | RegexOptions.ExplicitCapture | RegexOptions.Compiled)]
8686
public static partial Regex ListItemBodyRegex { get; }
8787

8888
[GeneratedRegex("""

src/InfiniLore.InfiniBlazor.Core.Markdown/Syntax/Nodes/ListItemMdSyntaxNode.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ namespace InfiniLore.InfiniBlazor.Markdown.Syntax.Nodes;
88
// ---------------------------------------------------------------------------------------------------------------------
99
public sealed class ListItemMdSyntaxNode : MdSyntaxNode<ListItemMdSyntaxNode> {
1010
public bool IsCheckable => OriginalCheckMarker.IsNotNullOrEmpty();
11+
public bool IsInapplicable => OriginalCheckMarker.ElementAtOrDefault(0) == '~';
1112
public bool IsChecked => OriginalCheckMarker.ToLowerInvariant().ElementAtOrDefault(0) == 'x';
1213
public string Index { get; private set; } = string.Empty;
1314
public string OriginalCheckMarker { get; private set; } = string.Empty;

0 commit comments

Comments
 (0)