Skip to content

Commit 3cc73bc

Browse files
committed
Updated Varnmala Page UI
1 parent 43b23fc commit 3cc73bc

File tree

4 files changed

+109
-25
lines changed

4 files changed

+109
-25
lines changed

src/assets/styles/alphabet.css

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,25 @@
11
.container__alphabet {
2+
padding: 1rem;
23
display: grid;
34
grid-gap: 4px;
45
container-type: inline-size;
56
container-name: layout;
67
font-family: "atkinson";
78

9+
& h1 {
10+
font-size: 2rem;
11+
text-align: center;
12+
border: 1px solid var(--border);
13+
border-radius: 1rem;
14+
background: var(--background);
15+
padding: 1rem;
16+
}
17+
818
& .list {
919
display: grid;
10-
grid-gap: 4px;
11-
grid-template-columns: repeat(5, 1fr);
12-
margin-block: 1rem;
20+
grid-gap: 1rem;
21+
grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
22+
margin-block: 1.5rem;
1323

1424
& .letter {
1525
display: grid;
@@ -19,19 +29,31 @@
1929
color: var(--text, grey);
2030
border: 2px solid var(--bc);
2131
border-radius: 0.5rem;
22-
box-shadow: rgb(38, 57, 77) 0px 20px 30px -10px;
32+
box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1);
2333
padding: 0.5rem;
2434
height: fit-content;
35+
transition: transform 0.2s ease, box-shadow 0.2s ease;
36+
background: var(--background);
37+
38+
&:hover {
39+
transform: translateY(-2px);
40+
box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1);
41+
}
2542

2643
& p {
27-
font-size: clamp(1.5rem, 5vw, 5rem);
44+
font-size: clamp(2rem, 4vw, 4rem);
2845
text-align: center;
2946
width: 100%;
47+
margin: 0.5rem 0;
3048
}
3149

3250
& .code {
3351
cursor: pointer;
34-
font-size: small;
52+
font-size: 1rem;
53+
color: var(--primary);
54+
padding: 0.25rem 0.5rem;
55+
border-radius: 0.25rem;
56+
background: var(--background-alt);
3557
}
3658

3759
::selection {
@@ -52,4 +74,8 @@
5274
color: black;
5375
font-size: max(1.5em, 1.23em + 2cqi);
5476
}
77+
78+
.letter p {
79+
font-size: clamp(1.5rem, 3vw, 2.5rem) !important;
80+
}
5581
}

src/assets/styles/varnmala.css

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
.container__varnmala {
2+
& .tabs {
3+
position: sticky;
4+
top: var(--header-height);
5+
z-index: 10;
6+
padding: 1rem;
7+
width: fit-content;
8+
border: 1px solid var(--border);
9+
border-radius: 1rem;
10+
background: var(--background);
11+
display: flex;
12+
gap: 1rem;
13+
box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1);
14+
}
15+
16+
& .tab {
17+
padding: 0.5rem 2rem;
18+
font-size: 1.2rem;
19+
border-bottom: 2px solid transparent;
20+
transition: all 0.2s ease;
21+
position: relative;
22+
background: var(--background-alt);
23+
border-radius: 0.5rem;
24+
25+
&:hover {
26+
background: var(--background-hover);
27+
}
28+
}
29+
30+
& .tab.active {
31+
color: var(--primary);
32+
border-bottom-color: var(--primary);
33+
background: var(--primary);
34+
color: var(--background);
35+
}
36+
37+
#english,
38+
& #hindi {
39+
scroll-margin-top: calc(var(--header-height) + 80px);
40+
}
41+
}

src/components/Letter.astro

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,6 @@ const {
1111
---
1212

1313
<div class="letter">
14-
<p>{letter}</p>
15-
<p data-id="tgt" class="code">{code}</p>
16-
</div>
17-
18-
<script>
19-
const tgt = document.querySelectorAll("[data-id]");
20-
tgt?.forEach((elm) =>
21-
elm.addEventListener("click", (e: any) => {
22-
console.log("Hello, on client", e?.target?.textContent);
23-
})
24-
);
25-
</script>
14+
<p class="character">{letter}</p>
15+
<p data-id="tgt" class="code" title="Click to copy">{code}</p>
16+
</div>

src/pages/varnmala.astro

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
---
22
import Alphabet from "@/components/Alphabet.astro";
3+
import "@/assets/styles/varnmala.css";
34
import Help from "@/components/Help.astro";
45
import BaseLayout from "@/layouts/Base";
56
import { varnmala_english, varnmala_hindi } from "@/utils/common";
@@ -12,14 +13,39 @@ import { varnmala_english, varnmala_hindi } from "@/utils/common";
1213
description="Varnmala is a collection of alphabets in Hindi and English. It is used to teach kids the basics of language."
1314
/>
1415
</Fragment>
16+
1517
<article class="container__varnmala">
16-
<Alphabet list={varnmala_english} title="English" />
17-
<Alphabet list={varnmala_hindi} title="Hindi" />
18+
<nav class="tabs">
19+
<button class="tab active" data-target="english">English</button>
20+
<button class="tab" data-target="hindi">Hindi</button>
21+
</nav>
22+
<div id="english">
23+
<Alphabet list={varnmala_english} title="English" />
24+
</div>
25+
<div id="hindi">
26+
<Alphabet list={varnmala_hindi} title="Hindi" />
27+
</div>
1828
</article>
29+
<script>
30+
const tabs = document.querySelectorAll(".tab");
31+
32+
tabs.forEach((tab) => {
33+
tab.addEventListener("click", () => {
34+
// Remove active class from all tabs
35+
tabs.forEach((t) => t.classList.remove("active"));
36+
37+
// Add active class to clicked tab
38+
tab.classList.add("active");
1939

20-
<style>
21-
.container__varnmala {
22-
display: block;
23-
}
24-
</style>
40+
// Scroll to target section with offset
41+
const targetId = tab.getAttribute("data-target");
42+
if (targetId) {
43+
const targetSection = document.getElementById(targetId);
44+
if (targetSection) {
45+
targetSection.scrollIntoView({ behavior: "smooth" });
46+
}
47+
}
48+
});
49+
});
50+
</script>
2551
</BaseLayout>

0 commit comments

Comments
 (0)