@ichaingo/theme-toggle 1.1.0

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/README.md ADDED
@@ -0,0 +1,7 @@
1
+ # @ichaingo/theme-toggle
2
+
3
+ This library was generated with [Nx](https://nx.dev).
4
+
5
+ ## Running unit tests
6
+
7
+ Run `nx test @ichaingo/theme-toggle` to execute the unit tests via [Vitest](https://vitest.dev/).
@@ -0,0 +1,2 @@
1
+ export default function ThemeToggle(): import("react/jsx-runtime").JSX.Element;
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAOA,MAAM,CAAC,OAAO,UAAU,WAAW,4CAqClC"}
package/dist/index.js ADDED
@@ -0,0 +1,48 @@
1
+ 'use client';
2
+ import { jsxs as l, jsx as e } from "react/jsx-runtime";
3
+ import { twMerge as o } from "tailwind-merge";
4
+ import { Sun as m, Moon as u, Monitor as c } from "lucide-react";
5
+ import { useTheme as d } from "next-themes";
6
+ import { useRouter as p } from "next/navigation";
7
+ function y() {
8
+ const { theme: r, setTheme: n } = d(), i = p(), t = (s) => {
9
+ n(s);
10
+ const a = new URL(window.location.href);
11
+ a.searchParams.set("theme", s), i.replace(a.toString());
12
+ };
13
+ return /* @__PURE__ */ l("div", { className: "flex items-center gap-2", children: [
14
+ /* @__PURE__ */ e(
15
+ "button",
16
+ {
17
+ onClick: () => t("light"),
18
+ className: o("p-1 cursor-pointer rounded-full", r === "light" ? "bg-primary text-white" : "bg-module"),
19
+ "aria-label": "Light mode",
20
+ suppressHydrationWarning: !0,
21
+ children: /* @__PURE__ */ e(m, { className: "w-4 h-4" })
22
+ }
23
+ ),
24
+ /* @__PURE__ */ e(
25
+ "button",
26
+ {
27
+ onClick: () => t("dark"),
28
+ className: o("p-1 cursor-pointer rounded-full", r === "dark" ? "bg-primary text-white" : "bg-module"),
29
+ "aria-label": "Dark mode",
30
+ suppressHydrationWarning: !0,
31
+ children: /* @__PURE__ */ e(u, { className: "w-4 h-4" })
32
+ }
33
+ ),
34
+ /* @__PURE__ */ e(
35
+ "button",
36
+ {
37
+ onClick: () => t("system"),
38
+ className: o("p-1 cursor-pointer rounded-full", r === "system" ? "bg-primary text-white" : "bg-module"),
39
+ "aria-label": "System preference",
40
+ suppressHydrationWarning: !0,
41
+ children: /* @__PURE__ */ e(c, { className: "w-4 h-4" })
42
+ }
43
+ )
44
+ ] });
45
+ }
46
+ export {
47
+ y as default
48
+ };
package/package.json ADDED
@@ -0,0 +1,32 @@
1
+ {
2
+ "name": "@ichaingo/theme-toggle",
3
+ "version": "1.1.0",
4
+ "type": "module",
5
+ "main": "./dist/index.js",
6
+ "module": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ "./package.json": "./package.json",
10
+ ".": {
11
+ "types": "./dist/index.d.ts",
12
+ "import": "./dist/index.js",
13
+ "default": "./dist/index.js"
14
+ }
15
+ },
16
+ "files": [
17
+ "dist",
18
+ "!**/*.tsbuildinfo"
19
+ ],
20
+ "devDependencies": {
21
+ "rollup-plugin-preserve-use-client": "^1.0.0"
22
+ },
23
+ "peerDependencies": {
24
+ "react": "^19.1.0",
25
+ "react-dom": "^19.1.0",
26
+ "tailwind-merge": "^2.5.5",
27
+ "lucide-react": "^0.539.0",
28
+ "next-themes": "^0.4.4",
29
+ "next": "^15.1.6",
30
+ "@ichaingo/i18n": "1.1.0"
31
+ }
32
+ }