@becklyn/next 2.1.4 → 3.0.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.
@@ -0,0 +1,9 @@
1
+ type Query = `(min-width: ${number}px)` | `(max-width: ${number}px)` | `(min-width: ${number}px) and (max-width: ${number}px)`;
2
+ /**
3
+ * Hook to track media query state
4
+ * @param query - The media query string (e.g., "(min-width: 1024px)")
5
+ * @returns boolean indicating if the media query matches
6
+ */
7
+ export declare const useMediaQuery: (query: Query) => boolean;
8
+ export {};
9
+ //# sourceMappingURL=useMediaQuery.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useMediaQuery.d.ts","sourceRoot":"","sources":["../../../lib/useMediaQuery.ts"],"names":[],"mappings":"AAIA,KAAK,KAAK,GACJ,eAAe,MAAM,KAAK,GAC1B,eAAe,MAAM,KAAK,GAC1B,eAAe,MAAM,uBAAuB,MAAM,KAAK,CAAC;AAE9D;;;;GAIG;AACH,eAAO,MAAM,aAAa,GAAI,OAAO,KAAK,KAAG,OAqC5C,CAAC"}
@@ -0,0 +1,41 @@
1
+ "use client";
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.useMediaQuery = void 0;
5
+ const react_1 = require("react");
6
+ /**
7
+ * Hook to track media query state
8
+ * @param query - The media query string (e.g., "(min-width: 1024px)")
9
+ * @returns boolean indicating if the media query matches
10
+ */
11
+ const useMediaQuery = (query) => {
12
+ // Default to false for SSR to prevent hydration mismatch
13
+ const [matches, setMatches] = (0, react_1.useState)(false);
14
+ const currentMatches = (0, react_1.useRef)(matches);
15
+ (0, react_1.useEffect)(() => {
16
+ // Only run on client side
17
+ if (typeof window === "undefined") {
18
+ return;
19
+ }
20
+ const mediaQuery = window.matchMedia(query);
21
+ // Set initial value
22
+ setMatches(mediaQuery.matches);
23
+ currentMatches.current = mediaQuery.matches;
24
+ // Create event listener
25
+ const handleChange = (event) => {
26
+ const newMatch = event.matches;
27
+ if (newMatch !== currentMatches.current) {
28
+ setMatches(newMatch);
29
+ currentMatches.current = newMatch;
30
+ }
31
+ };
32
+ // Add event listener
33
+ mediaQuery.addEventListener("change", handleChange);
34
+ // Cleanup
35
+ return () => {
36
+ mediaQuery.removeEventListener("change", handleChange);
37
+ };
38
+ }, [query]);
39
+ return matches;
40
+ };
41
+ exports.useMediaQuery = useMediaQuery;
@@ -0,0 +1,9 @@
1
+ type Query = `(min-width: ${number}px)` | `(max-width: ${number}px)` | `(min-width: ${number}px) and (max-width: ${number}px)`;
2
+ /**
3
+ * Hook to track media query state
4
+ * @param query - The media query string (e.g., "(min-width: 1024px)")
5
+ * @returns boolean indicating if the media query matches
6
+ */
7
+ export declare const useMediaQuery: (query: Query) => boolean;
8
+ export {};
9
+ //# sourceMappingURL=useMediaQuery.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useMediaQuery.d.ts","sourceRoot":"","sources":["../../../lib/useMediaQuery.ts"],"names":[],"mappings":"AAIA,KAAK,KAAK,GACJ,eAAe,MAAM,KAAK,GAC1B,eAAe,MAAM,KAAK,GAC1B,eAAe,MAAM,uBAAuB,MAAM,KAAK,CAAC;AAE9D;;;;GAIG;AACH,eAAO,MAAM,aAAa,GAAI,OAAO,KAAK,KAAG,OAqC5C,CAAC"}
@@ -0,0 +1,41 @@
1
+ "use client";
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.useMediaQuery = void 0;
5
+ const react_1 = require("react");
6
+ /**
7
+ * Hook to track media query state
8
+ * @param query - The media query string (e.g., "(min-width: 1024px)")
9
+ * @returns boolean indicating if the media query matches
10
+ */
11
+ const useMediaQuery = (query) => {
12
+ // Default to false for SSR to prevent hydration mismatch
13
+ const [matches, setMatches] = (0, react_1.useState)(false);
14
+ const currentMatches = (0, react_1.useRef)(matches);
15
+ (0, react_1.useEffect)(() => {
16
+ // Only run on client side
17
+ if (typeof window === "undefined") {
18
+ return;
19
+ }
20
+ const mediaQuery = window.matchMedia(query);
21
+ // Set initial value
22
+ setMatches(mediaQuery.matches);
23
+ currentMatches.current = mediaQuery.matches;
24
+ // Create event listener
25
+ const handleChange = (event) => {
26
+ const newMatch = event.matches;
27
+ if (newMatch !== currentMatches.current) {
28
+ setMatches(newMatch);
29
+ currentMatches.current = newMatch;
30
+ }
31
+ };
32
+ // Add event listener
33
+ mediaQuery.addEventListener("change", handleChange);
34
+ // Cleanup
35
+ return () => {
36
+ mediaQuery.removeEventListener("change", handleChange);
37
+ };
38
+ }, [query]);
39
+ return matches;
40
+ };
41
+ exports.useMediaQuery = useMediaQuery;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@becklyn/next",
3
- "version": "2.1.4",
3
+ "version": "3.0.0",
4
4
  "license": "MIT",
5
5
  "homepage": "https://github.com/Becklyn-Studios/ts-libs/tree/main/packages/next",
6
6
  "repository": {
package/scss/mixins.scss CHANGED
@@ -1,5 +1,4 @@
1
1
  @forward "./animation.scss";
2
- @forward "./breakpoints.scss";
3
2
  @forward "./interaction.scss";
4
3
  @forward "./sizing.scss";
5
4
  @forward "./fill.scss";
@@ -1,23 +0,0 @@
1
- @mixin tablet {
2
- @media (min-width: 744px) {
3
- @content;
4
- }
5
- }
6
-
7
- @mixin large-tablet {
8
- @media (min-width: 1024px) {
9
- @content;
10
- }
11
- }
12
-
13
- @mixin desktop {
14
- @media (min-width: 1440px) {
15
- @content;
16
- }
17
- }
18
-
19
- @mixin large-desktop {
20
- @media (min-width: 1920px) {
21
- @content;
22
- }
23
- }