|
1 | | -@page "/lowercase" |
2 | | -@using TextHub.Services |
3 | | -@using TextHub.UIComponent |
| 1 | +@using TextHub.Services.Data |
| 2 | +@using TextHub.Components.Shared |
4 | 3 | @using Microsoft.JSInterop |
5 | 4 | @inject JsonLdService JsonLdService |
6 | 5 | @inject ToolDataService ToolDataService |
7 | 6 | @inject IJSRuntime JSRuntime |
8 | 7 |
|
9 | | -<PageTitle>Lowercase Converter - Text Hub</PageTitle> |
| 8 | +<PageTitle>@PageTitle - Text Hub</PageTitle> |
10 | 9 |
|
11 | | -<DynamicJsonLd JsonLdContent="@_jsonLdContent" Id="lowercase-jsonld" /> |
| 10 | +<DynamicJsonLd JsonLdContent="@_jsonLdContent" Id="@(ToolName.ToLower().Replace(" ", "").Replace("-", "").Replace("_", "") + "-jsonld")" /> |
12 | 11 |
|
13 | 12 | <main class="flex-1"> |
14 | 13 | <div class="container mx-auto px-4 py-8 md:py-12 animate-fade-in"> |
15 | 14 | <div class="max-w-4xl mx-auto"> |
16 | 15 | <div class="text-center mb-8 md:mb-10"> |
17 | 16 | <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 |
25 | 18 | </div> |
26 | 19 | <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> |
28 | 21 | </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> |
30 | 23 | </div> |
31 | 24 |
|
32 | 25 | <div class="grid gap-4 md:gap-6"> |
33 | 26 | <div class="animate-fade-in" style="animation-delay: 100ms;"> |
34 | 27 | <label class="block text-sm font-medium mb-2">Input Text</label> |
35 | 28 | <textarea |
36 | 29 | @bind="_inputText" |
37 | | - @oninput="ConvertToLowercase" |
| 30 | + @oninput="OnInputChanged" |
38 | 31 | placeholder="Enter or paste your text here..." |
39 | 32 | class="input-area min-h-[150px] sm:min-h-[200px] text-sm sm:text-base"></textarea> |
40 | 33 | </div> |
41 | 34 |
|
42 | 35 | <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> |
44 | 37 | <button @onclick="ClearText" class="btn-secondary w-full sm:w-auto text-sm sm:text-base"> |
45 | 38 | <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"> |
46 | 39 | <path d="M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"></path> |
|
75 | 68 | <h2 class="text-lg md:text-xl font-semibold mb-2 md:mb-3">How it works</h2> |
76 | 69 | <ul class="space-y-1.5 md:space-y-2 text-sm md:text-base text-muted-foreground"> |
77 | 70 | <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> |
79 | 72 | <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> |
81 | 74 | </ul> |
82 | 75 | </div> |
83 | 76 | </div> |
84 | 77 | </div> |
85 | 78 | </main> |
86 | 79 |
|
87 | 80 | @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 | + |
88 | 90 | private string _inputText = string.Empty; |
89 | 91 | private string _outputText = string.Empty; |
90 | 92 | private string _jsonLdContent = string.Empty; |
91 | 93 |
|
92 | 94 | protected override void OnInitialized() |
93 | 95 | { |
94 | | - var tool = ToolDataService.GetTextCaseTools().FirstOrDefault(t => t.Href == "/lowercase"); |
| 96 | + var tool = ToolDataService.GetTextCaseTools().FirstOrDefault(t => t.Href == Route); |
95 | 97 | if (tool != null) |
96 | 98 | { |
97 | 99 | _jsonLdContent = JsonLdService.GenerateToolPageJsonLd(tool, "Text Case Tools"); |
98 | 100 | } |
99 | 101 | } |
100 | 102 |
|
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() |
102 | 112 | { |
103 | | - _outputText = _inputText.ToLower(); |
| 113 | + if (ConvertFunction != null) |
| 114 | + { |
| 115 | + _outputText = ConvertFunction(_inputText); |
| 116 | + } |
104 | 117 | } |
105 | 118 |
|
106 | 119 | private void ClearText() |
|
0 commit comments