react-responsive-tools 2.2.3 → 2.3.4

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.
Files changed (55) hide show
  1. package/dist/breakpoints.config.d.ts +3 -0
  2. package/dist/breakpoints.config.js +23 -0
  3. package/dist/breakpoints.config.js.map +1 -0
  4. package/dist/components/horizontal.d.ts +14 -0
  5. package/dist/components/horizontal.js +17 -0
  6. package/dist/components/horizontal.js.map +1 -0
  7. package/dist/functions/getBreakpoint.d.ts +3 -0
  8. package/dist/functions/getBreakpoint.js +8 -0
  9. package/dist/functions/getBreakpoint.js.map +1 -0
  10. package/dist/hooks/useBreakpoint.d.ts +5 -0
  11. package/dist/hooks/useBreakpoint.js +15 -0
  12. package/dist/hooks/useBreakpoint.js.map +1 -0
  13. package/dist/hooks/useVBreakpoint.d.ts +5 -0
  14. package/dist/hooks/useVBreakpoint.js +15 -0
  15. package/dist/hooks/useVBreakpoint.js.map +1 -0
  16. package/dist/hooks/useVariant.d.ts +2 -0
  17. package/dist/hooks/useVariant.js +4 -0
  18. package/dist/hooks/useVariant.js.map +1 -0
  19. package/{src/index.ts → dist/index.d.ts} +1 -9
  20. package/dist/index.js.map +1 -0
  21. package/dist/interfaces/TAdaptiveVariant.js +2 -0
  22. package/dist/interfaces/TAdaptiveVariant.js.map +1 -0
  23. package/dist/interfaces/TBreakpoint.d.ts +2 -0
  24. package/dist/interfaces/TBreakpoint.js +2 -0
  25. package/dist/interfaces/TBreakpoint.js.map +1 -0
  26. package/{src/interfaces/TBreakpoints.ts → dist/interfaces/TBreakpoints.d.ts} +2 -4
  27. package/dist/interfaces/TBreakpoints.js +2 -0
  28. package/dist/interfaces/TBreakpoints.js.map +1 -0
  29. package/dist/main.bundle.js +0 -0
  30. package/dist/scripts/copyDefaultConfig.js +1 -0
  31. package/dist/scripts/createConfig.mjs +1 -0
  32. package/dist/scripts/generateCustomBreakpointsSCSS.mjs +1 -0
  33. package/dist/scripts/generateSCSS.mjs +1 -0
  34. package/dist/scripts/generateTBreakpoint.mjs +1 -0
  35. package/package.json +3 -2
  36. package/src/breakpoints.config.ts +0 -25
  37. package/src/components/horizontal.tsx +0 -30
  38. package/src/default.config.mjs +0 -25
  39. package/src/functions/getBreakpoint.ts +0 -11
  40. package/src/hooks/useBreakpoint.ts +0 -20
  41. package/src/hooks/useVBreakpoint.ts +0 -20
  42. package/src/hooks/useVariant.ts +0 -5
  43. package/src/interfaces/TBreakpoint.ts +0 -20
  44. package/src/scripts/copyDefaultConfig.mjs +0 -22
  45. package/src/scripts/createConfig.mjs +0 -64
  46. package/src/scripts/generateCustomBreakpointsSCSS.mjs +0 -30
  47. package/src/scripts/generateSCSS.mjs +0 -107
  48. package/src/scripts/generateTBreakpoint.mjs +0 -30
  49. /package/{src → dist}/index.scss +0 -0
  50. /package/{src/interfaces/TAdaptiveVariant.ts → dist/interfaces/TAdaptiveVariant.d.ts} +0 -0
  51. /package/{src → dist}/scss/_custom-breakpoints.scss +0 -0
  52. /package/{src → dist}/scss/_horizontal-breakpoints.scss +0 -0
  53. /package/{src → dist}/scss/_horizontal.scss +0 -0
  54. /package/{src → dist}/scss/_vertical-breakpoints.scss +0 -0
  55. /package/{src → dist}/scss/_vertical.scss +0 -0
@@ -0,0 +1,3 @@
1
+ declare const HORIZONTAL_BREAKPOINTS: Record<string, string>;
2
+ declare const VERTICAL_BREAKPOINTS: Record<string, string>;
3
+ export { HORIZONTAL_BREAKPOINTS, VERTICAL_BREAKPOINTS };
@@ -0,0 +1,23 @@
1
+ // src/breakpoints.config.ts
2
+ const HORIZONTAL_BREAKPOINTS = {
3
+ "xs": "320px",
4
+ "sm": "576px",
5
+ "md": "768px",
6
+ "lg": "992px",
7
+ "lt": "1024px",
8
+ "ltm": "1200px",
9
+ "ltl": "1440px",
10
+ "xl": "1920px",
11
+ "xxl": "2560px",
12
+ "qxl": "3840px"
13
+ };
14
+ const VERTICAL_BREAKPOINTS = {
15
+ "xs": "600px",
16
+ "sm": "800px",
17
+ "md": "1000px",
18
+ "lg": "1200px",
19
+ "xl": "1600px",
20
+ "xxl": "1601px"
21
+ };
22
+ export { HORIZONTAL_BREAKPOINTS, VERTICAL_BREAKPOINTS };
23
+ //# sourceMappingURL=breakpoints.config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"breakpoints.config.js","sourceRoot":"","sources":["../src/breakpoints.config.ts"],"names":[],"mappings":"AAAA,4BAA4B;AAE5B,MAAM,sBAAsB,GAA2B;IACrD,IAAI,EAAE,OAAO;IACb,IAAI,EAAE,OAAO;IACb,IAAI,EAAE,OAAO;IACb,IAAI,EAAE,OAAO;IACb,IAAI,EAAE,QAAQ;IACd,KAAK,EAAE,QAAQ;IACf,KAAK,EAAE,QAAQ;IACf,IAAI,EAAE,QAAQ;IACd,KAAK,EAAE,QAAQ;IACf,KAAK,EAAE,QAAQ;CAChB,CAAC;AAEF,MAAM,oBAAoB,GAA2B;IACnD,IAAI,EAAE,OAAO;IACb,IAAI,EAAE,OAAO;IACb,IAAI,EAAE,QAAQ;IACd,IAAI,EAAE,QAAQ;IACd,IAAI,EAAE,QAAQ;IACd,KAAK,EAAE,QAAQ;CAChB,CAAC;AAEF,OAAO,EAAE,sBAAsB,EAAE,oBAAoB,EAAE,CAAC"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Created by westp on 15.05.2023
3
+ */
4
+ import React from "react";
5
+ import { TBreakpoint } from '../interfaces/TBreakpoint';
6
+ interface Props {
7
+ children: React.ReactNode;
8
+ }
9
+ interface ForComponentProps extends Props {
10
+ p: TBreakpoint | number;
11
+ }
12
+ export declare function For({ children, p }: ForComponentProps): React.ReactNode;
13
+ export declare function Before({ children, p }: ForComponentProps): React.ReactNode;
14
+ export {};
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Created by westp on 15.05.2023
3
+ */
4
+ import { useBreakpointDF, useBreakpointMF } from '../hooks/useBreakpoint';
5
+ export function For({ children, p }) {
6
+ const is = useBreakpointMF(p);
7
+ if (is)
8
+ return children;
9
+ return null;
10
+ }
11
+ export function Before({ children, p }) {
12
+ const is = useBreakpointDF(p);
13
+ if (is)
14
+ return children;
15
+ return null;
16
+ }
17
+ //# sourceMappingURL=horizontal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"horizontal.js","sourceRoot":"","sources":["../../src/components/horizontal.tsx"],"names":[],"mappings":"AAAA;;GAEG;AAKH,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAU1E,MAAM,UAAU,GAAG,CAAC,EAAC,QAAQ,EAAE,CAAC,EAAoB;IAClD,MAAM,EAAE,GAAG,eAAe,CAAC,CAAC,CAAC,CAAC;IAC9B,IAAI,EAAE;QAAE,OAAO,QAAQ,CAAC;IACxB,OAAO,IAAI,CAAC;AACd,CAAC;AAGD,MAAM,UAAU,MAAM,CAAC,EAAC,QAAQ,EAAE,CAAC,EAAoB;IACrD,MAAM,EAAE,GAAG,eAAe,CAAC,CAAC,CAAC,CAAC;IAC9B,IAAI,EAAE;QAAE,OAAO,QAAQ,CAAC;IACxB,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { TBreakpoint, TVerticalBreakpoint } from '../interfaces/TBreakpoint';
2
+ export default function getBreakpoint(b: TBreakpoint): string;
3
+ export declare function getVBreakpoint(b: TVerticalBreakpoint): string;
@@ -0,0 +1,8 @@
1
+ import { HORIZONTAL_BREAKPOINTS, VERTICAL_BREAKPOINTS } from '../breakpoints.config';
2
+ export default function getBreakpoint(b) {
3
+ return HORIZONTAL_BREAKPOINTS[b];
4
+ }
5
+ export function getVBreakpoint(b) {
6
+ return VERTICAL_BREAKPOINTS[b];
7
+ }
8
+ //# sourceMappingURL=getBreakpoint.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getBreakpoint.js","sourceRoot":"","sources":["../../src/functions/getBreakpoint.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,sBAAsB,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAGrF,MAAM,CAAC,OAAO,UAAU,aAAa,CAAC,CAAc;IAChD,OAAO,sBAAsB,CAAC,CAAC,CAAC,CAAC;AACrC,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,CAAsB;IACjD,OAAO,oBAAoB,CAAC,CAAC,CAAC,CAAC;AACnC,CAAC"}
@@ -0,0 +1,5 @@
1
+ import { TBreakpoint } from '../interfaces/TBreakpoint';
2
+ import { TAdaptiveVariant } from '../interfaces/TAdaptiveVariant';
3
+ export default function useBreakpoint(b: TBreakpoint | number, variant?: TAdaptiveVariant): boolean;
4
+ export declare function useBreakpointMF(b: TBreakpoint | number): boolean;
5
+ export declare function useBreakpointDF(b: TBreakpoint | number): boolean;
@@ -0,0 +1,15 @@
1
+ import { useMediaQuery } from 'react-responsive';
2
+ import useVariant from './useVariant';
3
+ import getBreakpoint from "../functions/getBreakpoint";
4
+ export default function useBreakpoint(b, variant = 'MtF') {
5
+ const _bp = typeof b === 'number' ? b + 'px' : getBreakpoint(b);
6
+ const v = useVariant(variant);
7
+ return useMediaQuery({ query: `(${v}-width: ${_bp})` });
8
+ }
9
+ export function useBreakpointMF(b) {
10
+ return useBreakpoint(b, 'MtF');
11
+ }
12
+ export function useBreakpointDF(b) {
13
+ return useBreakpoint(b, 'MtF');
14
+ }
15
+ //# sourceMappingURL=useBreakpoint.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useBreakpoint.js","sourceRoot":"","sources":["../../src/hooks/useBreakpoint.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAIjD,OAAO,UAAU,MAAM,cAAc,CAAC;AACtC,OAAO,aAAa,MAAM,4BAA4B,CAAC;AAEvD,MAAM,CAAC,OAAO,UAAU,aAAa,CAAC,CAAuB,EAAE,UAA4B,KAAK;IAC9F,MAAM,GAAG,GAAG,OAAO,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAE,aAAa,CAAC,CAAC,CAAC,CAAC;IACjE,MAAM,CAAC,GAAG,UAAU,CAAC,OAAO,CAAC,CAAC;IAC9B,OAAO,aAAa,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,WAAW,GAAG,GAAG,EAAE,CAAC,CAAC;AAC1D,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,CAAuB;IACrD,OAAO,aAAa,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;AACjC,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,CAAuB;IACrD,OAAO,aAAa,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;AACjC,CAAC"}
@@ -0,0 +1,5 @@
1
+ import { TVerticalBreakpoint } from '../interfaces/TBreakpoint';
2
+ import { TAdaptiveVariant } from '../interfaces/TAdaptiveVariant';
3
+ export default function useVBreakpoint(b: TVerticalBreakpoint | number, variant?: TAdaptiveVariant): boolean;
4
+ export declare function useVBreakpointMF(b: TVerticalBreakpoint | number): boolean;
5
+ export declare function useVBreakpointDF(b: TVerticalBreakpoint | number): boolean;
@@ -0,0 +1,15 @@
1
+ import { useMediaQuery } from 'react-responsive';
2
+ import useVariant from './useVariant';
3
+ import { getVBreakpoint } from "../functions/getBreakpoint";
4
+ export default function useVBreakpoint(b, variant = 'MtF') {
5
+ const _bp = typeof b === 'number' ? b + 'px' : getVBreakpoint(b);
6
+ const v = useVariant(variant);
7
+ return useMediaQuery({ query: `(${v}-height: ${_bp})` });
8
+ }
9
+ export function useVBreakpointMF(b) {
10
+ return useVBreakpoint(b, 'MtF');
11
+ }
12
+ export function useVBreakpointDF(b) {
13
+ return useVBreakpoint(b, 'MtF');
14
+ }
15
+ //# sourceMappingURL=useVBreakpoint.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useVBreakpoint.js","sourceRoot":"","sources":["../../src/hooks/useVBreakpoint.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAIjD,OAAO,UAAU,MAAM,cAAc,CAAC;AACtC,OAAQ,EAAC,cAAc,EAAC,MAAM,4BAA4B,CAAC;AAE3D,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,CAA+B,EAAE,UAA4B,KAAK;IACvG,MAAM,GAAG,GAAG,OAAO,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAE,cAAc,CAAC,CAAC,CAAC,CAAC;IAClE,MAAM,CAAC,GAAG,UAAU,CAAC,OAAO,CAAC,CAAC;IAC9B,OAAO,aAAa,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,YAAY,GAAG,GAAG,EAAE,CAAC,CAAC;AAC3D,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,CAA+B;IAC9D,OAAO,cAAc,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;AAClC,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,CAA+B;IAC9D,OAAO,cAAc,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;AAClC,CAAC"}
@@ -0,0 +1,2 @@
1
+ import { TAdaptiveVariant } from "../interfaces/TAdaptiveVariant";
2
+ export default function useVariant(variant: TAdaptiveVariant): "min" | "max";
@@ -0,0 +1,4 @@
1
+ export default function useVariant(variant) {
2
+ return variant === 'MtF' ? 'min' : 'max';
3
+ }
4
+ //# sourceMappingURL=useVariant.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useVariant.js","sourceRoot":"","sources":["../../src/hooks/useVariant.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,OAAO,UAAU,UAAU,CAAC,OAAyB;IACxD,OAAO,OAAO,KAAK,KAAK,CAAC,CAAC,CAAC,KAAK,CAAA,CAAC,CAAC,KAAK,CAAC;AAC5C,CAAC"}
@@ -1,14 +1,6 @@
1
1
  import { TBreakpoints, TVerticalBreakpoints } from './interfaces/TBreakpoints';
2
2
  import { TBreakpoint, TVerticalBreakpoint } from './interfaces/TBreakpoint';
3
-
4
3
  export * from './hooks/useBreakpoint';
5
4
  export * from './hooks/useVBreakpoint';
6
-
7
- export type {
8
- TBreakpoints,
9
- TBreakpoint,
10
- TVerticalBreakpoint,
11
- TVerticalBreakpoints,
12
- };
13
-
5
+ export type { TBreakpoints, TBreakpoint, TVerticalBreakpoint, TVerticalBreakpoints, };
14
6
  export * from './components/horizontal';
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AASvC,cAAc,yBAAyB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=TAdaptiveVariant.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TAdaptiveVariant.js","sourceRoot":"","sources":["../../src/interfaces/TAdaptiveVariant.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export type TBreakpoint = 'xs' | 'sm' | 'md' | 'lg' | 'lt' | 'ltm' | 'ltl' | 'xl' | 'xxl' | 'qxl';
2
+ export type TVerticalBreakpoint = 'xs' | 'sm' | 'md' | 'lg' | 'xl' | 'xxl';
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=TBreakpoint.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TBreakpoint.js","sourceRoot":"","sources":["../../src/interfaces/TBreakpoint.ts"],"names":[],"mappings":""}
@@ -1,9 +1,7 @@
1
1
  import { TBreakpoint, TVerticalBreakpoint } from './TBreakpoint';
2
-
3
2
  export type TBreakpoints<T> = {
4
- [key in TBreakpoint]: T;
3
+ [key in TBreakpoint]: T;
5
4
  };
6
-
7
5
  export type TVerticalBreakpoints<T> = {
8
- [key in TVerticalBreakpoint]: T;
6
+ [key in TVerticalBreakpoint]: T;
9
7
  };
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=TBreakpoints.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TBreakpoints.js","sourceRoot":"","sources":["../../src/interfaces/TBreakpoints.ts"],"names":[],"mappings":""}
File without changes
@@ -0,0 +1 @@
1
+ import fs from"fs";import path from"path";import{fileURLToPath}from"url";const __filename=fileURLToPath(import.meta.url),__dirname=path.dirname(__filename),defaultConfigPath=path.resolve(__dirname,"../default.config.mjs"),userConfigPath=path.resolve(__dirname,"../../../../breakpoints.config.js");fs.existsSync(userConfigPath)?console.log("User configuration file already exists."):(fs.copyFileSync(defaultConfigPath,userConfigPath),console.log("Default configuration file has been copied to the root of the project as breakpoints.config.js"));
@@ -0,0 +1 @@
1
+ import o from"fs";import n from"path";import{fileURLToPath as e}from"url";import{HORIZONTAL_BREAKPOINTS as r,VERTICAL_BREAKPOINTS as i}from"../default.config.mjs";const s=e(import.meta.url),l=n.dirname(s),t=n.resolve(l,"../../../../breakpoints.config.js");(async()=>{let e=r,s=i;if(o.existsSync(t))try{console.log(`User config file found at: ${t}`);const o=await import(t);console.log(`Loaded user config: ${JSON.stringify(o,null,2)}`),o.HORIZONTAL_BREAKPOINTS?(e=o.HORIZONTAL_BREAKPOINTS,console.log("Using user provided horizontal breakpoints.")):console.log("Using default horizontal breakpoints."),o.VERTICAL_BREAKPOINTS?(s=o.VERTICAL_BREAKPOINTS,console.log("Using user provided vertical breakpoints.")):console.log("Using default vertical breakpoints.")}catch(o){console.error("Error loading user config:",o)}else console.log(`User config file not found at: ${t}. Using default breakpoints.`);const c=`\n// breakpoints.config.mjs\nconst HORIZONTAL_BREAKPOINTS = ${JSON.stringify(e,null,2)};\n\nconst VERTICAL_BREAKPOINTS = ${JSON.stringify(s,null,2)};\n\nexport { HORIZONTAL_BREAKPOINTS, VERTICAL_BREAKPOINTS };\n`;try{o.writeFileSync(n.resolve(l,"../breakpoints.config.mjs"),c),console.log("Config file has been generated successfully.")}catch(o){console.error("Error writing merged config file:",o)}})();
@@ -0,0 +1 @@
1
+ import o from"fs";import e from"path";import{fileURLToPath as r}from"url";import{HORIZONTAL_BREAKPOINTS as s,VERTICAL_BREAKPOINTS as t}from"../breakpoints.config.ts";const n=r(import.meta.url),i=e.dirname(n),m=(o,e)=>`$${e}-breakpoints: (\n${Object.entries(o).map((([o,e])=>` ${o}: ${e}`)).join(",\n")}\n);`,a=`\n${m(s,"horizontal")}\n${m(t,"vertical")}\n`;o.writeFileSync(e.resolve(i,"../scss/_custom-breakpoints.scss"),a),console.log("SCSS file with breakpoints maps has been generated successfully.");
@@ -0,0 +1 @@
1
+ import n from"fs";import e from"path";import{fileURLToPath as i}from"url";import{HORIZONTAL_BREAKPOINTS as r,VERTICAL_BREAKPOINTS as o}from"../breakpoints.config.ts";const s=i(import.meta.url),t=e.dirname(s),l=(c=r,`\n@import "horizontal";\n\n${Object.keys(c).map((n=>`\n/**\n * @mixin for-${n}\n * @description Mixin for applying styles for screens greater than or equal to ${c[n]}px.\n * @example\n * @include for-${n} {\n * // your styles here\n * }\n */\n@mixin for-${n}() {\n @include mob-first(${n}) {\n @content;\n }\n}`)).join("\n")}\n\n${Object.keys(c).map((n=>`\n/**\n * @mixin before-${n}\n * @description Mixin for applying styles for screens less than ${c[n]}px.\n * @example\n * @include before-${n} {\n * // your styles here\n * }\n */\n@mixin before-${n}() {\n @include desk-first(${n}) {\n @content;\n }\n}`)).join("\n")}\n`);var c;const p=(n=>`\n@import "vertical";\n\n${Object.keys(n).map((e=>`\n/**\n * @mixin v-for-${e}\n * @description Mixin for applying styles for screens with height greater than or equal to ${n[e]}px.\n * @example\n * @include v-for-${e} {\n * // your styles here\n * }\n */\n@mixin v-for-${e}() {\n @include v-mob-first(${e}) {\n @content;\n }\n}`)).join("\n")}\n\n${Object.keys(n).map((e=>`\n/**\n * @mixin v-before-${e}\n * @description Mixin for applying styles for screens with height less than ${n[e]}px.\n * @example\n * @include v-before-${e} {\n * // your styles here\n * }\n */\n@mixin v-before-${e}() {\n @include v-desk-first(${e}) {\n @content;\n }\n}`)).join("\n")}\n`)(o);n.writeFileSync(e.resolve(t,"../scss/_horizontal-breakpoints.scss"),l),n.writeFileSync(e.resolve(t,"../scss/_vertical-breakpoints.scss"),p),console.log("SCSS files have been generated successfully.");
@@ -0,0 +1 @@
1
+ import e from"fs";import r from"path";import{fileURLToPath as t}from"url";import{HORIZONTAL_BREAKPOINTS as o,VERTICAL_BREAKPOINTS as n}from"../breakpoints.config.ts";const i=t(import.meta.url),p=r.dirname(i),s=(e,r)=>`export type ${r} =\n${Object.keys(e).map((e=>` | '${e}'`)).join("\n")}\n`,a=`\n${s(o,"TBreakpoint")}\n\n${s(n,"TVerticalBreakpoint")}\n`;e.writeFileSync(r.resolve(p,"../interfaces/TBreakpoint.ts"),a.trim()),console.log("TBreakpoint.ts file has been generated successfully.");
package/package.json CHANGED
@@ -1,11 +1,12 @@
1
1
  {
2
2
  "name": "react-responsive-tools",
3
- "version": "2.2.3",
3
+ "version": "2.3.4",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
8
8
  "type": "module",
9
+
9
10
  "scripts": {
10
11
  "dev": "webpack --mode development --watch",
11
12
  "start": "webpack serve --config webpack.config.js --env development=true",
@@ -18,7 +19,7 @@
18
19
  "reinit": "sh ./reinit.sh"
19
20
  },
20
21
  "files": [
21
- "src",
22
+ "dist",
22
23
  "reinit.sh"
23
24
  ],
24
25
  "keywords": [
@@ -1,25 +0,0 @@
1
- // src/breakpoints.config.ts
2
-
3
- const HORIZONTAL_BREAKPOINTS: Record<string, string> = {
4
- "xs": "320px",
5
- "sm": "576px",
6
- "md": "768px",
7
- "lg": "992px",
8
- "lt": "1024px",
9
- "ltm": "1200px",
10
- "ltl": "1440px",
11
- "xl": "1920px",
12
- "xxl": "2560px",
13
- "qxl": "3840px"
14
- };
15
-
16
- const VERTICAL_BREAKPOINTS: Record<string, string> = {
17
- "xs": "600px",
18
- "sm": "800px",
19
- "md": "1000px",
20
- "lg": "1200px",
21
- "xl": "1600px",
22
- "xxl": "1601px"
23
- };
24
-
25
- export { HORIZONTAL_BREAKPOINTS, VERTICAL_BREAKPOINTS };
@@ -1,30 +0,0 @@
1
- /**
2
- * Created by westp on 15.05.2023
3
- */
4
-
5
- import React from "react";
6
-
7
- import { TBreakpoint } from '../interfaces/TBreakpoint';
8
- import { useBreakpointDF, useBreakpointMF } from '../hooks/useBreakpoint';
9
-
10
- interface Props {
11
- children: React.ReactNode;
12
- }
13
-
14
- interface ForComponentProps extends Props {
15
- p: TBreakpoint | number;
16
- }
17
-
18
- export function For({children, p}: ForComponentProps) {
19
- const is = useBreakpointMF(p);
20
- if (is) return children;
21
- return null;
22
- }
23
-
24
-
25
- export function Before({children ,p}: ForComponentProps) {
26
- const is = useBreakpointDF(p);
27
- if (is) return children;
28
- return null;
29
- }
30
-
@@ -1,25 +0,0 @@
1
- // breakpointConfig.js
2
-
3
- const HORIZONTAL_BREAKPOINTS = {
4
- xs: '320px',
5
- sm: '576px',
6
- md: '768px',
7
- lg: '992px',
8
- lt: '1024px',
9
- ltm: '1200px',
10
- ltl: '1440px',
11
- xl: '1920px',
12
- xxl: '2560px',
13
- qxl: '3840px',
14
- };
15
-
16
- const VERTICAL_BREAKPOINTS = {
17
- xs: '600px',
18
- sm: '800px',
19
- md: '1000px',
20
- lg: '1200px',
21
- xl: '1600px',
22
- xxl: '1601px',
23
- };
24
-
25
- export { HORIZONTAL_BREAKPOINTS, VERTICAL_BREAKPOINTS };
@@ -1,11 +0,0 @@
1
-
2
- import { HORIZONTAL_BREAKPOINTS, VERTICAL_BREAKPOINTS } from '../breakpoints.config';
3
- import { TBreakpoint, TVerticalBreakpoint } from '../interfaces/TBreakpoint';
4
-
5
- export default function getBreakpoint(b: TBreakpoint): string {
6
- return HORIZONTAL_BREAKPOINTS[b];
7
- }
8
-
9
- export function getVBreakpoint(b: TVerticalBreakpoint): string {
10
- return VERTICAL_BREAKPOINTS[b];
11
- }
@@ -1,20 +0,0 @@
1
- import { useMediaQuery } from 'react-responsive';
2
-
3
- import { TBreakpoint } from '../interfaces/TBreakpoint';
4
- import { TAdaptiveVariant } from '../interfaces/TAdaptiveVariant';
5
- import useVariant from './useVariant';
6
- import getBreakpoint from "../functions/getBreakpoint";
7
-
8
- export default function useBreakpoint(b: TBreakpoint | number, variant: TAdaptiveVariant = 'MtF') {
9
- const _bp = typeof b === 'number' ? b + 'px' : getBreakpoint(b);
10
- const v = useVariant(variant);
11
- return useMediaQuery({ query: `(${v}-width: ${_bp})` });
12
- }
13
-
14
- export function useBreakpointMF(b: TBreakpoint | number) {
15
- return useBreakpoint(b, 'MtF');
16
- }
17
-
18
- export function useBreakpointDF(b: TBreakpoint | number) {
19
- return useBreakpoint(b, 'MtF');
20
- }
@@ -1,20 +0,0 @@
1
- import { useMediaQuery } from 'react-responsive';
2
-
3
- import { TVerticalBreakpoint } from '../interfaces/TBreakpoint';
4
- import { TAdaptiveVariant } from '../interfaces/TAdaptiveVariant';
5
- import useVariant from './useVariant';
6
- import {getVBreakpoint} from "../functions/getBreakpoint";
7
-
8
- export default function useVBreakpoint(b: TVerticalBreakpoint | number, variant: TAdaptiveVariant = 'MtF') {
9
- const _bp = typeof b === 'number' ? b + 'px' : getVBreakpoint(b);
10
- const v = useVariant(variant);
11
- return useMediaQuery({ query: `(${v}-height: ${_bp})` });
12
- }
13
-
14
- export function useVBreakpointMF(b: TVerticalBreakpoint | number) {
15
- return useVBreakpoint(b, 'MtF');
16
- }
17
-
18
- export function useVBreakpointDF(b: TVerticalBreakpoint | number) {
19
- return useVBreakpoint(b, 'MtF');
20
- }
@@ -1,5 +0,0 @@
1
- import {TAdaptiveVariant} from "../interfaces/TAdaptiveVariant";
2
-
3
- export default function useVariant(variant: TAdaptiveVariant){
4
- return variant === 'MtF' ? 'min': 'max';
5
- }
@@ -1,20 +0,0 @@
1
- export type TBreakpoint =
2
- | 'xs'
3
- | 'sm'
4
- | 'md'
5
- | 'lg'
6
- | 'lt'
7
- | 'ltm'
8
- | 'ltl'
9
- | 'xl'
10
- | 'xxl'
11
- | 'qxl'
12
-
13
-
14
- export type TVerticalBreakpoint =
15
- | 'xs'
16
- | 'sm'
17
- | 'md'
18
- | 'lg'
19
- | 'xl'
20
- | 'xxl'
@@ -1,22 +0,0 @@
1
- // copyDefaultConfig.mjs
2
- import fs from 'fs';
3
- import path from 'path';
4
- import { fileURLToPath } from 'url';
5
-
6
- // Определение __filename и __dirname
7
- const __filename = fileURLToPath(import.meta.url);
8
- const __dirname = path.dirname(__filename);
9
-
10
- // Путь к файлу конфигурации по умолчанию
11
- const defaultConfigPath = path.resolve(__dirname, '../default.config.mjs');
12
-
13
- // Путь для копии файла в корне проекта
14
- const userConfigPath = path.resolve(__dirname, '../../../../breakpoints.config.js');
15
-
16
- // Проверка, существует ли уже пользовательская конфигурация
17
- if (!fs.existsSync(userConfigPath)) {
18
- fs.copyFileSync(defaultConfigPath, userConfigPath);
19
- console.log('Default configuration file has been copied to the root of the project as breakpoints.config.js');
20
- } else {
21
- console.log('User configuration file already exists.');
22
- }
@@ -1,64 +0,0 @@
1
- // createConfig.mjs
2
- import fs from 'fs';
3
- import path from 'path';
4
- import { fileURLToPath } from 'url';
5
- import { HORIZONTAL_BREAKPOINTS as defaultHorizontalBreakpoints, VERTICAL_BREAKPOINTS as defaultVerticalBreakpoints } from '../default.config.mjs';
6
-
7
- // Определение __filename и __dirname
8
- const __filename = fileURLToPath(import.meta.url);
9
- const __dirname = path.dirname(__filename);
10
-
11
- // Путь к пользовательскому конфигурационному файлу
12
- const userConfigPath = path.resolve(__dirname, '../../../../breakpoints.config.js');
13
-
14
- const mergeBreakpointConfigs = async () => {
15
- let horizontalBreakpoints = defaultHorizontalBreakpoints;
16
- let verticalBreakpoints = defaultVerticalBreakpoints;
17
-
18
- // Проверяем, существует ли пользовательский конфигурационный файл
19
- if (fs.existsSync(userConfigPath)) {
20
- try {
21
- console.log(`User config file found at: ${userConfigPath}`);
22
- const userConfig = await import(userConfigPath);
23
- console.log(`Loaded user config: ${JSON.stringify(userConfig, null, 2)}`);
24
-
25
- if (userConfig.HORIZONTAL_BREAKPOINTS) {
26
- horizontalBreakpoints = userConfig.HORIZONTAL_BREAKPOINTS;
27
- console.log('Using user provided horizontal breakpoints.');
28
- } else {
29
- console.log('Using default horizontal breakpoints.');
30
- }
31
-
32
- if (userConfig.VERTICAL_BREAKPOINTS) {
33
- verticalBreakpoints = userConfig.VERTICAL_BREAKPOINTS;
34
- console.log('Using user provided vertical breakpoints.');
35
- } else {
36
- console.log('Using default vertical breakpoints.');
37
- }
38
- } catch (error) {
39
- console.error('Error loading user config:', error);
40
- }
41
- } else {
42
- console.log(`User config file not found at: ${userConfigPath}. Using default breakpoints.`);
43
- }
44
-
45
- const mergedConfigContent = `
46
- // breakpoints.config.mjs
47
- const HORIZONTAL_BREAKPOINTS = ${JSON.stringify(horizontalBreakpoints, null, 2)};
48
-
49
- const VERTICAL_BREAKPOINTS = ${JSON.stringify(verticalBreakpoints, null, 2)};
50
-
51
- export { HORIZONTAL_BREAKPOINTS, VERTICAL_BREAKPOINTS };
52
- `;
53
-
54
- try {
55
- // Создаем новый файл с именем breakpoints.config.mjs
56
- fs.writeFileSync(path.resolve(__dirname, '../breakpoints.config.mjs'), mergedConfigContent);
57
- console.log('Config file has been generated successfully.');
58
- } catch (error) {
59
- console.error('Error writing merged config file:', error);
60
- }
61
- };
62
-
63
- // Запуск функции
64
- mergeBreakpointConfigs();
@@ -1,30 +0,0 @@
1
- // generateSCSSMaps.js
2
- import fs from 'fs';
3
- import path from 'path';
4
- import { fileURLToPath } from 'url'; // Импортируем необходимую функцию из 'url'
5
- import { HORIZONTAL_BREAKPOINTS, VERTICAL_BREAKPOINTS } from '../breakpoints.config.ts';
6
-
7
- // Определение __filename и __dirname
8
- const __filename = fileURLToPath(import.meta.url);
9
- const __dirname = path.dirname(__filename);
10
-
11
- // Функция генерации SCSS map
12
- const generateSCSSMap = (breakpoints, name) => {
13
- return `$${name}-breakpoints: (\n${Object.entries(breakpoints)
14
- .map(([key, value]) => ` ${key}: ${value}`)
15
- .join(',\n')}\n);`;
16
- };
17
-
18
- // Создаем содержимое SCSS файла
19
- const scssContent = `
20
- ${generateSCSSMap(HORIZONTAL_BREAKPOINTS, 'horizontal')}
21
- ${generateSCSSMap(VERTICAL_BREAKPOINTS, 'vertical')}
22
- `;
23
-
24
- // Записываем содержимое в файл _custom-breakpoints.scss
25
- fs.writeFileSync(
26
- path.resolve(__dirname, '../scss/_custom-breakpoints.scss'),
27
- scssContent
28
- );
29
-
30
- console.log('SCSS file with breakpoints maps has been generated successfully.');
@@ -1,107 +0,0 @@
1
- // generateSCSS.js
2
- import fs from 'fs';
3
- import path from 'path';
4
- import { fileURLToPath } from 'url';
5
- import { HORIZONTAL_BREAKPOINTS, VERTICAL_BREAKPOINTS } from '../breakpoints.config.ts';
6
-
7
- // Определение __filename и __dirname
8
- const __filename = fileURLToPath(import.meta.url);
9
- const __dirname = path.dirname(__filename);
10
-
11
- // Функция генерации SCSS содержимого для горизонтальных брейкпоинтов
12
- const generateHorizontalSCSS = (breakpoints) => {
13
- const beforeMixins = Object.keys(breakpoints).map(bp => `
14
- /**
15
- * @mixin for-${bp}
16
- * @description Mixin for applying styles for screens greater than or equal to ${breakpoints[bp]}px.
17
- * @example
18
- * @include for-${bp} {
19
- * // your styles here
20
- * }
21
- */
22
- @mixin for-${bp}() {
23
- @include mob-first(${bp}) {
24
- @content;
25
- }
26
- }`).join('\n');
27
-
28
- const afterMixins = Object.keys(breakpoints).map(bp => `
29
- /**
30
- * @mixin before-${bp}
31
- * @description Mixin for applying styles for screens less than ${breakpoints[bp]}px.
32
- * @example
33
- * @include before-${bp} {
34
- * // your styles here
35
- * }
36
- */
37
- @mixin before-${bp}() {
38
- @include desk-first(${bp}) {
39
- @content;
40
- }
41
- }`).join('\n');
42
-
43
- return `
44
- @import "horizontal";
45
-
46
- ${beforeMixins}
47
-
48
- ${afterMixins}
49
- `;
50
- };
51
-
52
- // Функция генерации SCSS содержимого для вертикальных брейкпоинтов
53
- const generateVerticalSCSS = (breakpoints) => {
54
- const beforeMixins = Object.keys(breakpoints).map(bp => `
55
- /**
56
- * @mixin v-for-${bp}
57
- * @description Mixin for applying styles for screens with height greater than or equal to ${breakpoints[bp]}px.
58
- * @example
59
- * @include v-for-${bp} {
60
- * // your styles here
61
- * }
62
- */
63
- @mixin v-for-${bp}() {
64
- @include v-mob-first(${bp}) {
65
- @content;
66
- }
67
- }`).join('\n');
68
-
69
- const afterMixins = Object.keys(breakpoints).map(bp => `
70
- /**
71
- * @mixin v-before-${bp}
72
- * @description Mixin for applying styles for screens with height less than ${breakpoints[bp]}px.
73
- * @example
74
- * @include v-before-${bp} {
75
- * // your styles here
76
- * }
77
- */
78
- @mixin v-before-${bp}() {
79
- @include v-desk-first(${bp}) {
80
- @content;
81
- }
82
- }`).join('\n');
83
-
84
- return `
85
- @import "vertical";
86
-
87
- ${beforeMixins}
88
-
89
- ${afterMixins}
90
- `;
91
- };
92
-
93
- // Создаем файлы SCSS с миксинами
94
- const horizontalSCSSContent = generateHorizontalSCSS(HORIZONTAL_BREAKPOINTS);
95
- const verticalSCSSContent = generateVerticalSCSS(VERTICAL_BREAKPOINTS);
96
-
97
- fs.writeFileSync(
98
- path.resolve(__dirname, '../scss/_horizontal-breakpoints.scss'),
99
- horizontalSCSSContent
100
- );
101
-
102
- fs.writeFileSync(
103
- path.resolve(__dirname, '../scss/_vertical-breakpoints.scss'),
104
- verticalSCSSContent
105
- );
106
-
107
- console.log('SCSS files have been generated successfully.');
@@ -1,30 +0,0 @@
1
- // generateTBreakpoint.js
2
- import fs from 'fs';
3
- import path from 'path';
4
- import { fileURLToPath } from 'url';
5
- import { HORIZONTAL_BREAKPOINTS, VERTICAL_BREAKPOINTS } from '../breakpoints.config.ts';
6
-
7
- // Определение __filename и __dirname
8
- const __filename = fileURLToPath(import.meta.url);
9
- const __dirname = path.dirname(__filename);
10
-
11
- // Функция для генерации type alias на основе брейкпоинтов
12
- const generateTypeAlias = (breakpoints, typeName) => {
13
- const types = Object.keys(breakpoints).map(bp => ` | '${bp}'`).join('\n');
14
- return `export type ${typeName} =\n${types}\n`;
15
- };
16
-
17
- // Генерируем содержимое файла TBreakpoint.ts
18
- const content = `
19
- ${generateTypeAlias(HORIZONTAL_BREAKPOINTS, 'TBreakpoint')}
20
-
21
- ${generateTypeAlias(VERTICAL_BREAKPOINTS, 'TVerticalBreakpoint')}
22
- `;
23
-
24
- // Создаем файл TBreakpoint.ts и записываем туда содержимое
25
- fs.writeFileSync(
26
- path.resolve(__dirname, '../interfaces/TBreakpoint.ts'),
27
- content.trim()
28
- );
29
-
30
- console.log('TBreakpoint.ts file has been generated successfully.');
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes