-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLuxeVocabPage.jsx
More file actions
179 lines (164 loc) · 6.62 KB
/
LuxeVocabPage.jsx
File metadata and controls
179 lines (164 loc) · 6.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
import React, { useState, useMemo } from 'react';
import {
MagnifyingGlassIcon,
ArrowUpRightIcon,
ArrowLeftIcon,
} from '@phosphor-icons/react';
import { Link } from 'react-router-dom';
import Seo from '../../components/Seo';
import { vocabulary } from '../../data/vocabulary';
import { useSidePanel } from '../../context/SidePanelContext';
const LuxeVocabPage = () => {
const [searchQuery, setSearchQuery] = useState('');
const { openSidePanel } = useSidePanel();
const vocabEntries = useMemo(
() =>
Object.entries(vocabulary)
.map(([slug, data]) => ({
slug,
...data,
}))
.sort((a, b) => a.title.localeCompare(b.title)),
[],
);
const filteredEntries = useMemo(() => {
const query = searchQuery.toLowerCase().trim();
if (!query) return vocabEntries;
return vocabEntries.filter(
(entry) =>
entry.title.toLowerCase().includes(query) ||
entry.slug.toLowerCase().includes(query),
);
}, [vocabEntries, searchQuery]);
const groupedEntries = useMemo(() => {
const groups = {};
filteredEntries.forEach((entry) => {
const firstLetter = entry.title.charAt(0).toUpperCase();
if (!groups[firstLetter]) groups[firstLetter] = [];
groups[firstLetter].push(entry);
});
return groups;
}, [filteredEntries]);
const alphabet = useMemo(
() => Object.keys(groupedEntries).sort(),
[groupedEntries],
);
const handleOpenVocab = (entry) => {
const LazyComponent = React.lazy(entry.loader);
openSidePanel(entry.title, <LazyComponent />, 600);
};
const scrollToLetter = (letter) => {
const element = document.getElementById(`letter-${letter}`);
if (element) {
window.scrollTo({
top: element.offsetTop - 120,
behavior: 'smooth',
});
}
};
return (
<div className="min-h-screen bg-[#F5F5F0] text-[#1A1A1A] font-sans selection:bg-[#C0B298] selection:text-black pt-24 pb-20">
<Seo title="Fezcodex | Lexicon" description="Digital Glossary." />
<div className="max-w-[1400px] mx-auto px-6 md:px-12">
<header className="mb-20 pt-12 border-b border-[#1A1A1A]/10 pb-12">
<Link
to="/"
className="inline-flex items-center gap-2 mb-8 font-outfit text-xs uppercase tracking-widest text-[#1A1A1A]/40 hover:text-[#8D4004] transition-colors"
>
<ArrowLeftIcon /> Home
</Link>
<h1 className="font-playfairDisplay text-7xl md:text-9xl text-[#1A1A1A] mb-6">
Lexicon
</h1>
<div className="flex flex-col md:flex-row justify-between items-end gap-8">
<p className="font-outfit text-sm text-[#1A1A1A]/60 max-w-lg leading-relaxed">
A compendium of terminology and defined concepts within the
system. Curated for clarity and architectural precision.
</p>
<div className="relative group border-b border-[#1A1A1A]/20 focus-within:border-[#1A1A1A] transition-colors min-w-[300px]">
<input
type="text"
placeholder="Search Lexicon..."
value={searchQuery}
onChange={(e) => setSearchQuery(e.target.value)}
className="w-full bg-transparent py-2 outline-none font-outfit text-sm placeholder-[#1A1A1A]/30"
/>
<MagnifyingGlassIcon className="absolute right-0 top-1/2 -translate-y-1/2 text-[#1A1A1A]/40" />
</div>
</div>
</header>
{/* Alphabet Navigation */}
<div className="sticky top-24 z-20 mb-16 py-4 bg-[#F5F5F0]/80 backdrop-blur-md border-y border-[#1A1A1A]/5">
<div className="flex flex-wrap gap-2 md:gap-4 justify-center">
{alphabet.map((letter) => (
<button
key={letter}
onClick={() => scrollToLetter(letter)}
className="w-8 h-8 flex items-center justify-center font-outfit text-xs uppercase tracking-widest text-[#1A1A1A]/40 hover:text-[#8D4004] hover:bg-white rounded-full transition-all"
>
{letter}
</button>
))}
</div>
</div>
<div className="space-y-32">
{alphabet.map((letter) => (
<section
key={letter}
id={`letter-${letter}`}
className="scroll-mt-48"
>
<div className="flex items-baseline gap-8 mb-12 border-b border-[#1A1A1A]/5 pb-4">
<span className="font-playfairDisplay text-6xl md:text-8xl text-[#1A1A1A]/10 italic">
{letter}
</span>
</div>
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-x-12 gap-y-16">
{groupedEntries[letter].map((entry) => (
<button
key={entry.slug}
onClick={() => handleOpenVocab(entry)}
className="group text-left space-y-4"
>
<div className="flex items-center justify-between border-b border-[#1A1A1A]/5 pb-2">
<span className="font-outfit text-[10px] uppercase tracking-widest text-[#8D4004]">
{entry.slug}
</span>
<ArrowUpRightIcon
size={16}
className="text-[#1A1A1A]/20 group-hover:text-[#8D4004] group-hover:translate-x-1 group-hover:-translate-y-1 transition-all"
/>
</div>
<h3 className="font-playfairDisplay text-3xl text-[#1A1A1A] group-hover:italic transition-all leading-tight">
{entry.title}
</h3>
{entry.tags && (
<div className="flex flex-wrap gap-2 pt-2">
{entry.tags.map((tag) => (
<span
key={tag}
className="text-[9px] font-outfit uppercase tracking-[0.2em] text-[#1A1A1A]/30"
>
#{tag}
</span>
))}
</div>
)}
</button>
))}
</div>
</section>
))}
</div>
{filteredEntries.length === 0 && (
<div className="py-32 text-center">
<p className="font-playfairDisplay italic text-2xl text-[#1A1A1A]/40">
No definitions found for "{searchQuery}"
</p>
</div>
)}
</div>
</div>
);
};
export default LuxeVocabPage;