Skip to content

Commit 118b2c1

Browse files
committed
feat: add modal for glossary definitions and fix stubs link typo
Signed-off-by: Kunal-Darekar <[email protected]>
1 parent dbc83b9 commit 118b2c1

File tree

2 files changed

+55
-21
lines changed

2 files changed

+55
-21
lines changed

src/components/GlossaryCard.js

Lines changed: 53 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,60 @@
1-
import React from "react";
1+
import React, { useState } from "react";
22
import ArrowUpRight from "../../static/img/ArrowUpRight.svg";
33

4-
const GlossaryCard = ({name, description, link}) => {
4+
const GlossaryCard = ({ name, description, link }) => {
5+
const [open, setOpen] = useState(false);
6+
57
return (
6-
<a
7-
href={link}
8-
className="group flex h-full flex-col rounded-xl border border-transparent bg-[var(--ifm-card-background-color)] p-6 shadow-[0_4px_12px_var(--ifm-card-shadow-color)] transition-all duration-300 hover:border-[var(--ifm-color-primary)] hover:shadow-[0_8px_20px_var(--ifm-card-shadow-color)] focus:outline-none focus:ring-2 focus:ring-[var(--ifm-color-primary)] focus:ring-offset-2
9-
"
10-
>
11-
<div className="mb-3 flex items-start justify-between">
12-
<h3 className="pr-4 text-xl font-bold text-[var(--ifm-color-primary)]">
13-
{name}
14-
</h3>
15-
<ArrowUpRight
16-
className=" flex-shrink-0 text-[var(--ifm-color-emphasis-500)] transition-all duration-300 ease-in-out group-hover:rotate-45 group-hover:text-[var(--ifm-color-primary)]"
17-
size={22}
18-
/>
8+
<>
9+
<div
10+
tabIndex={0}
11+
role="button"
12+
onClick={() => setOpen(true)}
13+
onKeyPress={e => (e.key === 'Enter' || e.key === ' ') && setOpen(true)}
14+
className="group flex h-full flex-col rounded-xl border border-transparent bg-[var(--ifm-card-background-color)] p-6 shadow-[0_4px_12px_var(--ifm-card-shadow-color)] transition-all duration-300 hover:border-[var(--ifm-color-primary)] hover:shadow-[0_8px_20px_var(--ifm-card-shadow-color)] focus:outline-none focus:ring-2 focus:ring-[var(--ifm-color-primary)] focus:ring-offset-2 cursor-pointer"
15+
aria-label={`Show definition for ${name}`}
16+
>
17+
<div className="mb-3 flex items-start justify-between">
18+
<h3 className="pr-4 text-xl font-bold text-[var(--ifm-color-primary)]">
19+
{name}
20+
</h3>
21+
<ArrowUpRight
22+
className=" flex-shrink-0 text-[var(--ifm-color-emphasis-500)] transition-all duration-300 ease-in-out group-hover:rotate-45 group-hover:text-[var(--ifm-color-primary)]"
23+
size={22}
24+
/>
25+
</div>
26+
<p className="text-sm leading-relaxed text-[var(--ifm-color-emphasis-700)]">
27+
{description}
28+
</p>
1929
</div>
20-
<p className="text-sm leading-relaxed text-[var(--ifm-color-emphasis-700)]">
21-
{description}
22-
</p>
23-
</a>
30+
{open && (
31+
<div className="fixed inset-0 z-50 flex items-center justify-center bg-black bg-opacity-40" onClick={() => setOpen(false)}>
32+
<div
33+
className="bg-white rounded-lg shadow-xl p-8 max-w-md w-full relative"
34+
onClick={e => e.stopPropagation()}
35+
>
36+
<button
37+
className="absolute top-2 right-2 text-gray-500 hover:text-gray-800 text-2xl font-bold"
38+
onClick={() => setOpen(false)}
39+
aria-label="Close"
40+
>
41+
×
42+
</button>
43+
<h2 className="text-2xl font-bold mb-4 text-[var(--ifm-color-primary)]">{name}</h2>
44+
<p className="mb-6 text-[var(--ifm-color-emphasis-700)]">{description}</p>
45+
<a
46+
href={link}
47+
target="_blank"
48+
rel="noopener noreferrer"
49+
className="inline-flex items-center gap-2 rounded bg-[var(--ifm-color-primary)] px-4 py-2 font-semibold text-white hover:bg-[var(--ifm-color-primary-darker)] transition-colors"
50+
>
51+
Read more
52+
<ArrowUpRight size={18} />
53+
</a>
54+
</div>
55+
</div>
56+
)}
57+
</>
2458
);
2559
};
2660

static/data/glossaryEntries.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,13 +104,13 @@ export const glossaryEntries = {
104104
{
105105
name: "Regression Testing",
106106
link: "/docs/concepts/reference/glossary/regression-testing",
107-
description: "Ensures new code doesnt break old features.",
107+
description: "Ensures new code doesn't break old features.",
108108
},
109109
],
110110
S: [
111111
{
112112
name: "Stubs",
113-
ink: "/docs/concepts/reference/glossary/stubs",
113+
link: "/docs/concepts/reference/glossary/stubs",
114114
description: "Simulates methods or APIs during testing.",
115115
},
116116
{

0 commit comments

Comments
 (0)