Skip to content

Commit 00a2108

Browse files
committed
Code Refactored
1 parent 0c499eb commit 00a2108

39 files changed

+484
-1215
lines changed

TextHub/Pages/Lowercase.razor renamed to TextHub/Components/Forms/TextCaseLayout.razor

Lines changed: 34 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,39 @@
1-
@page "/lowercase"
2-
@using TextHub.Services
3-
@using TextHub.UIComponent
1+
@using TextHub.Services.Data
2+
@using TextHub.Components.Shared
43
@using Microsoft.JSInterop
54
@inject JsonLdService JsonLdService
65
@inject ToolDataService ToolDataService
76
@inject IJSRuntime JSRuntime
87

9-
<PageTitle>Lowercase Converter - Text Hub</PageTitle>
8+
<PageTitle>@PageTitle - Text Hub</PageTitle>
109

11-
<DynamicJsonLd JsonLdContent="@_jsonLdContent" Id="lowercase-jsonld" />
10+
<DynamicJsonLd JsonLdContent="@_jsonLdContent" Id="@(ToolName.ToLower().Replace(" ", "").Replace("-", "").Replace("_", "") + "-jsonld")" />
1211

1312
<main class="flex-1">
1413
<div class="container mx-auto px-4 py-8 md:py-12 animate-fade-in">
1514
<div class="max-w-4xl mx-auto">
1615
<div class="text-center mb-8 md:mb-10">
1716
<div class="inline-flex items-center justify-center p-2.5 sm:p-3 bg-primary/10 rounded-lg mb-3 md:mb-4">
18-
<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-6 h-6 sm:w-8 sm:h-8 text-primary">
19-
<path d="M15 12h6"></path>
20-
<path d="M15 6h6"></path>
21-
<path d="m3 13 3.553-7.724a.5.5 0 0 1 .894 0L11 13"></path>
22-
<path d="M3 18h18"></path>
23-
<path d="M4 11h6"></path>
24-
</svg>
17+
@IconSvg
2518
</div>
2619
<h1 class="text-2xl sm:text-3xl md:text-4xl font-bold mb-3 md:mb-4">
27-
<span class="text-gradient">Lowercase Converter</span>
20+
<span class="text-gradient">@ToolName</span>
2821
</h1>
29-
<p class="text-base sm:text-lg text-muted-foreground px-4">Transform text to lowercase with one click</p>
22+
<p class="text-base sm:text-lg text-muted-foreground px-4">@Description</p>
3023
</div>
3124

3225
<div class="grid gap-4 md:gap-6">
3326
<div class="animate-fade-in" style="animation-delay: 100ms;">
3427
<label class="block text-sm font-medium mb-2">Input Text</label>
3528
<textarea
3629
@bind="_inputText"
37-
@oninput="ConvertToLowercase"
30+
@oninput="OnInputChanged"
3831
placeholder="Enter or paste your text here..."
3932
class="input-area min-h-[150px] sm:min-h-[200px] text-sm sm:text-base"></textarea>
4033
</div>
4134

4235
<div class="flex flex-col sm:flex-row gap-3 sm:gap-4 justify-center animate-fade-in" style="animation-delay: 200ms;">
43-
<button @onclick="ConvertToLowercase" class="btn-primary w-full sm:w-auto text-sm sm:text-base">Convert to lowercase</button>
36+
<button @onclick="OnConvertClicked" class="btn-primary w-full sm:w-auto text-sm sm:text-base">@ConvertButtonText</button>
4437
<button @onclick="ClearText" class="btn-secondary w-full sm:w-auto text-sm sm:text-base">
4538
<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-rotate-ccw w-4 h-4 mr-2 inline">
4639
<path d="M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"></path>
@@ -75,32 +68,52 @@
7568
<h2 class="text-lg md:text-xl font-semibold mb-2 md:mb-3">How it works</h2>
7669
<ul class="space-y-1.5 md:space-y-2 text-sm md:text-base text-muted-foreground">
7770
<li>• Simply paste or type your text in the input box</li>
78-
<li>• Click "Convert to lowercase" to transform your text</li>
71+
<li>• Click "@ConvertButtonText" to transform your text</li>
7972
<li>• Copy the result to your clipboard with one click</li>
80-
<li>• Perfect for normalizing text or creating consistent formatting</li>
73+
<li>• @UseCaseDescription</li>
8174
</ul>
8275
</div>
8376
</div>
8477
</div>
8578
</main>
8679

8780
@code {
81+
[Parameter] public string PageTitle { get; set; } = string.Empty;
82+
[Parameter] public string ToolName { get; set; } = string.Empty;
83+
[Parameter] public string Description { get; set; } = string.Empty;
84+
[Parameter] public string ConvertButtonText { get; set; } = string.Empty;
85+
[Parameter] public string UseCaseDescription { get; set; } = string.Empty;
86+
[Parameter] public RenderFragment IconSvg { get; set; } = default!;
87+
[Parameter] public string Route { get; set; } = string.Empty;
88+
[Parameter] public Func<string, string> ConvertFunction { get; set; } = default!;
89+
8890
private string _inputText = string.Empty;
8991
private string _outputText = string.Empty;
9092
private string _jsonLdContent = string.Empty;
9193

9294
protected override void OnInitialized()
9395
{
94-
var tool = ToolDataService.GetTextCaseTools().FirstOrDefault(t => t.Href == "/lowercase");
96+
var tool = ToolDataService.GetTextCaseTools().FirstOrDefault(t => t.Href == Route);
9597
if (tool != null)
9698
{
9799
_jsonLdContent = JsonLdService.GenerateToolPageJsonLd(tool, "Text Case Tools");
98100
}
99101
}
100102

101-
private void ConvertToLowercase()
103+
private void OnInputChanged()
104+
{
105+
if (ConvertFunction != null)
106+
{
107+
_outputText = ConvertFunction(_inputText);
108+
}
109+
}
110+
111+
private void OnConvertClicked()
102112
{
103-
_outputText = _inputText.ToLower();
113+
if (ConvertFunction != null)
114+
{
115+
_outputText = ConvertFunction(_inputText);
116+
}
104117
}
105118

106119
private void ClearText()
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)