Skip to content

Commit 259e265

Browse files
authored
docs: add dark mode support + theme toggle (#235)
* docs: add dark mode support * docs: add missing border for the preview component * docs: remove extra border in the preview code component * chore(badge): improve flat variant contrast in light theme * chore(tabs): remove `EditorRequired` attribute from `Id` param * docs: add null check and theme class cleanup to prevent issues * docs: remove IPopoverService injection from theme toggle component
1 parent 7d4bfd8 commit 259e265

File tree

99 files changed

+518
-363
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

99 files changed

+518
-363
lines changed

docs/LumexUI.Docs.Client/Components/Callout.razor

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
{
4343
CalloutVariant.Info => typeof( InfoIcon ),
4444
CalloutVariant.Warning => typeof( ShieldAlertIcon ),
45-
CalloutVariant.Danger => typeof( OctagonAlertIcon ),
45+
CalloutVariant.Danger => typeof( OctagonAlertFilledIcon ),
4646
CalloutVariant.Success => typeof( CircleCheckIcon ),
4747
CalloutVariant.Tip => typeof( InfoIcon ),
4848
_ => throw new NotImplementedException()
Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,30 @@
11
@namespace LumexUI.Docs.Client.Components
22
@rendermode InteractiveWebAssembly
33

4-
<div class="relative my-6 first:mt-0 last:mb-0 rounded-large overflow-hidden" @ref="@_ref">
5-
<div class="prose prose-zinc bg-zinc-800">
6-
@if( !string.IsNullOrEmpty( Code.Name ) )
7-
{
8-
<div class="flex items-center px-3 py-2 text-xs leading-6 border-b border-zinc-600/50">
9-
<div class="flex items-center px-2 py-0.5 text-orange-400 bg-zinc-700/40 rounded-lg">
4+
<div class="group relative my-6 first:mt-0 last:mb-0"
5+
data-expanded="@(Expandable ? _isExpanded.ToAttributeValue() : null)">
6+
<div class="rounded-large overflow-hidden group-data-[expanded=false]:max-h-72">
7+
<div class="prose prose-zinc dark:prose-invert">
8+
@if( !string.IsNullOrEmpty( Code.Name ) )
9+
{
10+
<div class="flex items-center px-4 py-2.5 gap-2 border-b border-zinc-700 text-small text-foreground-400 bg-zinc-800 dark:text-foreground-500 dark:bg-zinc-900">
11+
<CodeXmlIcon Size="16" />
1012
@Code.Name
1113
</div>
14+
}
15+
16+
<div id="@Id" class="*:my-0" @ref="@_ref">
17+
@_renderCodeSnippet
1218
</div>
13-
}
14-
<div id="@Id" class="*:my-0">
15-
@_renderCodeSnippet
1619
</div>
1720
</div>
21+
22+
@if( Expandable )
23+
{
24+
<button type="button"
25+
class="absolute inset-x-0 bottom-0 flex h-20 items-center justify-center rounded-b-large bg-linear-to-b from-default-800/70 to-default-800 text-foreground-200 text-small group-data-[expanded=true]:hidden dark:from-default-50/70 dark:to-default-50 dark:text-foreground-700"
26+
@onclick="@(() => _isExpanded = true)">
27+
Expand
28+
</button>
29+
}
1830
</div>

docs/LumexUI.Docs.Client/Components/CodeSnippet.razor.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,16 @@ namespace LumexUI.Docs.Client.Components;
99
public partial class CodeSnippet
1010
{
1111
[Parameter] public string? Id { get; set; }
12+
[Parameter] public bool Expandable { get; set; }
1213
[Parameter, EditorRequired] public CodeBlock Code { get; set; } = default!;
1314

1415
[Inject] private IJSRuntime JSRuntime { get; set; } = default!;
1516

1617
private readonly RenderFragment _renderCodeSnippet;
1718
private ElementReference _ref;
19+
private bool _isExpanded;
1820

19-
public CodeSnippet()
21+
public CodeSnippet()
2022
{
2123
_renderCodeSnippet = RenderCodeSnippet;
2224
}

docs/LumexUI.Docs.Client/Components/CodeSnippetCollapsible.razor

Lines changed: 0 additions & 17 deletions
This file was deleted.

docs/LumexUI.Docs.Client/Components/CodeSnippetCollapsible.razor.cs

Lines changed: 0 additions & 15 deletions
This file was deleted.

docs/LumexUI.Docs.Client/Components/DocsApiSection.razor

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,21 @@
1212
var componentPathSegment = component.Replace( "Lumex", "" ).SplitPascalCase().ToKebabCase();
1313

1414
<li>
15-
<LumexLink Href="@($"{NavigationManager.BaseUri}docs/api/{componentPathSegment}")"
16-
Class="border-none text-orange-500 text-xs font-normal not-prose">
17-
<span class="px-1 py-0.5 rounded-md ring ring-orange-200 bg-orange-50">
15+
<LumexChip Size="@Size.Small"
16+
Radius="@Radius.Small"
17+
Variant="@ChipVariant.Flat"
18+
Class="not-prose bg-default-50 ring ring-default-900/10">
19+
<LumexLink Href="@($"{NavigationManager.BaseUri}docs/api/{componentPathSegment}")"
20+
Class="font-mono text-orange-600 dark:text-orange-400">
1821
@($"<{component} />")
19-
</span>
20-
</LumexLink>
22+
</LumexLink>
23+
</LumexChip>
2124
</li>
2225
}
26+
27+
@* <span class="px-1 py-0.5 rounded-md ring ring-orange-200 bg-default-50">
28+
@($"<{component} />")
29+
</span> *@
2330
</ul>
2431
</DocsSection>
2532

docs/LumexUI.Docs.Client/Components/DocsCompositionSection.razor

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
@foreach( var component in Components )
99
{
1010
<li>
11-
<strong class="text-orange-500">@component.Name</strong>: @component.Description
11+
<strong class="text-orange-500 dark:text-orange-400">@component.Name</strong>: @component.Description
1212
</li>
1313
}
1414
</ul>

docs/LumexUI.Docs.Client/Components/DocsSection.razor

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,9 @@
77
<LumexComponent As="@(IsSubsection ? "h3" : "h2")"
88
id="@_id">
99
<LumexLink Href="@($"{RelativePath}#{_id}")"
10-
Color="@ThemeColor.None"
11-
Class="border-none">
10+
Color="@ThemeColor.None">
1211
@Title
13-
<span class="flex items-center justify-center size-6 ml-2 rounded-md text-foreground-400 shadow-xs ring ring-foreground-900/10 hover:ring-orange-200 hover:bg-orange-50 hover:text-orange-500">
12+
<span class="flex items-center justify-center size-6 ml-2 rounded-md text-foreground-400 shadow-xs ring ring-default-900/10 hover:ring-orange-300 hover:bg-orange-400/10 hover:text-orange-500 dark:text-foreground-500 dark:hover:ring-orange-300/60 dark:hover:text-orange-200">
1413
<Link2Icon Size="16" />
1514
</span>
1615
</LumexLink>

docs/LumexUI.Docs.Client/Components/DocsSlotsSection.razor

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
@foreach( var slot in Slots )
1010
{
1111
<li>
12-
<strong class="text-orange-500">@slot.Name:</strong> @slot.Description
12+
<strong class="text-orange-500 dark:text-orange-400">@slot.Name:</strong> @slot.Description
1313
</li>
1414
}
1515
</ul>

docs/LumexUI.Docs.Client/Components/Header.razor

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<LumexNavbar Sticky="@true"
55
Bordered="@true"
66
MaxWidth="@MaxWidth.XLarge"
7-
Classes="@_navbarClasses">
7+
Classes="@(new() { Wrapper = "gap-6" })">
88
<LumexNavbarBrand>
99
<LumexLink Href="/"
1010
Class="font-bold text-xl text-foreground-900">
@@ -18,13 +18,13 @@
1818
<LumexNavbarItem>
1919
<LumexLink Href="@item.Link"
2020
Color="@ThemeColor.None"
21-
Class="hover:text-orange-500 data-[active=true]:text-orange-500">
21+
Class="data-[active=true]:text-orange-500 dark:text-foreground-700 dark:data-[active=true]:text-orange-400">
2222
@item.Name
2323
</LumexLink>
2424
</LumexNavbarItem>
2525
}
2626

27-
<LumexNavbarItem Class="h-full">
27+
<LumexNavbarItem Class="h-6">
2828
<LumexDivider Orientation="@Orientation.Vertical" />
2929
</LumexNavbarItem>
3030
@_headerActions
@@ -41,22 +41,20 @@
4141
</LumexNavbar>
4242

4343
@code {
44-
private static RenderFragment _headerActions =
44+
private readonly RenderFragment _headerActions =
4545
@<text>
4646
<LumexNavbarItem Class="flex">
4747
<LumexLink Href="https://github.com/LumexUI/lumexui"
4848
External="@true"
49-
Class="text-foreground-400 hover:text-foreground-600">
49+
Class="text-foreground-500 hover:text-foreground-600 hover:opacity-100">
5050
<GithubIcon Size="20" />
5151
</LumexLink>
5252
</LumexNavbarItem>
53+
<LumexNavbarItem Class="flex">
54+
<ThemeToggle />
55+
</LumexNavbarItem>
5356
</text>;
5457

55-
private readonly NavbarSlots _navbarClasses = new()
56-
{
57-
Wrapper = "py-5 gap-6"
58-
};
59-
6058
private readonly NavItem[] _navItems = new NavItem[]
6159
{
6260
new("/", "Docs"),

0 commit comments

Comments
 (0)