Skip to content

Commit 2337f8e

Browse files
committed
refactor(website): fix mechanics card semantics and onSelect item signature
1 parent 35a91aa commit 2337f8e

3 files changed

Lines changed: 35 additions & 17 deletions

File tree

‎website/components/feature/FeatureHero.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export function FeatureHero({ eyebrow, title, subtitle, ctaText, ctaHref = "/dow
3131
<SectionReveal delay={0.15}>
3232
<Link
3333
href={ctaHref}
34-
className="inline-block px-10 py-4 rounded-2xl text-white font-medium text-lg transition-all duration-500 hover:scale-[1.05] active:scale-[0.97]"
34+
className="inline-block px-10 py-4 rounded-2xl text-white font-medium text-lg transition-all duration-500 hover:scale-[1.05] active:scale-[0.97] focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-kb-brand"
3535
style={{
3636
background: "linear-gradient(135deg, var(--kb-amber), var(--kb-accent-400))",
3737
boxShadow: "var(--kb-shadow-accent)",

‎website/components/feature/FeatureMechanics.tsx‎

Lines changed: 33 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,12 @@ interface FeatureMechanicsProps {
1010
title: string;
1111
hint?: string;
1212
items: FeatureMechanicsItem[];
13-
onSelect?: (index: number) => void;
13+
onSelect?: (item: FeatureMechanicsItem) => void;
1414
}
1515

16+
const CARD_CLASS =
17+
"w-full h-full text-left rounded-3xl p-6 transition-all duration-500 hover:-translate-y-1";
18+
1619
export function FeatureMechanics({ title, hint, items, onSelect }: FeatureMechanicsProps) {
1720
return (
1821
<section className="max-w-4xl mx-auto px-6 mb-24">
@@ -23,20 +26,35 @@ export function FeatureMechanics({ title, hint, items, onSelect }: FeatureMechan
2326
<div className="grid sm:grid-cols-2 lg:grid-cols-3 gap-5">
2427
{items.map((item, i) => (
2528
<SectionReveal key={item.key ?? item.name} delay={i * 0.06}>
26-
<button
27-
type="button"
28-
onClick={() => onSelect?.(i)}
29-
className="w-full h-full text-left rounded-3xl p-6 transition-all duration-500 hover:-translate-y-1 cursor-pointer"
30-
style={{
31-
background: "var(--kb-bg-elevated)",
32-
border: "1px solid var(--kb-glass-border)",
33-
boxShadow: "var(--kb-shadow-card)",
34-
}}
35-
>
36-
<span className="text-2xl">{item.icon}</span>
37-
<h3 className="font-serif text-lg font-semibold text-kb-text mt-3 mb-2">{item.name}</h3>
38-
<p className="text-sm text-kb-text2 leading-relaxed">{item.desc}</p>
39-
</button>
29+
{onSelect ? (
30+
<button
31+
type="button"
32+
onClick={() => onSelect(item)}
33+
className={`${CARD_CLASS} cursor-pointer focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-kb-brand`}
34+
style={{
35+
background: "var(--kb-bg-elevated)",
36+
border: "1px solid var(--kb-glass-border)",
37+
boxShadow: "var(--kb-shadow-card)",
38+
}}
39+
>
40+
<span className="text-2xl">{item.icon}</span>
41+
<span className="font-serif text-lg font-semibold text-kb-text mt-3 mb-2 block">{item.name}</span>
42+
<p className="text-sm text-kb-text2 leading-relaxed">{item.desc}</p>
43+
</button>
44+
) : (
45+
<div
46+
className={CARD_CLASS}
47+
style={{
48+
background: "var(--kb-bg-elevated)",
49+
border: "1px solid var(--kb-glass-border)",
50+
boxShadow: "var(--kb-shadow-card)",
51+
}}
52+
>
53+
<span className="text-2xl">{item.icon}</span>
54+
<span className="font-serif text-lg font-semibold text-kb-text mt-3 mb-2 block">{item.name}</span>
55+
<p className="text-sm text-kb-text2 leading-relaxed">{item.desc}</p>
56+
</div>
57+
)}
4058
</SectionReveal>
4159
))}
4260
</div>

‎website/components/feature/FeatureTrust.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ export function FeatureTrust() {
6666
href="https://github.com/Aparencia/Entropydecrease"
6767
target="_blank"
6868
rel="noopener noreferrer"
69-
className="inline-flex items-center gap-2 text-kb-brand font-medium transition-all duration-400 hover:gap-3.5"
69+
className="inline-flex items-center gap-2 text-kb-brand font-medium transition-all duration-400 hover:gap-3.5 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-kb-brand"
7070
>
7171
GitHub 仓库 · 开发全程公开 ↗
7272
</a>

0 commit comments

Comments
 (0)