oddsgate-ds 1.0.91 → 1.0.93
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/dist/cjs/index.js +5 -5
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/helpers/useMediaMatch.d.ts +1 -0
- package/dist/cjs/types/index.d.ts +1 -0
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/helpers/useMediaMatch.d.ts +1 -0
- package/dist/esm/types/index.d.ts +1 -0
- package/dist/types.d.ts +3 -1
- package/package.json +1 -1
- package/src/components/organisms/CircularSlider/CircularSlider.component.tsx +2 -2
- package/src/components/organisms/Slider/Slider.component.tsx +2 -2
- package/src/helpers/isTouchDevice.tsx +6 -30
- package/src/helpers/useMediaMatch.tsx +26 -0
- package/src/index.ts +1 -0
- package/dist/cjs/types/helpers/useMediaQuery.d.ts +0 -2
- package/dist/esm/types/helpers/useMediaQuery.d.ts +0 -2
- package/src/helpers/useMediaQuery.tsx +0 -28
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function useMediaMatch(query?: string): boolean;
|
|
@@ -48,5 +48,6 @@ export { iconsList } from './helpers/getIcons';
|
|
|
48
48
|
export { default as GlobalStyles } from './styles/Global';
|
|
49
49
|
export { default as clickOutSideToClose } from './helpers/clickOutsideToClose';
|
|
50
50
|
export { default as isTouchDevice } from './helpers/isTouchDevice';
|
|
51
|
+
export { default as useMediaMatch } from './helpers/useMediaMatch';
|
|
51
52
|
export { debounce } from './helpers/events';
|
|
52
53
|
export { variables };
|
package/dist/types.d.ts
CHANGED
|
@@ -637,6 +637,8 @@ declare function clickOutSideToClose(ref: React.RefObject<HTMLDivElement>, close
|
|
|
637
637
|
|
|
638
638
|
declare const isTouchDevice: () => boolean;
|
|
639
639
|
|
|
640
|
+
declare function useMediaMatch(query?: string): boolean;
|
|
641
|
+
|
|
640
642
|
declare const debounce: (callback: any, wait: number) => (...args: any) => void;
|
|
641
643
|
|
|
642
|
-
export { Accordion, AccordionItem, BlogCard, Button, CareersCard, CheckRadioField, Chip, CircularSlider, CloseButton, Column, Counter, Cover, Dropdown, DropdownItem, EmptyState, EventsCard, Flex, FormField, GlobalStyles, Heading, Icon, IconBox, IconTitle, ImageWrapper, LicenseCard, Loader, LogosCard, Marquee, Modal, NewsCard, OffCanvas, PortalComponent, ProductCard, Quote, RichText, Row, ScrollingNav, Separator, ShareModal, Slider, SocialLinks, Spacer, Tabs, TeamCard, Video, VideoEmbed, clickOutSideToClose, debounce, iconsList, isTouchDevice, variables };
|
|
644
|
+
export { Accordion, AccordionItem, BlogCard, Button, CareersCard, CheckRadioField, Chip, CircularSlider, CloseButton, Column, Counter, Cover, Dropdown, DropdownItem, EmptyState, EventsCard, Flex, FormField, GlobalStyles, Heading, Icon, IconBox, IconTitle, ImageWrapper, LicenseCard, Loader, LogosCard, Marquee, Modal, NewsCard, OffCanvas, PortalComponent, ProductCard, Quote, RichText, Row, ScrollingNav, Separator, ShareModal, Slider, SocialLinks, Spacer, Tabs, TeamCard, Video, VideoEmbed, clickOutSideToClose, debounce, iconsList, isTouchDevice, useMediaMatch, variables };
|
package/package.json
CHANGED
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
import Heading from '@/components/atoms/Heading/Heading.component';
|
|
11
11
|
import { ICircularSlider } from './CircularSlider.interface'
|
|
12
12
|
import { debounce } from '@/helpers/events';
|
|
13
|
-
import
|
|
13
|
+
import useMediaMatch from '@/helpers/useMediaMatch';
|
|
14
14
|
|
|
15
15
|
const CircularSlider = ({
|
|
16
16
|
content,
|
|
@@ -27,7 +27,7 @@ const CircularSlider = ({
|
|
|
27
27
|
const slidesHolder = useRef<HTMLDivElement>();
|
|
28
28
|
const contentHolder = useRef<HTMLDivElement>();
|
|
29
29
|
|
|
30
|
-
const isMobile =
|
|
30
|
+
const isMobile = useMediaMatch();
|
|
31
31
|
|
|
32
32
|
const sliderSize = isMobile ? 2.6 : 1;
|
|
33
33
|
const slideSize = isMobile ? 0.12 : 0.15;
|
|
@@ -4,8 +4,8 @@ import Button from '@/components/atoms/Button/Button.component'
|
|
|
4
4
|
import { ISlider } from './Slider.interface'
|
|
5
5
|
import Icon from '@/components/atoms/Icon/Icon.component'
|
|
6
6
|
import { StyledSlider } from './Slider.theme'
|
|
7
|
-
import isTouchDevice from '@/helpers/isTouchDevice'
|
|
8
7
|
import { useBlazeSlider } from './Slider.utils'
|
|
8
|
+
import useMediaMatch from '@/helpers/useMediaMatch'
|
|
9
9
|
|
|
10
10
|
const Slider = ({
|
|
11
11
|
arrows,
|
|
@@ -28,7 +28,7 @@ const Slider = ({
|
|
|
28
28
|
let elRef: any = null
|
|
29
29
|
let sliderRef: any = null
|
|
30
30
|
|
|
31
|
-
const isMobile =
|
|
31
|
+
const isMobile = useMediaMatch();
|
|
32
32
|
|
|
33
33
|
const setConfig = () => {
|
|
34
34
|
if (sliderRef?.current) sliderRef.current.destroy()
|
|
@@ -1,35 +1,11 @@
|
|
|
1
|
-
import { useEffect, useRef, useState } from "react";
|
|
2
|
-
|
|
3
|
-
import { responsiveMedia } from "@/styles/variables";
|
|
4
|
-
|
|
5
1
|
const isTouchDevice = () => {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
for (let entry of entries) {
|
|
13
|
-
setDimensions({
|
|
14
|
-
width: entry.contentRect.width,
|
|
15
|
-
height: entry.contentRect.height,
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
observer.observe(observedElementRef);
|
|
21
|
-
|
|
22
|
-
// Cleanup function
|
|
23
|
-
return () => {
|
|
24
|
-
observer.disconnect();
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
}, []);
|
|
28
|
-
|
|
29
|
-
console.log(dimensions);
|
|
30
|
-
return dimensions.width < parseInt(responsiveMedia);
|
|
2
|
+
try {
|
|
3
|
+
document.createEvent('TouchEvent');
|
|
4
|
+
return true;
|
|
5
|
+
} catch (e) {
|
|
6
|
+
return false;
|
|
7
|
+
}
|
|
31
8
|
}
|
|
32
9
|
|
|
33
10
|
|
|
34
|
-
|
|
35
11
|
export default isTouchDevice
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { useEffect, useState } from 'react'
|
|
2
|
+
|
|
3
|
+
import { debounce } from './events';
|
|
4
|
+
import { responsiveMedia } from '@/styles/variables'
|
|
5
|
+
|
|
6
|
+
// useMediaMatch('(max-width: 600px)')
|
|
7
|
+
export default function useMediaMatch(query: string = `(max-width: ${responsiveMedia})`) {
|
|
8
|
+
const [matches, setMatches] = useState(false)
|
|
9
|
+
|
|
10
|
+
useEffect(() => {
|
|
11
|
+
const mediaQueryList = window.matchMedia(query)
|
|
12
|
+
|
|
13
|
+
const handleMatchChange = debounce((e) => {
|
|
14
|
+
setMatches(e.matches)
|
|
15
|
+
}, 250)
|
|
16
|
+
|
|
17
|
+
mediaQueryList.addEventListener('change', handleMatchChange)
|
|
18
|
+
setMatches(mediaQueryList.matches || false)
|
|
19
|
+
|
|
20
|
+
return () => {
|
|
21
|
+
mediaQueryList.removeEventListener('change', handleMatchChange)
|
|
22
|
+
}
|
|
23
|
+
}, [query])
|
|
24
|
+
|
|
25
|
+
return matches
|
|
26
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -58,6 +58,7 @@ export { default as GlobalStyles } from './styles/Global'
|
|
|
58
58
|
|
|
59
59
|
export { default as clickOutSideToClose } from './helpers/clickOutsideToClose'
|
|
60
60
|
export { default as isTouchDevice } from './helpers/isTouchDevice'
|
|
61
|
+
export { default as useMediaMatch } from './helpers/useMediaMatch'
|
|
61
62
|
export { debounce } from './helpers/events'
|
|
62
63
|
|
|
63
64
|
export { variables };
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { useEffect, useState } from 'react';
|
|
2
|
-
|
|
3
|
-
import { debounce } from './events';
|
|
4
|
-
|
|
5
|
-
function useMediaQuery(query: string) {
|
|
6
|
-
const [matches, setMatches] = useState<boolean>(false)
|
|
7
|
-
|
|
8
|
-
useEffect(() => {
|
|
9
|
-
if (typeof window !== 'undefined') {
|
|
10
|
-
const media = window.matchMedia(query)
|
|
11
|
-
|
|
12
|
-
if (media.matches !== matches) {
|
|
13
|
-
setMatches(media.matches)
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
const listener = debounce(() => {
|
|
17
|
-
setMatches(media.matches)
|
|
18
|
-
}, 250)
|
|
19
|
-
window.addEventListener('resize', listener)
|
|
20
|
-
|
|
21
|
-
return () => window.removeEventListener('resize', listener)
|
|
22
|
-
}
|
|
23
|
-
}, [matches, query])
|
|
24
|
-
|
|
25
|
-
return matches
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export default useMediaQuery
|