oddsgate-ds 1.0.87 → 1.0.89

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.87",
3
+ "version": "1.0.89",
4
4
  "description": "Miew theme component library",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -42,7 +42,7 @@
42
42
  "@storybook/addon-essentials": "^8.1.5",
43
43
  "@storybook/addon-interactions": "^8.1.5",
44
44
  "@storybook/addon-links": "^8.1.5",
45
- "@storybook/addon-styling": "^1.3.2",
45
+ "@storybook/addon-styling": "^1.3.7",
46
46
  "@storybook/addon-webpack5-compiler-swc": "^1.0.3",
47
47
  "@storybook/blocks": "^8.1.5",
48
48
  "@storybook/react": "^8.1.5",
@@ -80,6 +80,7 @@
80
80
  "dependencies": {
81
81
  "@rollup/plugin-json": "^6.0.0",
82
82
  "@rollup/plugin-url": "^8.0.1",
83
+ "@washingtonpost/storybook-addon-web-vitals": "^0.3.0",
83
84
  "blaze-slider": "^1.9.3",
84
85
  "classnames": "^2.3.2",
85
86
  "formik": "^2.4.2",
@@ -113,6 +113,7 @@ export const StyledButton = styled.a<IButtonSC>`
113
113
  return css`
114
114
  ${fontSize('h5')};
115
115
  text-transform:uppercase;
116
+ padding: 0;
116
117
 
117
118
  ${props.$mode === "light" ? `
118
119
  color: ${colors.third50};
@@ -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 = ({
@@ -27,6 +28,7 @@ const CircularSlider = ({
27
28
  const contentHolder = useRef<HTMLDivElement>();
28
29
 
29
30
  const isMobile = isTouchDevice();
31
+ console.log(isMobile);
30
32
 
31
33
  const sliderSize = isMobile ? 2.6 : 1;
32
34
  const slideSize = isMobile ? 0.12 : 0.15;
@@ -88,7 +90,7 @@ const CircularSlider = ({
88
90
 
89
91
  }
90
92
 
91
- const sliderResize = () => {
93
+ const sliderResize = debounce(() => {
92
94
  let radius,
93
95
  w = slider?.current ? slider?.current?.getBoundingClientRect().width : 0,
94
96
  h = slider?.current ? slider?.current.getBoundingClientRect().height : 0;
@@ -96,7 +98,7 @@ const CircularSlider = ({
96
98
  2 * h <= w ? radius = h * sliderSize : radius = (w / 2) * sliderSize;
97
99
 
98
100
  setSize(Math.round(radius));
99
- }
101
+ }, 250)
100
102
 
101
103
  const addStyle = () => {
102
104
  setTimeout(() => {
@@ -126,10 +128,10 @@ const CircularSlider = ({
126
128
  if (currentSlide === 0 && newSlide === (slides.length - 1)) {
127
129
  multiplier = -1;
128
130
  direction = "-";
129
- } else if(currentSlide === (slides.length - 1) && newSlide === 0) {
131
+ } else if (currentSlide === (slides.length - 1) && newSlide === 0) {
130
132
  multiplier = 1;
131
133
  direction = "+";
132
- }else{
134
+ } else {
133
135
  multiplier = newSlide - currentSlide
134
136
  direction = currentSlide < newSlide ? "+" : "-";
135
137
  }
@@ -149,7 +151,7 @@ const CircularSlider = ({
149
151
 
150
152
 
151
153
  for (let i = 0; i < slides.length; i++) {
152
- slides[i].addEventListener('click', rotateSlider, {passive: true});
154
+ slides[i].addEventListener('click', rotateSlider, { passive: true });
153
155
  };
154
156
 
155
157
  window.addEventListener('resize', sliderResize)
@@ -54,6 +54,7 @@ export const StyledCircularSliderSlide = styled.div<ICircularSlider>`
54
54
  transform-origin: center;
55
55
  transition: .3s linear all;
56
56
  filter: brightness(70%);
57
+ cursor: pointer;
57
58
 
58
59
  & img{
59
60
  height: 100%;
@@ -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();
@@ -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
+ }
@@ -1,11 +1,35 @@
1
+ import { useEffect, useRef, useState } from "react";
2
+
3
+ import { responsiveMedia } from "@/styles/variables";
4
+
1
5
  const isTouchDevice = () => {
2
- try {
3
- document.createEvent('TouchEvent');
4
- return true;
5
- } catch (e) {
6
- return false;
7
- }
6
+ const [dimensions, setDimensions] = useState({ width: 0, height: 0 });
7
+
8
+ useEffect(() => {
9
+ const observedElementRef = document.querySelector('body > main');
10
+ if (observedElementRef) {
11
+ const observer = new ResizeObserver((entries) => {
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);
8
31
  }
9
32
 
10
33
 
34
+
11
35
  export default isTouchDevice
@@ -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
 
@@ -184,6 +184,12 @@ export const utilities: {
184
184
  last: 6,
185
185
  },
186
186
  },
187
+ "gap": {
188
+ responsive: true,
189
+ property: "gap",
190
+ class: "gap",
191
+ values: spacers
192
+ },
187
193
  "margin": {
188
194
  responsive: true,
189
195
  property: "margin",