Skip to content

Commit 3f20bc3

Browse files
authored
Merge pull request #1015 from supertokens/fix/light-mode
2 parents 213c95c + 74e0fcb commit 3f20bc3

File tree

6 files changed

+100
-26
lines changed

6 files changed

+100
-26
lines changed

src/components/MenuItemIcon.tsx

Lines changed: 20 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,14 @@ import useBaseUrl from "@docusaurus/useBaseUrl";
33
import {
44
Book,
55
Zap,
6+
HousePlus,
7+
ShieldUser,
8+
Braces,
69
Key,
10+
LayoutDashboard,
711
Shield,
8-
GitPullRequest,
912
CircleUserRound,
13+
UserPlus,
1014
FileTerminal,
1115
FileCode,
1216
HardDrive,
@@ -15,45 +19,27 @@ import {
1519
ArrowRight,
1620
Settings,
1721
Server,
18-
Mail,
22+
WandSparkles,
23+
FileUser,
1924
Smartphone,
2025
Share2,
2126
Building,
2227
RectangleEllipsis,
2328
Bot,
24-
Layers,
2529
Fingerprint,
26-
MailCheck,
2730
ShieldCheck,
2831
Clock,
2932
UserCheck,
30-
ShieldAlert,
31-
Timer,
32-
UserCog,
33-
Link,
34-
BarChart3,
3533
Puzzle,
36-
Cloud,
37-
Triangle,
38-
Database,
3934
Workflow,
40-
Globe,
41-
Folder,
42-
FileText,
4335
Monitor,
44-
Code,
4536
Bug,
46-
Wrench,
4737
Palette,
48-
FlaskConical,
49-
BookOpenCheck,
5038
Cpu,
5139
Hash,
5240
History,
53-
Construction,
5441
Play,
55-
ChevronRight,
56-
Lightbulb,
42+
MailCheck,
5743
} from "lucide-react";
5844

5945
import VercelLogo from "/img/logos/vercel.svg";
@@ -80,7 +66,7 @@ const categoryIcons = {
8066

8167
// Authentication methods
8268
"Email Password": RectangleEllipsis,
83-
Passwordless: Smartphone,
69+
Passwordless: WandSparkles,
8470
"Social Login": CircleUserRound,
8571
"Enterprise Login": Building,
8672
"Unified Login": Share2,
@@ -108,7 +94,7 @@ const categoryIcons = {
10894
"SuperTokens Core": Cpu,
10995

11096
// Authentication reference subcategories
111-
"Email/Password": Mail,
97+
"Email/Password": RectangleEllipsis,
11298
ThirdParty: Share2,
11399
WebAuthn: Fingerprint,
114100
OAuth: Key,
@@ -118,6 +104,16 @@ const categoryIcons = {
118104
OTP: Smartphone,
119105
SAML: Building,
120106

107+
// CDI/FDI
108+
"Email Verification": MailCheck,
109+
"Account Linking": FileUser,
110+
"Bulk Import": UserPlus,
111+
Core: Cpu,
112+
Dashboard: LayoutDashboard,
113+
"User Metadata": Braces,
114+
"User Roles": ShieldUser,
115+
Multitenancy: HousePlus,
116+
121117
// Quickstart guides and workflows
122118
"Quickstart Guides": Zap,
123119
"Advanced Workflows": Workflow,

src/components/ScrollOffsetFix.tsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { useEffect } from 'react';
2+
import { initScrollOffset } from '../lib/scrollOffset';
3+
4+
export function ScrollOffsetFix() {
5+
useEffect(() => {
6+
initScrollOffset();
7+
}, []);
8+
9+
return null; // This component doesn't render anything
10+
}
11+
12+
export default ScrollOffsetFix;

src/css/custom.scss

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,12 @@
3030

3131
// Navbar customization
3232
--ifm-navbar-height: 122px;
33+
// Total navbar height including tabs and padding for accurate scroll positioning
34+
--navbar-total-height: 140px;
3335

3436
@media (max-width: 996px) {
3537
--ifm-navbar-height: 80px;
38+
--navbar-total-height: 80px; // No tabs on mobile
3639
}
3740

3841
// Doc Sidebar

src/lib/scrollOffset.ts

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
export function getNavbarHeight(): number {
2+
if (typeof window === "undefined") return 140;
3+
4+
const navbar = document.querySelector("nav.navbar");
5+
if (!navbar) return 140;
6+
7+
const height = navbar.getBoundingClientRect().height;
8+
return height;
9+
}
10+
11+
function scrollToElementWithOffset(element: Element): void {
12+
const navbarHeight = getNavbarHeight();
13+
const elementRect = element.getBoundingClientRect();
14+
const absoluteElementTop = elementRect.top + window.pageYOffset;
15+
const targetScrollTop = absoluteElementTop - navbarHeight - 16;
16+
17+
window.scrollTo({
18+
top: targetScrollTop,
19+
behavior: "smooth",
20+
});
21+
}
22+
23+
function handleHashNavigation(): void {
24+
if (typeof window === "undefined") return;
25+
26+
const hash = window.location.hash;
27+
if (!hash) return;
28+
29+
const targetId = hash.substring(1);
30+
const targetElement = document.getElementById(targetId);
31+
32+
if (targetElement) {
33+
setTimeout(() => {
34+
scrollToElementWithOffset(targetElement);
35+
}, 100);
36+
}
37+
}
38+
39+
function handleHashLinkClick(event: Event): void {
40+
const target = event.target as HTMLElement;
41+
const link = target.closest('a[href^="#"]') as HTMLAnchorElement;
42+
43+
if (!link || !link.hash) return;
44+
45+
const targetId = link.hash.substring(1);
46+
const targetElement = document.getElementById(targetId);
47+
48+
if (targetElement) {
49+
event.preventDefault();
50+
history.pushState(null, "", link.hash);
51+
scrollToElementWithOffset(targetElement);
52+
}
53+
}
54+
55+
export function initScrollOffset(): void {
56+
if (typeof window === "undefined") return;
57+
58+
setTimeout(handleHashNavigation, 100);
59+
setTimeout(handleHashNavigation, 500);
60+
window.addEventListener("hashchange", handleHashNavigation);
61+
document.addEventListener("click", handleHashLinkClick);
62+
}
63+

src/theme/Layout/index.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import ErrorPageContent from "@theme/ErrorPageContent";
1313
import supertokens from "supertokens-website";
1414
import type { Props } from "@theme/Layout";
1515
import styles from "./styles.module.css";
16+
import ScrollOffsetFix from "@site/src/components/ScrollOffsetFix";
1617

1718
if (typeof window !== "undefined") {
1819
const isProdEnv =
@@ -51,6 +52,7 @@ export default function Layout(props: Props): JSX.Element {
5152
return (
5253
<LayoutProvider>
5354
<PageMetadata title={title} description={description} />
55+
<ScrollOffsetFix />
5456

5557
<SkipToContent />
5658

src/theme/Root.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ export default function Root({ children }: { children: React.ReactNode }) {
1818
init();
1919
}, []);
2020

21-
useLayoutEffect(() => {}, []);
22-
2321
useEffect(() => {
2422
trackPageView();
2523
}, [pathname]);

0 commit comments

Comments
 (0)