oddsgate-ds 1.0.86 → 1.0.88

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 @@
1
+ export declare const debounce: (callback: any, wait: number) => (...args: any) => void;
@@ -48,4 +48,5 @@ 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 { debounce } from './helpers/events';
51
52
  export { variables };
package/dist/types.d.ts CHANGED
@@ -637,4 +637,6 @@ declare function clickOutSideToClose(ref: React.RefObject<HTMLDivElement>, close
637
637
 
638
638
  declare const isTouchDevice: () => boolean;
639
639
 
640
- 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, iconsList, isTouchDevice, variables };
640
+ declare const debounce: (callback: any, wait: number) => (...args: any) => void;
641
+
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 };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oddsgate-ds",
3
- "version": "1.0.86",
3
+ "version": "1.0.88",
4
4
  "description": "Miew theme component library",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -3,7 +3,6 @@ import { css, styled } from 'styled-components';
3
3
  import { IImageWrapper } from './ImageWrapper.interface';
4
4
 
5
5
  export const StyledImageWrapper = styled.picture<IImageWrapper>`
6
-
7
6
  & picture{
8
7
  position: relative;
9
8
  }
@@ -48,4 +47,4 @@ export const Overlay = styled.div`
48
47
  bottom: 0;
49
48
  left: 0;
50
49
  right: 0;
51
- `
50
+ `
@@ -15,7 +15,7 @@ export const StyledIconBox = styled.div<IIconBox>`
15
15
  height: 32px;
16
16
 
17
17
  color: ${colors.primary50};
18
- background: ${colors.primary10};
18
+ background: ${colors.secondary50};
19
19
  border-radius: 50px;
20
20
 
21
21
  text-align:center;
@@ -32,8 +32,6 @@ const ProductCard = ({
32
32
  firstRowTitle = title;
33
33
  }
34
34
 
35
- console.log(parts, half);
36
-
37
35
 
38
36
  return (
39
37
  <StyledProductCard className={className} style={style}>
@@ -35,7 +35,7 @@ export const StyledModal = styled.div<IShareModal>`
35
35
 
36
36
  &:hover {
37
37
  & > div {
38
- background: ${colors.primary10}
38
+ background: ${colors.primary50}
39
39
  }
40
40
  };
41
41
 
@@ -9,6 +9,7 @@ import {
9
9
 
10
10
  import Heading from '@/components/atoms/Heading/Heading.component';
11
11
  import { ICircularSlider } from './CircularSlider.interface'
12
+ import { debounce } from '@/helpers/events';
12
13
  import isTouchDevice from '@/helpers/isTouchDevice';
13
14
 
14
15
  const CircularSlider = ({
@@ -88,7 +89,7 @@ const CircularSlider = ({
88
89
 
89
90
  }
90
91
 
91
- const sliderResize = () => {
92
+ const sliderResize = debounce(() => {
92
93
  let radius,
93
94
  w = slider?.current ? slider?.current?.getBoundingClientRect().width : 0,
94
95
  h = slider?.current ? slider?.current.getBoundingClientRect().height : 0;
@@ -96,7 +97,7 @@ const CircularSlider = ({
96
97
  2 * h <= w ? radius = h * sliderSize : radius = (w / 2) * sliderSize;
97
98
 
98
99
  setSize(Math.round(radius));
99
- }
100
+ }, 250)
100
101
 
101
102
  const addStyle = () => {
102
103
  setTimeout(() => {
@@ -126,10 +127,10 @@ const CircularSlider = ({
126
127
  if (currentSlide === 0 && newSlide === (slides.length - 1)) {
127
128
  multiplier = -1;
128
129
  direction = "-";
129
- } else if(currentSlide === (slides.length - 1) && newSlide === 0) {
130
+ } else if (currentSlide === (slides.length - 1) && newSlide === 0) {
130
131
  multiplier = 1;
131
132
  direction = "+";
132
- }else{
133
+ } else {
133
134
  multiplier = newSlide - currentSlide
134
135
  direction = currentSlide < newSlide ? "+" : "-";
135
136
  }
@@ -149,7 +150,7 @@ const CircularSlider = ({
149
150
 
150
151
 
151
152
  for (let i = 0; i < slides.length; i++) {
152
- slides[i].addEventListener('click', rotateSlider);
153
+ slides[i].addEventListener('click', rotateSlider, { passive: true });
153
154
  };
154
155
 
155
156
  window.addEventListener('resize', sliderResize)
@@ -8,6 +8,7 @@ import {
8
8
 
9
9
  import Heading from '@/components/atoms/Heading/Heading.component'
10
10
  import { ITabs } from './Tabs.interface'
11
+ import { debounce } from '@/helpers/events'
11
12
 
12
13
  const Tabs = ({ id, title, menu, vertical, className, style }: ITabs) => {
13
14
  const [active, setActive] = useState(0)
@@ -19,7 +20,8 @@ const Tabs = ({ id, title, menu, vertical, className, style }: ITabs) => {
19
20
  setActive(index);
20
21
  }
21
22
 
22
- const setTabsHeight = () => {
23
+
24
+ const setTabsHeight = debounce(() => {
23
25
  if (!tabsContent.current) return;
24
26
 
25
27
  const heights: number[] = [];
@@ -27,7 +29,7 @@ const Tabs = ({ id, title, menu, vertical, className, style }: ITabs) => {
27
29
  heights.push(child?.offsetHeight as number)
28
30
  })
29
31
  tabsContent.current.style.height = `${Math.max(...heights)}px`;
30
- }
32
+ }, 250)
31
33
 
32
34
  useEffect(()=>{
33
35
  setTabsHeight();
@@ -11,7 +11,7 @@ export default function clickOutSideToClose(
11
11
  }
12
12
 
13
13
  useEffect(() => {
14
- document.addEventListener('mouseup', handleClickOutside)
14
+ document.addEventListener('mouseup', handleClickOutside, {passive: true})
15
15
  return () => document.removeEventListener('mouseup', handleClickOutside)
16
16
  }, [ref])
17
17
  }
@@ -0,0 +1,9 @@
1
+ export const debounce = (callback: any, wait: number) => {
2
+ let timeoutId: number | null = null;
3
+ return (...args: any) => {
4
+ timeoutId && window.clearTimeout(timeoutId);
5
+ timeoutId = window.setTimeout(() => {
6
+ callback(...args);
7
+ }, wait);
8
+ };
9
+ }
@@ -10,7 +10,6 @@ export const useInterval = (callback, delay) => {
10
10
 
11
11
  useEffect(() => {
12
12
  function tick() {
13
- console.log("tou2");
14
13
  if (savedCallback && savedCallback.current) {
15
14
  const result = (savedCallback as unknown as any).current();
16
15
  if (result === true) {// if callback returs true, clear timeout;
@@ -1,5 +1,7 @@
1
1
  import { useEffect, useState } from 'react';
2
2
 
3
+ import { debounce } from './events';
4
+
3
5
  function useMediaQuery(query: string) {
4
6
  const [matches, setMatches] = useState<boolean>(false)
5
7
 
@@ -11,7 +13,9 @@ function useMediaQuery(query: string) {
11
13
  setMatches(media.matches)
12
14
  }
13
15
 
14
- const listener = () => setMatches(media.matches)
16
+ const listener = debounce(() => {
17
+ setMatches(media.matches)
18
+ }, 250)
15
19
  window.addEventListener('resize', listener)
16
20
 
17
21
  return () => window.removeEventListener('resize', listener)
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 { debounce } from './helpers/events'
61
62
 
62
63
  export { variables };
63
64