|
1 |
| -import React from "react"; |
| 1 | +import React, { useState } from "react"; |
2 | 2 | import ArrowUpRight from "../../static/img/ArrowUpRight.svg";
|
3 | 3 |
|
4 |
| -const GlossaryCard = ({name, description, link}) => { |
| 4 | +const GlossaryCard = ({ name, description, link }) => { |
| 5 | + const [open, setOpen] = useState(false); |
| 6 | + |
5 | 7 | 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> |
19 | 29 | </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 | + </> |
24 | 58 | );
|
25 | 59 | };
|
26 | 60 |
|
|
0 commit comments