Skip to content

Commit

Permalink
feat(docs): add the Customize Theme page (#116)
Browse files Browse the repository at this point in the history
  • Loading branch information
desmondinho authored Dec 3, 2024
1 parent ccc3573 commit be127f9
Show file tree
Hide file tree
Showing 9 changed files with 203 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class NavigationStore
.Add( new( "Theme" ) )
.Add( new( "Layout" ) )
.Add( new( "Colors" ) )
.Add( new( "Customize Theme", NavItemStatus.Soon ) );
.Add( new( "Customize Theme" ) );

private static NavigationCategory ComponentsCategory =>
new NavigationCategory( "Components", Icons.Rounded.Joystick )
Expand Down
15 changes: 2 additions & 13 deletions docs/LumexUI.Docs.Client/Pages/Customization/Colors.razor
Original file line number Diff line number Diff line change
Expand Up @@ -60,16 +60,6 @@
</DocsSection>
</DocsSection>

<DocsSection Title="Customization">
<Callout Variant="@CalloutVariant.Info">
For detailed color customization examples, visit the
<LumexLink Href="/docs/customization/customizing-theme#customizing-colors"
Class="bordered-link">
Customizing Theme
</LumexLink> page.
</Callout>
</DocsSection>

@code {
[CascadingParameter] private DocsContentLayout Layout { get; set; } = default!;

Expand All @@ -78,16 +68,15 @@
new("Overview", [
new("Common Colors"),
new("Semantic Colors"),
]),
new("Customization")
])
};

protected override void OnInitialized()
{
Layout.Initialize(
title: "Colors",
category: "Customization",
description: "Color customization allows you you define and adjust your components' visual palette for a consistent, cohesive design.",
description: "Color system simplifies managing and customizing the application's color palette.",
_headings
);
}
Expand Down
134 changes: 134 additions & 0 deletions docs/LumexUI.Docs.Client/Pages/Customization/CustomizeTheme.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
@page "/docs/customization/customize-theme"
@layout DocsContentLayout

<DocsSection Title="Overview">
<p>
In LumexUI, the theme system provides flexibility
with two sub-themes: <Code>Light</Code> and <Code>Dark</Code>.
Both sub-themes share the same structure, allowing you to
seamlessly customize your application’s appearance.
</p>
<p>Each sub-theme consists of 2 key configurations:</p>
<ul>
<li><LumexLink Href="/docs/customization/layout">Layout Configuration</LumexLink></li>
<li><LumexLink Href="/docs/customization/colors">Colors Configuration</LumexLink></li>
</ul>
</DocsSection>

<DocsSection Title="Customizing Layout">
<p>
The layout configuration allows you to control typography,
border radius, shadows, and opacities for various states
like hover, focus, and disabled.
</p>
<p>
Suppose you require a smaller border radius,
and more opaque disabled elements across all themes.
You can achieve this by overriding the default <Code>LayoutConfig</Code>.
</p>
<CodeSnippet Code="@(new CodeBlock(name: "MyTheme.cs", snippet: "customizeThemeLayout"))" />
<p>
As LumexUI components employ <Code>LayoutConfig</Code> properties, the modifications
will be reflected across all components that utilize them.
</p>
<p>
For instance, the <LumexLink Href="/docs/components/button#radius">Button</LumexLink>
component exposes the <Code>Radius</Code> parameter to set the border radius and
the <Code>Disabled</Code> parameter to set the
appropriate opacity and disable interactions when it is disabled.
</p>
<Preview>
<div class="w-full flex flex-col items-center justify-around sm:flex-row">
<div class="flex flex-col items-center">
<span class="font-medium text-sm text-foreground-500 font-mono mb-3">Border Radius</span>
<div class="flex flex-col gap-4">
<LumexButton Radius="@Radius.Medium">Default</LumexButton>
<LumexButton Class="rounded-[4px]">Custom</LumexButton>
</div>
</div>
<div class="flex flex-col items-center">
<span class="font-medium text-sm text-foreground-500 font-mono mb-3">Disabled Opacity</span>
<div class="flex flex-col gap-4">
<LumexButton Radius="@Radius.Medium" Disabled="@true">Default</LumexButton>
<LumexButton Disabled="@true" Class="rounded-[4px] opacity-[0.4]">Custom</LumexButton>
</div>
</div>
</div>
</Preview>
<CodeSnippet Code="@(new CodeBlock(name: null, snippet: "customizeThemeLayoutExample"))" />
<Callout Variant="@CalloutVariant.Info">
See the <LumexLink Href="/docs/customization/layout" Class="bordered-link">Layout</LumexLink>
section for more details about the configuration properties.
</Callout>
</DocsSection>

<DocsSection Title="Customizing Colors">
<p>
The colors configuration allows you to control
<LumexLink Href="/docs/customization/colors#semantic-colors">semantic colors</LumexLink>.
</p>
<p>
Now, let's say you wish to modify the primary and focus colors of the light theme.
You can achieve this by overriding the default <Code>ThemeColors</Code>.
</p>
<CodeSnippet Code="@(new CodeBlock(name: "MyTheme.cs", snippet: "customizeThemeColors"))" />
<p>
Just like with the layout, the modifications
will be reflected across all components that utilize them.
</p>
<p>
For instance, the <LumexLink Href="/docs/components/button#colors">Button</LumexLink>
component exposes the <Code>Color</Code> parameter
to set the background color when its variant is set to <Code>Solid</Code>.
</p>
<Preview>
<div class="w-full flex flex-col items-center justify-around sm:flex-row">
<div class="flex flex-col items-center">
<span class="font-medium text-sm text-foreground-500 font-mono mb-3">Primary</span>
<div class="flex flex-col gap-4">
<LumexButton Color="@ThemeColor.Primary">Default</LumexButton>
<LumexButton Class="bg-[#f97316] focus-visible:outline-[#f97316]">Custom</LumexButton>
</div>
</div>
<div class="flex flex-col items-center">
<span class="font-medium text-sm text-foreground-500 font-mono mb-3">Focus</span>
<div class="flex flex-col gap-4">
<LumexButton Color="@ThemeColor.Primary"
Variant="@Variant.Outlined">
Default
</LumexButton>
<LumexButton Variant="@Variant.Outlined"
Class="text-[#f97316] border-[#f97316] focus-visible:outline-[#f97316]">
Custom
</LumexButton>
</div>
</div>
</div>
</Preview>
<CodeSnippet Code="@(new CodeBlock(name: null, snippet: "customizeThemeColorsExample"))" />
<Callout Variant="@CalloutVariant.Info">
See the <LumexLink Href="/docs/customization/colors" Class="bordered-link">Colors</LumexLink>
section for more details about the configuration properties.
</Callout>
</DocsSection>

@code {
[CascadingParameter] private DocsContentLayout Layout { get; set; } = default!;

private readonly Heading[] _headings = new Heading[]
{
new("Overview"),
new("Customizing Layout"),
new("Customizing Colors")
};

protected override void OnInitialized()
{
Layout.Initialize(
title: "Customize Theme",
category: "Customization",
description: "Customizing the default theme for your application.",
_headings
);
}
}
13 changes: 1 addition & 12 deletions docs/LumexUI.Docs.Client/Pages/Customization/LayoutConfig.razor
Original file line number Diff line number Diff line change
Expand Up @@ -164,16 +164,6 @@
</DocsSection>
</DocsSection>

<DocsSection Title="Customization">
<Callout Variant="@CalloutVariant.Info">
For detailed layout customization examples, visit the
<LumexLink Href="/docs/customization/customizing-theme#customizing-layout"
Class="bordered-link">
Customizing Theme
</LumexLink> page.
</Callout>
</DocsSection>

<DocsSection Title="Types">
<DocsSection Title="BaseScale">
<CodeSnippet Code="@(new CodeBlock(name: null, snippet: "layoutTypesBaseScale"))" />
Expand Down Expand Up @@ -201,7 +191,6 @@
new("Opacity"),
new("Full"),
]),
new("Customization"),
new("Types", [
new("BaseScale"),
new("FontScale")
Expand All @@ -213,7 +202,7 @@
Layout.Initialize(
title: "Layout",
category: "Customization",
description: "Layout customization defines important aspects of the UI, including typography, shadows, and opacities for component states.",
description: "Layout configuration simplifies managing and customizing key interface aspects like typography, shadows and more.",
_headings
);
}
Expand Down
2 changes: 1 addition & 1 deletion docs/LumexUI.Docs.Client/Pages/Customization/Theme.razor
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@
Layout.Initialize(
title: "Theme",
category: "Customization",
description: "Theming allows you to customize the feel and look of components by defining global styles, colors, and design elements to align with your app's brand or preferences.",
description: "Theming allows customizing the components' look and feel with global styles.",
_headings
);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<pre><code class="language-csharp">record MyTheme : LumexTheme
{
public MyTheme()
{
Light = new ThemeConfigLight()
{
Colors = new ThemeColorsLight()
{
Primary = new ColorScale( Colors.Orange ),
Focus = new ColorScale( Colors.Orange[&quot;500&quot;] ) // #f97316
}
};
}
}
</code></pre>
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<pre><code class="language-razor">&lt;div class=&quot;flex flex-col gap-4&quot;&gt;
&lt;LumexButton Color=&quot;@ThemeColor.Primary&quot;&gt;
Custom
&lt;/LumexButton&gt;

&lt;LumexButton Color=&quot;@ThemeColor.Primary&quot;
Variant=&quot;@Variant.Outlined&quot;&gt;
Custom
&lt;/LumexButton&gt;
&lt;/div&gt;
</code></pre>
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<pre><code class="language-csharp">record MyTheme : LumexTheme
{
public MyTheme()
{
var layoutConfig = new LayoutConfig()
{
DisabledOpacity = 0.4,
Radius = new BaseScale()
{
Sm = &quot;0.125rem&quot;,
Md = &quot;0.25rem&quot;,
Lg = &quot;0.375rem&quot;
}
};

Light = new ThemeConfigLight
{
Layout = layoutConfig
};

Dark = new ThemeConfigDark
{
Layout = layoutConfig
};
}
}
</code></pre>
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<pre><code class="language-razor">&lt;div class=&quot;flex flex-col gap-4&quot;&gt;
&lt;LumexButton Radius=&quot;@Radius.Medium&quot;&gt;
Custom
&lt;/LumexButton&gt;

&lt;LumexButton Radius=&quot;@Radius.Medium&quot;
Disabled=&quot;@true&quot;&gt;
Custom
&lt;/LumexButton&gt;
&lt;/div&gt;
</code></pre>

0 comments on commit be127f9

Please sign in to comment.