Skip to content

Commit 01a5da6

Browse files
constants moved to constants.ts
1 parent 2a6de1e commit 01a5da6

File tree

3 files changed

+23
-30
lines changed

3 files changed

+23
-30
lines changed

src/pages/vedic.astro

Lines changed: 2 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
import { fullEnglish, fullHindi, styleOption
2+
import { fullEnglish, fullHindi, styleOption,tithiNames
33
} from "@/utils/constants.ts";
44
import BackIcon from "@/components/Back.astro";
55
import BaseLayout from "@/layouts/Base";
@@ -131,7 +131,7 @@ const timeUnits = vedicData.time_units;
131131
</div>
132132
</div>
133133

134-
<script is:inline define:vars={{ timeUnits , fullEnglish, fullHindi, styleOption}}>
134+
<script is:inline define:vars={{ timeUnits , fullEnglish, fullHindi, styleOption,tithiNames}}>
135135
const dateInEnglish = new Intl.DateTimeFormat("en-us", fullEnglish);
136136
const samay = new Intl.DateTimeFormat("hi", fullHindi);
137137
const dateInHindi = new Intl.DateTimeFormat("hi", styleOption);
@@ -140,7 +140,6 @@ const timeUnits = vedicData.time_units;
140140
const from = timeUnits.find((u) => u.name === fromUnit);
141141
const to = timeUnits.find((u) => u.name === toUnit);
142142
if (!from || !to) return null;
143-
144143
const seconds = value * from.seconds;
145144
return seconds / to.seconds;
146145
}
@@ -182,30 +181,23 @@ const timeUnits = vedicData.time_units;
182181
const temp = fromUnit.value;
183182
fromUnit.value = toUnit.value;
184183
toUnit.value = temp;
185-
186184
swapButton.classList.toggle("active");
187-
188185
updateResult();
189186
});
190187
}
191-
192188
// Tab functionality
193189
const tabButtons = document.querySelectorAll(".tab-button");
194190
const tabContents = document.querySelectorAll(".tab-content");
195-
196191
tabButtons.forEach((button) => {
197192
button.addEventListener("click", () => {
198193
// Remove active class from all buttons and contents
199194
tabButtons.forEach((btn) => btn.classList.remove("active"));
200195
tabContents.forEach((content) => content.classList.remove("active"));
201-
202196
// Add active class to clicked button
203197
button.classList.add("active");
204-
205198
// Show corresponding tab content
206199
const targetTab = button.dataset.tab;
207200
document.getElementById(`${targetTab}-tab-content`).classList.add("active");
208-
209201
// Call updateResult if switching to converter tab to ensure result is shown if inputs have values
210202
if (targetTab === "converter") {
211203
updateResult();
@@ -217,25 +209,6 @@ const timeUnits = vedicData.time_units;
217209
document.querySelector('.tab-button[data-tab="tithi"]').click(); // Simulate click to activate default tab
218210

219211
// Tithi date display functionality
220-
const tithiNames = [
221-
"प्रतिपदा",
222-
"द्वितीया",
223-
"तृतीया",
224-
"चतुर्थी",
225-
"पंचमी",
226-
"षष्ठी",
227-
"सप्तमी",
228-
"अष्टमी",
229-
"नवमी",
230-
"दशमी",
231-
"एकादशी",
232-
"द्वादशी",
233-
"त्रयोदशी",
234-
"चतुर्दशी",
235-
"पूर्णिमा",
236-
"अमावस्या"
237-
];
238-
239212
const getLunarDate = (gregorianDate) => {
240213
const day = gregorianDate.getDate();
241214
const lunarDay = ((day - 1) % 15) + 1;

src/utils/constants.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,26 @@ const englishConsonants = [
303303
"sa",
304304
"ha"
305305
];
306+
const tithiNames = [
307+
"प्रतिपदा",
308+
"द्वितीया",
309+
"तृतीया",
310+
"चतुर्थी",
311+
"पंचमी",
312+
"षष्ठी",
313+
"सप्तमी",
314+
"अष्टमी",
315+
"नवमी",
316+
"दशमी",
317+
"एकादशी",
318+
"द्वादशी",
319+
"त्रयोदशी",
320+
"चतुर्दशी",
321+
"पूर्णिमा",
322+
"अमावस्या"
323+
];
324+
325+
export {tithiNames}
306326
export {englishVowels, englishConsonants}
307327
export { fullEnglish, fullHindi, styleOption }
308328
export { BASE_URL, IMAGE_DIR };

src/utils/languageLetters.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { englishVowels,englishConsonants
22
} from "@/utils/constants.ts";
33

4-
interface LetterPair {
4+
type LetterPair = {
55
hindi: string;
66
kannada: string;
77
marathi: string;

0 commit comments

Comments
 (0)