@checkstack/theme-frontend 0.1.27 → 0.1.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +9 -0
- package/package.json +1 -1
- package/src/components/NavbarPerformanceToggle.tsx +39 -0
- package/src/index.tsx +7 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# @checkstack/theme-frontend
|
|
2
2
|
|
|
3
|
+
## 0.1.28
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 286491a: Added automatic FPS detection that enables "Low Power Mode" once for devices running below 50 FPS, ensuring smooth performance even for users unaware of the manual toggle.
|
|
8
|
+
- Updated dependencies [286491a]
|
|
9
|
+
- @checkstack/ui@1.3.5
|
|
10
|
+
- @checkstack/auth-frontend@0.5.24
|
|
11
|
+
|
|
3
12
|
## 0.1.27
|
|
4
13
|
|
|
5
14
|
### Patch Changes
|
package/package.json
CHANGED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Zap, ZapOff } from "lucide-react";
|
|
3
|
+
import { useApi } from "@checkstack/frontend-api";
|
|
4
|
+
import { authApiRef } from "@checkstack/auth-frontend/api";
|
|
5
|
+
import { Button, usePerformance } from "@checkstack/ui";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Navbar performance toggle button for non-logged-in users.
|
|
9
|
+
*
|
|
10
|
+
* Shows a Zap icon button that toggles between high and low performance modes.
|
|
11
|
+
* Only renders when user is NOT logged in (logged-in users use the toggle in UserMenu).
|
|
12
|
+
*/
|
|
13
|
+
export const NavbarPerformanceToggle = () => {
|
|
14
|
+
const { manualLowPower, toggleManualLowPower } = usePerformance();
|
|
15
|
+
const authApi = useApi(authApiRef);
|
|
16
|
+
const { data: session, isPending } = authApi.useSession();
|
|
17
|
+
|
|
18
|
+
// Don't render while loading session
|
|
19
|
+
if (isPending) {
|
|
20
|
+
return <React.Fragment />;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// Don't render for logged-in users (they use UserMenu toggle)
|
|
24
|
+
if (session?.user) {
|
|
25
|
+
return <React.Fragment />;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return (
|
|
29
|
+
<Button
|
|
30
|
+
variant="ghost"
|
|
31
|
+
size="icon"
|
|
32
|
+
onClick={toggleManualLowPower}
|
|
33
|
+
aria-label={manualLowPower ? "Switch to high performance" : "Switch to low power mode"}
|
|
34
|
+
className="rounded-full"
|
|
35
|
+
>
|
|
36
|
+
{manualLowPower ? <ZapOff className="h-5 w-5 text-muted-foreground" /> : <Zap className="h-5 w-5 text-primary" />}
|
|
37
|
+
</Button>
|
|
38
|
+
);
|
|
39
|
+
};
|
package/src/index.tsx
CHANGED
|
@@ -8,6 +8,7 @@ import { ThemeToggleMenuItem } from "./components/ThemeToggleMenuItem";
|
|
|
8
8
|
import { PerformanceToggleMenuItem } from "./components/PerformanceToggleMenuItem";
|
|
9
9
|
import { ThemeSynchronizer } from "./components/ThemeSynchronizer";
|
|
10
10
|
import { NavbarThemeToggle } from "./components/NavbarThemeToggle";
|
|
11
|
+
import { NavbarPerformanceToggle } from "./components/NavbarPerformanceToggle";
|
|
11
12
|
|
|
12
13
|
export const themePlugin = createFrontendPlugin({
|
|
13
14
|
metadata: pluginMetadata,
|
|
@@ -37,5 +38,11 @@ export const themePlugin = createFrontendPlugin({
|
|
|
37
38
|
slot: NavbarRightSlot,
|
|
38
39
|
component: NavbarThemeToggle,
|
|
39
40
|
},
|
|
41
|
+
// Performance toggle button in navbar (for non-logged-in users)
|
|
42
|
+
{
|
|
43
|
+
id: "theme.navbar.performance.toggle",
|
|
44
|
+
slot: NavbarRightSlot,
|
|
45
|
+
component: NavbarPerformanceToggle,
|
|
46
|
+
},
|
|
40
47
|
],
|
|
41
48
|
});
|