-
Notifications
You must be signed in to change notification settings - Fork 1
feat: Add 10 new educational tools using Svelte 5 runes and shadcn components #546
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,147 @@ | ||
| <script lang="ts"> | ||
| import { Button } from '$lib/components/ui/button/index.js'; | ||
| import { Input } from '$lib/components/ui/input/index.js'; | ||
| import { | ||
| Card, | ||
| CardContent, | ||
| CardDescription, | ||
| CardHeader, | ||
| CardTitle | ||
| } from '$lib/components/ui/card/index.js'; | ||
|
|
||
| let inputText = $state(''); | ||
| let output = $state(''); | ||
|
|
||
| // Simple ASCII art fonts | ||
| const fonts = { | ||
| block: { | ||
| A: ['█████', '█ █', '█████', '█ █', '█ █'], | ||
| B: ['████ ', '█ █', '████ ', '█ █', '████ '], | ||
| C: ['█████', '█ ', '█ ', '█ ', '█████'], | ||
| D: ['████ ', '█ █', '█ █', '█ █', '████ '], | ||
| E: ['█████', '█ ', '███ ', '█ ', '█████'], | ||
| F: ['█████', '█ ', '███ ', '█ ', '█ '], | ||
| G: ['█████', '█ ', '█ ███', '█ █', '█████'], | ||
| H: ['█ █', '█ █', '█████', '█ █', '█ █'], | ||
| I: ['█████', ' █ ', ' █ ', ' █ ', '█████'], | ||
| J: ['█████', ' █', ' █', '█ █', '█████'], | ||
| K: ['█ █', '█ █ ', '███ ', '█ █ ', '█ █'], | ||
| L: ['█ ', '█ ', '█ ', '█ ', '█████'], | ||
| M: ['█ █', '██ ██', '█ █ █', '█ █', '█ █'], | ||
| N: ['█ █', '██ █', '█ █ █', '█ ██', '█ █'], | ||
| O: ['█████', '█ █', '█ █', '█ █', '█████'], | ||
| P: ['████ ', '█ █', '████ ', '█ ', '█ '], | ||
| Q: ['█████', '█ █', '█ █ █', '█ ██', '██ ██'], | ||
| R: ['████ ', '█ █', '████ ', '█ █ ', '█ █'], | ||
| S: ['█████', '█ ', '█████', ' █', '█████'], | ||
| T: ['█████', ' █ ', ' █ ', ' █ ', ' █ '], | ||
| U: ['█ █', '█ █', '█ █', '█ █', '█████'], | ||
| V: ['█ █', '█ █', '█ █', ' █ █ ', ' █ '], | ||
| W: ['█ █', '█ █', '█ █ █', '██ ██', '█ █'], | ||
| X: ['█ █', ' █ █ ', ' █ ', ' █ █ ', '█ █'], | ||
| Y: ['█ █', ' █ █ ', ' █ ', ' █ ', ' █ '], | ||
| Z: ['█████', ' █ ', ' █ ', ' █ ', '█████'], | ||
| ' ': [' ', ' ', ' ', ' ', ' '], | ||
| '!': [' █ ', ' █ ', ' █ ', ' ', ' █ '], | ||
| '?': ['█████', ' █', ' ██ ', ' ', ' █ '] | ||
| } | ||
| }; | ||
|
|
||
| function generateAsciiArt() { | ||
| if (!inputText.trim()) { | ||
| output = ''; | ||
| return; | ||
| } | ||
|
|
||
| const selectedFont = fonts.block; | ||
| const text = inputText.toUpperCase(); | ||
| const lines: string[] = []; | ||
|
|
||
| // Get the height of the font (number of rows) | ||
| const fontHeight = Object.values(selectedFont)[0].length; | ||
|
|
||
| // Initialize lines array | ||
| for (let i = 0; i < fontHeight; i++) { | ||
| lines.push(''); | ||
| } | ||
|
|
||
| // Process each character | ||
| for (let charIndex = 0; charIndex < text.length; charIndex++) { | ||
| const char = text[charIndex]; | ||
| const charPattern = selectedFont[char] || selectedFont[' ']; | ||
|
|
||
| // Add each line of the character to the corresponding line | ||
| for (let lineIndex = 0; lineIndex < fontHeight; lineIndex++) { | ||
| lines[lineIndex] += charPattern[lineIndex]; | ||
| // Add space between characters (except for the last character) | ||
| if (charIndex < text.length - 1) { | ||
| lines[lineIndex] += ' '; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| output = lines.join('\n'); | ||
| } | ||
|
|
||
| function copyToClipboard() { | ||
| if (output) { | ||
| navigator.clipboard.writeText(output); | ||
| } | ||
| } | ||
|
|
||
| function clearAll() { | ||
| inputText = ''; | ||
| output = ''; | ||
| } | ||
|
|
||
| // Auto-generate ASCII art when input changes | ||
| $effect(() => { | ||
| generateAsciiArt(); | ||
| }); | ||
| </script> | ||
|
|
||
| <div class="flex h-full flex-col items-center justify-center gap-4 p-4"> | ||
| <Card class="w-full max-w-4xl"> | ||
| <CardHeader> | ||
| <CardTitle>ASCII Art Generator</CardTitle> | ||
| <CardDescription>Convert text into ASCII art</CardDescription> | ||
| </CardHeader> | ||
| <CardContent class="space-y-4"> | ||
| <div class="grid grid-cols-1 gap-4"> | ||
| <div> | ||
| <label for="text" class="mb-2 block text-sm font-medium">Text to Convert:</label> | ||
| <Input | ||
| id="text" | ||
| bind:value={inputText} | ||
| placeholder="Enter text (letters, spaces, !, ? supported)" | ||
| maxlength="20" | ||
| class="w-full" | ||
| /> | ||
| </div> | ||
| </div> | ||
|
|
||
| <div class="flex gap-2"> | ||
| <Button onclick={generateAsciiArt} disabled={!inputText.trim()}>Generate ASCII Art</Button> | ||
| <Button variant="outline" onclick={clearAll}>Clear</Button> | ||
| {#if output} | ||
| <Button variant="secondary" onclick={copyToClipboard}>Copy ASCII Art</Button> | ||
| {/if} | ||
| </div> | ||
|
|
||
| {#if output} | ||
| <div> | ||
| <h3 class="mb-2 text-lg font-semibold">ASCII Art:</h3> | ||
| <div class="overflow-auto rounded border bg-black p-4 text-green-400"> | ||
| <pre class="font-mono text-sm whitespace-pre">{output}</pre> | ||
| </div> | ||
| </div> | ||
| {/if} | ||
|
|
||
| <div class="text-muted-foreground space-y-1 text-sm"> | ||
| <p><strong>Supported characters:</strong> A-Z, space, !, ?</p> | ||
| <p><strong>Tip:</strong> Keep text short (max 20 characters) for best results</p> | ||
| <p><strong>Note:</strong> ASCII art works best with monospace fonts</p> | ||
| </div> | ||
| </CardContent> | ||
| </Card> | ||
| </div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,107 @@ | ||
| <script lang="ts"> | ||
| import { Button } from '$lib/components/ui/button/index.js'; | ||
| import { | ||
| Card, | ||
| CardContent, | ||
| CardDescription, | ||
| CardHeader, | ||
| CardTitle | ||
| } from '$lib/components/ui/card/index.js'; | ||
| import { Textarea } from '$lib/components/ui/textarea/index.js'; | ||
| import { Tabs, TabsContent, TabsList, TabsTrigger } from '$lib/components/ui/tabs/index.js'; | ||
|
|
||
| let inputText = $state(''); | ||
| let outputText = $state(''); | ||
| let error = $state(''); | ||
|
|
||
| function encode() { | ||
| try { | ||
| error = ''; | ||
| outputText = btoa(inputText); | ||
| } catch (e) { | ||
| error = 'Failed to encode. Please check your input.'; | ||
| outputText = ''; | ||
| } | ||
| } | ||
|
|
||
| function decode() { | ||
| try { | ||
| error = ''; | ||
| outputText = atob(inputText); | ||
| } catch (e) { | ||
| error = 'Invalid Base64 input. Please check your input.'; | ||
| outputText = ''; | ||
| } | ||
| } | ||
|
|
||
| function clearAll() { | ||
| inputText = ''; | ||
| outputText = ''; | ||
| error = ''; | ||
| } | ||
|
|
||
| function copyToClipboard() { | ||
| if (outputText) { | ||
| navigator.clipboard.writeText(outputText); | ||
| } | ||
| } | ||
| </script> | ||
|
|
||
| <div class="flex h-full flex-col items-center justify-center gap-4 p-4"> | ||
| <Card class="w-full max-w-4xl"> | ||
| <CardHeader> | ||
| <CardTitle>Base64 Encoder/Decoder</CardTitle> | ||
| <CardDescription>Encode text to Base64 or decode Base64 back to text</CardDescription> | ||
| </CardHeader> | ||
| <CardContent class="space-y-4"> | ||
| <Tabs value="encode" class="w-full"> | ||
| <TabsList class="grid w-full grid-cols-2"> | ||
| <TabsTrigger value="encode">Encode</TabsTrigger> | ||
| <TabsTrigger value="decode">Decode</TabsTrigger> | ||
| </TabsList> | ||
|
|
||
| <TabsContent value="encode" class="space-y-4"> | ||
| <div> | ||
| <Textarea | ||
| bind:value={inputText} | ||
| placeholder="Enter text to encode to Base64..." | ||
| class="min-h-[150px]" | ||
| /> | ||
| </div> | ||
| <Button onclick={encode} disabled={!inputText.trim()}>Encode to Base64</Button> | ||
| </TabsContent> | ||
|
|
||
| <TabsContent value="decode" class="space-y-4"> | ||
| <div> | ||
| <Textarea | ||
| bind:value={inputText} | ||
| placeholder="Enter Base64 text to decode..." | ||
| class="min-h-[150px]" | ||
| /> | ||
| </div> | ||
| <Button onclick={decode} disabled={!inputText.trim()}>Decode from Base64</Button> | ||
| </TabsContent> | ||
| </Tabs> | ||
|
|
||
| <div class="flex gap-2"> | ||
| <Button variant="outline" onclick={clearAll}>Clear All</Button> | ||
| {#if outputText} | ||
| <Button variant="secondary" onclick={copyToClipboard}>Copy Result</Button> | ||
| {/if} | ||
| </div> | ||
|
|
||
| {#if error} | ||
| <div class="text-destructive bg-destructive/10 rounded border p-3"> | ||
| {error} | ||
| </div> | ||
| {/if} | ||
|
|
||
| {#if outputText} | ||
| <div> | ||
| <h3 class="mb-2 text-lg font-semibold">Result:</h3> | ||
| <Textarea value={outputText} readonly class="bg-muted min-h-[150px]" /> | ||
| </div> | ||
| {/if} | ||
| </CardContent> | ||
| </Card> | ||
| </div> | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Allow the tabs to switch so the Decode tool is usable.
<Tabs value="encode">locks the component to the Encode tab; clicking “Decode” never changes the active tab, so the decoding workflow can’t be reached. UsedefaultValue="encode"(or bindvalueto state) so the tab set can update on user interaction.📝 Committable suggestion
🤖 Prompt for AI Agents