|
2 | 2 | import BaseLayout from "@/layouts/Base"; |
3 | 3 | import "@/assets/styles/varnmala/english.css"; |
4 | 4 | import Help from "@/components/Help.astro"; |
| 5 | +import BackButton from "@/components/ui/backButton.astro"; |
5 | 6 | --- |
6 | 7 |
|
7 | 8 | <BaseLayout meta={{ title: "English" }}> |
@@ -40,98 +41,101 @@ import Help from "@/components/Help.astro"; |
40 | 41 | description="Just press any letter fron keyboard and it display the letter and it's relative word in clear way and if you type again it will change the color" |
41 | 42 | /> |
42 | 43 | </Fragment> |
43 | | - <div class="controls" id="controls"> |
44 | | - <div class="control-group"> |
45 | | - <label>Background:</label> |
46 | | - <select id="bgSelector"> |
47 | | - <option value="none">None</option> |
48 | | - <option value="gradient1">Gradient 1</option> |
49 | | - <option value="gradient2">Gradient 2</option> |
50 | | - <option value="pattern1">Pattern 1</option> |
51 | | - </select> |
52 | | - <button id="toggleBg">Toggle Background</button> |
53 | | - </div> |
| 44 | + <BackButton /> |
| 45 | + <article class="container__english"> |
| 46 | + <div class="controls" id="controls"> |
| 47 | + <div class="control-group"> |
| 48 | + <label>Background:</label> |
| 49 | + <select id="bgSelector"> |
| 50 | + <option value="none">None</option> |
| 51 | + <option value="gradient1">Gradient 1</option> |
| 52 | + <option value="gradient2">Gradient 2</option> |
| 53 | + <option value="pattern1">Pattern 1</option> |
| 54 | + </select> |
| 55 | + <button id="toggleBg">Toggle Background</button> |
| 56 | + </div> |
54 | 57 |
|
55 | | - <div class="control-group"> |
56 | | - <label>Font:</label> |
57 | | - <select id="fontSelector"> |
58 | | - <option value="Arial">Arial</option> |
59 | | - <option value="Georgia">Georgia</option> |
60 | | - <option value="Times New Roman">Times New Roman</option> |
61 | | - </select> |
62 | | - <input type="color" id="colorPicker" value="#000000" /> |
| 58 | + <div class="control-group"> |
| 59 | + <label>Font:</label> |
| 60 | + <select id="fontSelector"> |
| 61 | + <option value="Arial">Arial</option> |
| 62 | + <option value="Georgia">Georgia</option> |
| 63 | + <option value="Times New Roman">Times New Roman</option> |
| 64 | + </select> |
| 65 | + <input type="color" id="colorPicker" value="#000000" /> |
| 66 | + </div> |
63 | 67 | </div> |
64 | | - </div> |
65 | | - <article class="container__hindi" id="letterContainer"> |
66 | | - <div class="letter">A</div> |
67 | | - </article> |
68 | | - <script> |
69 | | - import { colorBox, isAlphabet, random } from "@/utils/utils.js"; |
| 68 | + <article class="container__hindi" id="letterContainer"> |
| 69 | + <div class="letter">A</div> |
| 70 | + </article> |
| 71 | + <script> |
| 72 | + import { colorBox, isAlphabet, random } from "@/utils/utils.js"; |
70 | 73 |
|
71 | | - const letterDiv = document.querySelector(".letter") as HTMLDivElement; |
72 | | - const controls = document.getElementById("controls") as HTMLElement; |
73 | | - const letterContainer = document.getElementById("letterContainer") as HTMLElement; |
74 | | - const bgSelector = document.getElementById("bgSelector") as HTMLInputElement; |
75 | | - const fontSelector = document.getElementById("fontSelector") as HTMLInputElement; |
76 | | - const colorPicker = document.getElementById("colorPicker") as HTMLInputElement; |
77 | | - const toggleBg = document.getElementById("toggleBg") as HTMLButtonElement; |
| 74 | + const letterDiv = document.querySelector(".letter") as HTMLDivElement; |
| 75 | + const controls = document.getElementById("controls") as HTMLElement; |
| 76 | + const letterContainer = document.getElementById("letterContainer") as HTMLElement; |
| 77 | + const bgSelector = document.getElementById("bgSelector") as HTMLInputElement; |
| 78 | + const fontSelector = document.getElementById("fontSelector") as HTMLInputElement; |
| 79 | + const colorPicker = document.getElementById("colorPicker") as HTMLInputElement; |
| 80 | + const toggleBg = document.getElementById("toggleBg") as HTMLButtonElement; |
78 | 81 |
|
79 | | - // Event Listeners |
80 | | - bgSelector?.addEventListener("change", updateBackground); |
81 | | - fontSelector?.addEventListener("change", updateFont); |
82 | | - colorPicker?.addEventListener("change", updateColor); |
83 | | - toggleBg?.addEventListener("click", toggleBackground); |
| 82 | + // Event Listeners |
| 83 | + bgSelector?.addEventListener("change", updateBackground); |
| 84 | + fontSelector?.addEventListener("change", updateFont); |
| 85 | + colorPicker?.addEventListener("change", updateColor); |
| 86 | + toggleBg?.addEventListener("click", toggleBackground); |
84 | 87 |
|
85 | | - document.addEventListener( |
86 | | - "keydown", |
87 | | - (e) => { |
88 | | - e.preventDefault(); |
89 | | - const color = random(colorBox); |
90 | | - const { key, keyCode } = e; |
91 | | - if (isAlphabet(keyCode)) { |
92 | | - const keyCapital = key.toUpperCase(); |
93 | | - drawLetter(keyCapital, colorPicker.value || color); |
94 | | - } |
95 | | - }, |
96 | | - false |
97 | | - ); |
| 88 | + document.addEventListener( |
| 89 | + "keydown", |
| 90 | + (e) => { |
| 91 | + e.preventDefault(); |
| 92 | + const color = random(colorBox); |
| 93 | + const { key, keyCode } = e; |
| 94 | + if (isAlphabet(keyCode)) { |
| 95 | + const keyCapital = key.toUpperCase(); |
| 96 | + drawLetter(keyCapital, colorPicker.value || color); |
| 97 | + } |
| 98 | + }, |
| 99 | + false |
| 100 | + ); |
98 | 101 |
|
99 | | - const drawLetter = (letter: string, color = "pink") => { |
100 | | - letterDiv.innerHTML = letter; |
101 | | - letterDiv.style.color = color; |
102 | | - letterDiv.style.animation = "letterPop 0.3s ease-out"; |
103 | | - setTimeout(() => { |
104 | | - letterDiv.style.animation = ""; |
105 | | - }, 300); |
106 | | - }; |
| 102 | + const drawLetter = (letter: string, color = "pink") => { |
| 103 | + letterDiv.innerHTML = letter; |
| 104 | + letterDiv.style.color = color; |
| 105 | + letterDiv.style.animation = "letterPop 0.3s ease-out"; |
| 106 | + setTimeout(() => { |
| 107 | + letterDiv.style.animation = ""; |
| 108 | + }, 300); |
| 109 | + }; |
107 | 110 |
|
108 | | - function updateBackground() { |
109 | | - letterContainer.className = "container__hindi"; |
110 | | - if (bgSelector.value !== "none") { |
111 | | - letterContainer.classList.add(`bg-${bgSelector.value}`); |
| 111 | + function updateBackground() { |
| 112 | + letterContainer.className = "container__hindi"; |
| 113 | + if (bgSelector.value !== "none") { |
| 114 | + letterContainer.classList.add(`bg-${bgSelector.value}`); |
| 115 | + } |
112 | 116 | } |
113 | | - } |
114 | 117 |
|
115 | | - function updateFont() { |
116 | | - letterDiv.style.fontFamily = fontSelector.value; |
117 | | - } |
| 118 | + function updateFont() { |
| 119 | + letterDiv.style.fontFamily = fontSelector.value; |
| 120 | + } |
118 | 121 |
|
119 | | - function updateColor() { |
120 | | - letterDiv.style.color = colorPicker.value; |
121 | | - } |
| 122 | + function updateColor() { |
| 123 | + letterDiv.style.color = colorPicker.value; |
| 124 | + } |
122 | 125 |
|
123 | | - function toggleBackground() { |
124 | | - letterContainer.classList.toggle("no-background"); |
125 | | - } |
| 126 | + function toggleBackground() { |
| 127 | + letterContainer.classList.toggle("no-background"); |
| 128 | + } |
126 | 129 |
|
127 | | - // Intersection Observer for sticky header |
128 | | - const observer = new IntersectionObserver( |
129 | | - ([e]) => { |
130 | | - controls.classList.toggle("sticky", e.intersectionRatio < 1); |
131 | | - }, |
132 | | - { threshold: [1] } |
133 | | - ); |
| 130 | + // Intersection Observer for sticky header |
| 131 | + const observer = new IntersectionObserver( |
| 132 | + ([e]) => { |
| 133 | + controls.classList.toggle("sticky", e.intersectionRatio < 1); |
| 134 | + }, |
| 135 | + { threshold: [1] } |
| 136 | + ); |
134 | 137 |
|
135 | | - observer.observe(controls); |
136 | | - </script> |
| 138 | + observer.observe(controls); |
| 139 | + </script> |
| 140 | + </article> |
137 | 141 | </BaseLayout> |
0 commit comments