Skip to content

Commit 67a2634

Browse files
committed
[main]: added copy icon to barahkhadi; avgrah added
1 parent 1771316 commit 67a2634

File tree

8 files changed

+125
-31
lines changed

8 files changed

+125
-31
lines changed

src/assets/icons/copy.svg

Lines changed: 4 additions & 0 deletions
Loading

src/assets/styles/alphabet.css

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
& .list {
2525
display: grid;
2626
grid-gap: 1.5rem;
27-
grid-template-columns: repeat(auto-fit, minmax(20rem, 1fr));
27+
grid-template-columns: repeat(5, minmax(20rem, 1fr));
2828
margin-block: 2rem;
2929

3030
& .letter {
@@ -81,17 +81,19 @@
8181
}
8282
}
8383

84-
/*@container layout (width <=768px) {
85-
.list {
86-
grid-template-columns: repeat(2, 1fr);
87-
}
84+
@container alphabet (width <=768px) {
85+
.container__alphabet {
86+
& .list {
87+
grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
88+
}
8889

89-
.letter {
90-
color: black;
91-
font-size: max(1.5em, 1.23em + 2cqi);
92-
}
90+
& .letter {
91+
color: black;
92+
font-size: max(1.5em, 1.23em + 2cqi);
93+
}
9394

94-
.letter p {
95-
font-size: clamp(2rem, 4vw, 3rem) !important;
95+
& def {
96+
font-size: 1.5rem;
97+
}
9698
}
97-
}*/
99+
}

src/assets/styles/menu.css

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -490,9 +490,6 @@
490490
color: white;
491491
}
492492

493-
[data-debug="false"] .debug-toggle g:first-of-type {
494-
display: block;
495-
}
496493

497494
[popover] nav {
498495
overflow-y: auto;

src/components/Alphabet.astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
import "@/assets/styles/alphabet.css";
33
import Letter from "@/components/Letter.astro";
4-
import { type LetterEntity } from "@/types";
4+
import type { LetterEntity } from "@/types";
55
66
type Props = {
77
title: string;

src/components/Dialog.js

Lines changed: 0 additions & 11 deletions
This file was deleted.

src/components/Letter.astro

Lines changed: 100 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
---
22
import type { LetterEntity } from "@/types";
3+
import CopyIcon from "@/assets/icons/copy.svg";
34
45
type Props = {
56
item: LetterEntity;
@@ -12,6 +13,104 @@ const {
1213

1314
<div class="letter">
1415
<p class="character">{letter}</p>
15-
<p data-id="tgt" class="code" title="Click to copy">&copy;</p>
16+
<button id="copy-btn" class="copy-btn" title="Copy character" data-letter={letter}>
17+
<CopyIcon />
18+
</button>
19+
<span class="copy-feedback">Copied!</span>
1620
<def data-id="def" class="help" title="Definition">{code}</def>
1721
</div>
22+
23+
<script>
24+
// Wait for the DOM to be loaded
25+
document.addEventListener("DOMContentLoaded", () => {
26+
const copyButtons = document.querySelectorAll("#copy-btn");
27+
28+
copyButtons.forEach((button) => {
29+
button.addEventListener("click", async () => {
30+
const letter = (button as HTMLElement).dataset.letter;
31+
if (!letter) return;
32+
33+
try {
34+
await navigator.clipboard.writeText(letter);
35+
const letterDiv = button.closest(".letter") as HTMLElement;
36+
const feedback = letterDiv.querySelector(".copy-feedback") as HTMLElement;
37+
38+
// Add animation classes
39+
letterDiv.classList.add("copied");
40+
feedback.classList.add("show");
41+
42+
// Remove animation classes after animation
43+
setTimeout(() => {
44+
letterDiv.classList.remove("copied");
45+
feedback.classList.remove("show");
46+
}, 2000);
47+
} catch (err) {
48+
console.error("Failed to copy text: ", err);
49+
}
50+
});
51+
});
52+
});
53+
</script>
54+
55+
<style>
56+
.letter {
57+
position: relative;
58+
}
59+
60+
.copy-btn {
61+
background: none;
62+
border: none;
63+
cursor: pointer;
64+
padding: 4px;
65+
color: #666;
66+
transition: color 0.2s;
67+
}
68+
69+
.copy-btn:hover {
70+
color: #333;
71+
}
72+
73+
.copy-btn svg {
74+
display: block;
75+
}
76+
77+
.copy-feedback {
78+
position: absolute;
79+
top: -30px;
80+
left: 50%;
81+
transform: translateX(-50%) translateY(10px);
82+
background: #333;
83+
color: white;
84+
padding: 4px 8px;
85+
border-radius: 4px;
86+
font-size: 14px;
87+
opacity: 0;
88+
visibility: hidden;
89+
transition: all 0.3s ease;
90+
}
91+
92+
.copy-feedback.show {
93+
opacity: 1;
94+
visibility: visible;
95+
transform: translateX(-50%) translateY(0);
96+
}
97+
98+
.letter.copied {
99+
animation: copyPulse 0.5s ease;
100+
}
101+
102+
@keyframes copyPulse {
103+
0% {
104+
transform: scale(1);
105+
box-shadow: 0 0 0 0 rgba(52, 152, 219, 0.4);
106+
}
107+
50% {
108+
transform: scale(1.05);
109+
box-shadow: 0 0 0 10px rgba(52, 152, 219, 0.2);
110+
}
111+
100% {
112+
transform: scale(1);
113+
box-shadow: 0 0 0 0 rgba(52, 152, 219, 0);
114+
}
115+
}
116+
</style>

src/utils/common.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ export const hindiVowelList = hindiVowels.filter((v) => !extraHindiVowelKey.incl
1818
const additionalConsonants = [
1919
String.fromCharCode(2325, 2381, 2359),
2020
String.fromCharCode(2340, 2381, 2352),
21-
String.fromCharCode(2332, 2381, 2334)
21+
String.fromCharCode(2332, 2381, 2334),
22+
String.fromCharCode(2365)
2223
];
2324

2425
export const hindiConsonants = [
@@ -61,8 +62,10 @@ export const barahkhadi = (code: number) => {
6162
return list.concat(sanyukat);
6263
};
6364

65+
// 2365 avgrah ऽ
66+
6467
// exclude 2345 ' 2353 / 2355 / 2356
65-
export const extraLetters = [2345, 2353, 2356]; // 'ऩ', 'ऱ', 'ऴ'
68+
export const extraLetters = [2345, 2353, 2355, 2356]; // 'ऩ', 'ऱ', 'ऴ'
6669
export const varnmala = Array.from(Array(37), (_, i) => ({ code: 2325 + i, letter: String.fromCharCode(2325 + i) }));
6770
export const varnmala_english = Array.from(Array(26), (_, i) => ({
6871
code: 65 + i,

src/utils/constants.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import HomeIcon from "@/assets/icons/home.svg";
22
import RecordIcon from "@/assets/icons/record.svg";
3-
import type { LinkProps } from "@/types";
3+
import type { LinkProps } from "@/types/index.ts";
44

55
export const APP_NAME = "Template";
66

0 commit comments

Comments
 (0)