Skip to content

Commit 4f12742

Browse files
committed
Came Case Tetsting
1 parent 6df5118 commit 4f12742

File tree

4 files changed

+35
-4
lines changed

4 files changed

+35
-4
lines changed

TextHub/Components/Layout/UINavBar.razor

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,17 @@
6868
{
6969
private bool _isMobileMenuOpen;
7070
private bool _isToolsDropdownOpen;
71-
private bool _isDarkMode = false; // Start with light mode
71+
private bool _isDarkMode = false; // Will be initialized from localStorage
72+
73+
protected override async Task OnAfterRenderAsync(bool firstRender)
74+
{
75+
if (firstRender)
76+
{
77+
// Initialize theme from localStorage or system preference
78+
_isDarkMode = await JsRuntime.InvokeAsync<bool>("getTheme");
79+
StateHasChanged();
80+
}
81+
}
7282

7383
private void ToggleMobileMenu()
7484
{

TextHub/Features/TextCase/CamelCase.razor

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
@page "/camel-case"
1+
@page "/TextHub/camel-case"
22
@using TextHub.Services.Converters
33
@using TextHub.Components.Forms
44
@inject TextCaseConverterService ConverterService
@@ -9,7 +9,7 @@
99
Description="Convert to camelCase for coding"
1010
ConvertButtonText="Convert to camelCase"
1111
UseCaseDescription="Perfect for variable names, function names, and coding"
12-
Route="/camel-case"
12+
Route="/TextHub/camel-case"
1313
ConvertFunction="@(input => ConverterService.ConvertToCamelCase(input))">
1414

1515
<IconSvg>

TextHub/Services/Data/ToolDataService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public List<Tool> GetTextCaseTools()
2323
new Tool("Lowercase Converter", "Transform text to lowercase with one click", "/lowercase", "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" class=\"lucide lucide-letter-text w-5 h-5 sm:w-6 sm:h-6 text-primary\"><path d=\"M15 12h6\"></path><path d=\"M15 6h6\"></path><path d=\"m3 13 3.553-7.724a.5.5 0 0 1 .894 0L11 13\"></path><path d=\"M3 18h18\"></path><path d=\"M4 11h6\"></path></svg>"),
2424
new Tool("Title Case", "Capitalize First Letter Of Each Word", "/title-case", "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" class=\"lucide lucide-case-sensitive w-5 h-5 sm:w-6 sm:h-6 text-primary\"><path d=\"m3 15 4-8 4 8\"></path><path d=\"M4 13h6\"></path><circle cx=\"18\" cy=\"12\" r=\"3\"></circle><path d=\"M21 9v6\"></path></svg>"),
2525
new Tool("Sentence Case", "Capitalize first letter of sentences", "/sentence-case", "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" class=\"lucide lucide-case-sensitive w-5 h-5 sm:w-6 sm:h-6 text-primary\"><path d=\"m3 15 4-8 4 8\"></path><path d=\"M4 13h6\"></path><circle cx=\"18\" cy=\"12\" r=\"3\"></circle><path d=\"M21 9v6\"></path></svg>"),
26-
new Tool("camelCase", "Convert to camelCase for coding", "/camel-case", "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" class=\"lucide lucide-code w-5 h-5 sm:w-6 sm:h-6 text-primary\"><polyline points=\"16 18 22 12 16 6\"></polyline><polyline points=\"8 6 2 12 8 18\"></polyline></svg>"),
26+
new Tool("camelCase", "Convert to camelCase for coding", "/TextHub/camel-case", "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" class=\"lucide lucide-code w-5 h-5 sm:w-6 sm:h-6 text-primary\"><polyline points=\"16 18 22 12 16 6\"></polyline><polyline points=\"8 6 2 12 8 18\"></polyline></svg>"),
2727
new Tool("PascalCase", "Convert to PascalCase for classes", "/pascal-case", "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" class=\"lucide lucide-code w-5 h-5 sm:w-6 sm:h-6 text-primary\"><polyline points=\"16 18 22 12 16 6\"></polyline><polyline points=\"8 6 2 12 8 18\"></polyline></svg>"),
2828
new Tool("snake_case", "Convert to snake_case format", "/snake-case", "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" class=\"lucide lucide-code w-5 h-5 sm:w-6 sm:h-6 text-primary\"><polyline points=\"16 18 22 12 16 6\"></polyline><polyline points=\"8 6 2 12 8 18\"></polyline></svg>"),
2929
new Tool("kebab-case", "Convert to kebab-case for URLs", "/kebab-case", "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" class=\"lucide lucide-code w-5 h-5 sm:w-6 sm:h-6 text-primary\"><polyline points=\"16 18 22 12 16 6\"></polyline><polyline points=\"8 6 2 12 8 18\"></polyline></svg>")

TextHub/wwwroot/index.html

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,14 +137,35 @@
137137

138138
<script src="_framework/blazor.webassembly.js"></script>
139139
<script>
140+
// Initialize theme on page load to prevent flash
141+
(function() {
142+
const savedTheme = localStorage.getItem('theme');
143+
const prefersDark = window.matchMedia('(prefers-color-scheme: dark)').matches;
144+
const isDarkMode = savedTheme === 'dark' || (savedTheme === null && prefersDark);
145+
146+
if (isDarkMode) {
147+
document.documentElement.classList.add('dark');
148+
} else {
149+
document.documentElement.classList.remove('dark');
150+
}
151+
})();
152+
140153
window.toggleTheme = (isDarkMode) => {
141154
const html = document.documentElement;
142155
if (isDarkMode) {
143156
html.classList.add('dark');
157+
localStorage.setItem('theme', 'dark');
144158
} else {
145159
html.classList.remove('dark');
160+
localStorage.setItem('theme', 'light');
146161
}
147162
};
163+
164+
window.getTheme = () => {
165+
const savedTheme = localStorage.getItem('theme');
166+
const prefersDark = window.matchMedia('(prefers-color-scheme: dark)').matches;
167+
return savedTheme === 'dark' || (savedTheme === null && prefersDark);
168+
};
148169
</script>
149170
<!-- <script>navigator.serviceWorker.register('service-worker.js');</script>-->
150171
</body>

0 commit comments

Comments
 (0)