@ably/ui 14.0.0-dev.fbce38f → 14.0.1

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 (208) hide show
  1. package/README.md +8 -10
  2. package/core/Accordion.js +1 -0
  3. package/core/Code/component.js +1 -1
  4. package/core/Code.js +1 -0
  5. package/core/ConnectStateWrapper.js +1 -0
  6. package/core/ContactFooter/component.css +9 -7
  7. package/core/ContactFooter/component.js +1 -1
  8. package/core/ContactFooter.js +1 -0
  9. package/core/CookieMessage/component.css +12 -10
  10. package/core/CookieMessage.js +1 -0
  11. package/core/CustomerLogos.js +1 -0
  12. package/core/DropdownMenu.js +1 -0
  13. package/core/Expander.js +1 -0
  14. package/core/FeaturedLink.js +1 -0
  15. package/core/Flash/component.css +21 -19
  16. package/core/Flash.js +1 -0
  17. package/core/Footer/component.css +24 -22
  18. package/core/Footer.js +1 -0
  19. package/core/Icon.js +1 -0
  20. package/core/Loader.js +13 -0
  21. package/core/Logo.js +1 -0
  22. package/core/Meganav/component.css +105 -103
  23. package/core/Meganav/component.js +1 -1
  24. package/core/Meganav.js +1 -0
  25. package/core/MeganavBlogPostsList/component.js +1 -1
  26. package/core/MeganavBlogPostsList.js +1 -0
  27. package/core/MeganavContentCompany.js +1 -0
  28. package/core/MeganavContentDevelopers.js +1 -0
  29. package/core/MeganavContentProducts.js +1 -0
  30. package/core/MeganavContentUseCases.js +1 -0
  31. package/core/MeganavControl/component.js +1 -1
  32. package/core/MeganavControl.js +1 -0
  33. package/core/MeganavControlMobileDropdown/component.js +1 -1
  34. package/core/MeganavControlMobileDropdown.js +1 -0
  35. package/core/MeganavControlMobilePanelClose/component.js +1 -1
  36. package/core/MeganavControlMobilePanelClose.js +1 -0
  37. package/core/MeganavControlMobilePanelOpen/component.js +1 -1
  38. package/core/MeganavControlMobilePanelOpen.js +1 -0
  39. package/core/MeganavItemsDesktop.js +1 -0
  40. package/core/MeganavItemsMobile.js +1 -0
  41. package/core/MeganavItemsSignedIn.js +1 -0
  42. package/core/MeganavSearch.js +1 -0
  43. package/core/MeganavSearchAutocomplete/component.js +1 -1
  44. package/core/MeganavSearchAutocomplete.js +1 -0
  45. package/core/MeganavSearchPanel.js +1 -0
  46. package/core/MeganavSearchSuggestions/component.js +1 -1
  47. package/core/MeganavSearchSuggestions.js +1 -0
  48. package/core/Notice/component.css +6 -4
  49. package/core/Notice/component.js +1 -1
  50. package/core/Notice.js +1 -0
  51. package/core/SignOutLink.js +1 -0
  52. package/core/Slider/component.css +38 -4
  53. package/core/Slider/component.js +1 -1
  54. package/core/Slider.js +1 -0
  55. package/core/Table/Table.js +1 -1
  56. package/core/Table/TableCell.js +7 -1
  57. package/core/Table/TableRow.js +1 -1
  58. package/core/Table/data.js +1 -0
  59. package/core/Table.js +1 -0
  60. package/core/Tooltip.js +1 -0
  61. package/core/css.js +1 -1
  62. package/core/dom-query.js +1 -1
  63. package/core/hubspot-chat-toggle.js +1 -1
  64. package/core/icons/icon-gui-partial.svg +4 -0
  65. package/core/icons.js +1 -1
  66. package/core/load-sprites.js +1 -1
  67. package/core/react-renderer.js +1 -1
  68. package/core/remote-blogs-posts.js +1 -1
  69. package/core/remote-data-store.js +1 -1
  70. package/core/remote-data-util.js +1 -1
  71. package/core/remote-session-data.js +1 -1
  72. package/core/scripts.js +1 -1
  73. package/core/sprites.svg +1 -1
  74. package/core/styles/buttons.css +123 -121
  75. package/core/styles/forms.css +51 -49
  76. package/core/styles/layout.css +16 -14
  77. package/core/styles/properties.css +252 -250
  78. package/core/styles/text.css +167 -165
  79. package/core/styles.components.css +24 -22
  80. package/core/url-base.js +1 -1
  81. package/core/utils/syntax-highlighter-registry.js +1 -1
  82. package/core/utils/syntax-highlighter.css +59 -55
  83. package/core/utils/syntax-highlighter.js +1 -1
  84. package/package.json +4 -7
  85. package/src/core/Accordion/Accordion.stories.tsx +1 -1
  86. package/src/core/{Accordion/component.tsx → Accordion.tsx} +8 -6
  87. package/src/core/Code/Code.stories.tsx +1 -1
  88. package/src/core/{Code/component.tsx → Code.tsx} +2 -3
  89. package/src/core/{ConnectStateWrapper/component.tsx → ConnectStateWrapper.tsx} +1 -1
  90. package/src/core/ContactFooter/ContactFooter.stories.tsx +1 -1
  91. package/src/core/ContactFooter/component.css +9 -7
  92. package/src/core/{ContactFooter/component.tsx → ContactFooter.tsx} +3 -4
  93. package/src/core/CookieMessage/CookieMessage.stories.tsx +1 -1
  94. package/src/core/CookieMessage/component.css +12 -10
  95. package/src/core/{CookieMessage/component.tsx → CookieMessage.tsx} +1 -2
  96. package/src/core/CustomerLogos/CustomerLogos.stories.tsx +1 -1
  97. package/src/core/DropdownMenu/DropdownMenu.stories.tsx +2 -2
  98. package/src/core/{DropdownMenu/component.tsx → DropdownMenu.tsx} +1 -1
  99. package/src/core/Expander/Expander.stories.tsx +132 -0
  100. package/src/core/Expander.tsx +63 -0
  101. package/src/core/FeaturedLink/FeaturedLink.stories.tsx +1 -1
  102. package/src/core/{FeaturedLink/component.tsx → FeaturedLink.tsx} +1 -1
  103. package/src/core/Flash/Flash.stories.tsx +1 -1
  104. package/src/core/Flash/component.css +21 -19
  105. package/src/core/{Flash/component.tsx → Flash.tsx} +3 -4
  106. package/src/core/Footer/Footer.stories.tsx +1 -1
  107. package/src/core/Footer/component.css +24 -22
  108. package/src/core/{Footer/component.tsx → Footer.tsx} +2 -3
  109. package/src/core/Icon/Icon.stories.tsx +2 -1
  110. package/src/core/Loader/Loader.stories.tsx +1 -1
  111. package/src/core/Logo/Logo.stories.tsx +1 -1
  112. package/src/core/Meganav/Meganav.stories.tsx +1 -1
  113. package/src/core/Meganav/component.css +105 -103
  114. package/src/core/Meganav/component.js +0 -2
  115. package/src/core/{Meganav/component.tsx → Meganav.tsx} +16 -19
  116. package/src/core/{MeganavBlogPostsList/component.tsx → MeganavBlogPostsList.tsx} +2 -2
  117. package/src/core/{MeganavContentCompany/component.tsx → MeganavContentCompany.tsx} +5 -5
  118. package/src/core/{MeganavContentDevelopers/component.tsx → MeganavContentDevelopers.tsx} +2 -2
  119. package/src/core/{MeganavContentProducts/component.tsx → MeganavContentProducts.tsx} +2 -2
  120. package/src/core/{MeganavContentUseCases/component.tsx → MeganavContentUseCases.tsx} +2 -2
  121. package/src/core/{MeganavControl/component.tsx → MeganavControl.tsx} +2 -2
  122. package/src/core/{MeganavControlMobileDropdown/component.tsx → MeganavControlMobileDropdown.tsx} +2 -2
  123. package/src/core/{MeganavControlMobilePanelClose/component.tsx → MeganavControlMobilePanelClose.tsx} +1 -2
  124. package/src/core/{MeganavControlMobilePanelOpen/component.tsx → MeganavControlMobilePanelOpen.tsx} +1 -2
  125. package/src/core/{MeganavItemsDesktop/component.tsx → MeganavItemsDesktop.tsx} +3 -3
  126. package/src/core/{MeganavItemsMobile/component.tsx → MeganavItemsMobile.tsx} +9 -9
  127. package/src/core/{MeganavItemsSignedIn/component.tsx → MeganavItemsSignedIn.tsx} +4 -8
  128. package/src/core/{MeganavSearch/component.tsx → MeganavSearch.tsx} +3 -3
  129. package/src/core/{MeganavSearchPanel/component.tsx → MeganavSearchPanel.tsx} +4 -4
  130. package/src/core/{MeganavSearchSuggestions/component.tsx → MeganavSearchSuggestions.tsx} +2 -2
  131. package/src/core/Notice/component.css +6 -4
  132. package/src/core/Notice/component.js +1 -2
  133. package/src/core/{Notice/component.tsx → Notice.tsx} +2 -4
  134. package/src/core/{SignOutLink/component.tsx → SignOutLink.tsx} +1 -1
  135. package/src/core/Slider/Slider.stories.tsx +83 -30
  136. package/src/core/Slider/component.css +38 -4
  137. package/src/core/Slider/component.js +0 -2
  138. package/src/core/Slider.tsx +224 -0
  139. package/src/core/Table/Table.tsx +38 -10
  140. package/src/core/Table/TableCell.tsx +14 -27
  141. package/src/core/Table/{stories/data.tsx → data.tsx} +23 -3
  142. package/src/core/{Table/index.ts → Table.tsx} +3 -12
  143. package/src/core/Tooltip/Tooltip.stories.tsx +1 -1
  144. package/src/core/{Tooltip/component.tsx → Tooltip.tsx} +34 -6
  145. package/src/core/icons/icon-gui-partial.svg +4 -0
  146. package/src/core/scripts.js +0 -2
  147. package/src/core/styles/buttons.css +123 -121
  148. package/src/core/styles/forms.css +51 -49
  149. package/src/core/styles/layout.css +16 -14
  150. package/src/core/styles/properties.css +252 -250
  151. package/src/core/styles/text.css +167 -165
  152. package/src/core/styles.components.css +24 -22
  153. package/src/core/utils/syntax-highlighter.css +59 -55
  154. package/src/pages/Buttons.mdx +1 -1
  155. package/src/pages/Chips.mdx +1 -1
  156. package/src/pages/Forms.mdx +2 -2
  157. package/core/Accordion/component.js +0 -1
  158. package/core/ConnectStateWrapper/component.js +0 -1
  159. package/core/CookieMessage/component.js +0 -1
  160. package/core/CustomerLogos/component.js +0 -1
  161. package/core/DropdownMenu/component.js +0 -1
  162. package/core/FeaturedLink/component.js +0 -1
  163. package/core/Flash/component.js +0 -1
  164. package/core/Footer/component.js +0 -1
  165. package/core/Icon/component.js +0 -1
  166. package/core/Loader/component.js +0 -1
  167. package/core/Logo/component.js +0 -1
  168. package/core/MeganavContentCompany/component.js +0 -1
  169. package/core/MeganavContentDevelopers/component.js +0 -1
  170. package/core/MeganavContentProducts/component.js +0 -1
  171. package/core/MeganavContentUseCases/component.js +0 -1
  172. package/core/MeganavItemsDesktop/component.js +0 -1
  173. package/core/MeganavItemsMobile/component.js +0 -1
  174. package/core/MeganavItemsSignedIn/component.js +0 -1
  175. package/core/MeganavSearch/component.js +0 -1
  176. package/core/MeganavSearchPanel/component.js +0 -1
  177. package/core/SignOutLink/component.js +0 -1
  178. package/core/Table/index.js +0 -1
  179. package/core/Table/stories/data.js +0 -1
  180. package/core/Tooltip/component.js +0 -1
  181. package/src/core/Accordion/component.js +0 -0
  182. package/src/core/ConnectStateWrapper/component.js +0 -0
  183. package/src/core/CookieMessage/component.js +0 -1
  184. package/src/core/CustomerLogos/component.js +0 -0
  185. package/src/core/DropdownMenu/component.js +0 -0
  186. package/src/core/FeaturedLink/component.js +0 -0
  187. package/src/core/Flash/component.js +0 -1
  188. package/src/core/Footer/component.js +0 -1
  189. package/src/core/Icon/component.js +0 -0
  190. package/src/core/Loader/component.js +0 -0
  191. package/src/core/Logo/component.js +0 -0
  192. package/src/core/MeganavContentCompany/component.js +0 -0
  193. package/src/core/MeganavContentDevelopers/component.js +0 -0
  194. package/src/core/MeganavContentProducts/component.js +0 -0
  195. package/src/core/MeganavContentUseCases/component.js +0 -1
  196. package/src/core/MeganavItemsDesktop/component.js +0 -0
  197. package/src/core/MeganavItemsMobile/component.js +0 -0
  198. package/src/core/MeganavItemsSignedIn/component.js +0 -0
  199. package/src/core/MeganavSearch/component.js +0 -0
  200. package/src/core/MeganavSearchPanel/component.js +0 -0
  201. package/src/core/SignOutLink/component.js +0 -0
  202. package/src/core/Slider/component.tsx +0 -112
  203. /package/src/core/{CustomerLogos/component.tsx → CustomerLogos.tsx} +0 -0
  204. /package/src/core/{Icon/component.tsx → Icon.tsx} +0 -0
  205. /package/src/core/{Loader/component.tsx → Loader.tsx} +0 -0
  206. /package/src/core/{Logo/component.tsx → Logo.tsx} +0 -0
  207. /package/src/core/{MeganavSearchAutocomplete/component.tsx → MeganavSearchAutocomplete.tsx} +0 -0
  208. /package/src/core/Table/{stories/Table.stories.tsx → Table.stories.tsx} +0 -0
@@ -1,45 +1,98 @@
1
- import React, { ReactNode } from "react";
2
- import Slider from "./component.tsx";
1
+ import React from "react";
2
+ import Slider from "../Slider";
3
+ import Icon from "../Icon";
3
4
 
4
- export default {
5
- title: "Components/Slider",
6
- component: Slider,
7
- parameters: {
8
- layout: "fullscreen",
9
- },
10
- tags: ["autodocs"],
11
- };
5
+ const Slide = ({ name }: { name: string }) => (
6
+ <div className="relative ">
7
+ <div className="relative w-full sm:w-[560px] md:w-[784px] lg:w-[960px] bg-white overflow-hidden flex gap-40 rounded-3xl shadow-container-subtle">
8
+ <div className="w-full md:w-2/3 flex flex-col gap-24 pr-40 md:pr-0 pt-40 pl-40 pb-40 sm:pb-[120px] md:pb-40">
9
+ <h2 className="ui-text-h2 font-medium text-neutral-1000">
10
+ “Ably seamlessly absorbs sudden bursts in load during unexpected
11
+ client events. The integration was easy and we were live in under a
12
+ month.”
13
+ </h2>
14
+ <div className="flex flex-col sm:flex-row gap-32">
15
+ <div className="flex gap-8">
16
+ <div className="static self-center sm:absolute sm:-bottom-48 sm:-right-[56px] rounded-full bg-gradient-to-l from-neutral-200 to-50% to-neutral-500 w-[48px] h-[48px] sm:w-[201px] sm:h-[201px] md:w-[257px] md:h-[257px] lg:w-[280px] lg:h-[280px] overflow-hidden flex items-center justify-center sm:border-[16px] border-neutral-200">
17
+ <img src="https://picsum.photos/id/64/200" alt="test-image" />
18
+ </div>
19
+ <div className="sm:py-16">
20
+ <p className="ui-text-p1 text-neutral-1300">{name}</p>
21
+ <p className="ui-text-p3 text-neutral-800">
22
+ Co-Founder & Technical Leader
23
+ </p>
24
+ </div>
25
+ </div>
12
26
 
13
- const Slide = ({ children }: { children: ReactNode }) => (
14
- <div className="h-full p-24 bg-white rounded">
15
- <p className="ui-text-p2 text-center">{children}</p>
27
+ <div className="w-[80px] h-1 sm:w-1 sm:h-full bg-neutral-500"></div>
28
+ <div className="flex items-center gap-4">
29
+ <img src="https://picsum.photos/id/145/40" alt="test-image" />
30
+ <p className="ui-text-h4 font-bold">Mentimeter</p>
31
+ </div>
32
+ </div>
33
+ <a href="/case-study" className="ui-btn self-start">
34
+ Read case study
35
+ <Icon
36
+ name="icon-gui-arrow-right"
37
+ size="1.25rem"
38
+ additionalCSS="ml-4"
39
+ />
40
+ </a>
41
+ </div>
42
+ </div>
43
+
44
+ <div className="absolute h-256 -z-10 -bottom-48 -left-36 w-1/5 rounded-full blur-xl opacity-50 transform -rotate-45 bg-gradient-to-bl from-bg-glow-green to-bg-glow-teal"></div>
45
+ <div className="absolute h-256 -z-10 -top-48 -right-48 w-3/5 rounded-full blur-xl opacity-50 transform rotate-12 bg-gradient-to-br from-bg-glow-green to-bg-glow-teal"></div>
16
46
  </div>
17
47
  );
18
48
 
19
49
  const slides = [
20
- <Slide key="1">
21
- Powers live chat, updates, analytics, and composition for millions of users.
22
- </Slide>,
23
- <Slide key="2">
24
- Powers virtual venues for millions of event attendees around the world.
25
- </Slide>,
26
- <Slide key="3">
27
- Provides 5 million daily users with live financial commentary and stock
28
- tickers.
29
- </Slide>,
30
- <Slide key="4">Monitors live car performance data across the USA.</Slide>,
50
+ <Slide key="1" name={"Johan Bengtsson"} />,
51
+ <Slide key="2" name={"Mirko Bergman"} />,
52
+ <Slide key="3" name={"Stefania Lombardo"} />,
53
+ <Slide key="4" name={"Aleksandar Kostadinov"} />,
31
54
  ];
32
55
 
33
- export const SliderOnAllBreakpoints = {
56
+ export default {
57
+ title: "Components/Slider",
58
+ component: Slider,
59
+ args: {
60
+ children: slides,
61
+ options: {
62
+ interval: 10000,
63
+ intervalIndicator: true,
64
+ controlPosition: "floating",
65
+ },
66
+ },
67
+ };
68
+
69
+ export const FloatingControlPosition = {
70
+ args: {
71
+ children: slides,
72
+ options: {
73
+ interval: 10000,
74
+ intervalIndicator: true,
75
+ controlPosition: "floating",
76
+ },
77
+ },
78
+ };
79
+
80
+ export const InlineControlPosition = {
34
81
  args: {
35
- slides,
82
+ options: {
83
+ interval: 10000,
84
+ intervalIndicator: true,
85
+ controlPosition: "inline",
86
+ },
36
87
  },
37
88
  };
38
89
 
39
- export const SliderOnSmallBreakpointOnly = {
90
+ export const WithoutIntervalIndicator = {
40
91
  args: {
41
- slides,
42
- classes: `sm:grid-cols-${slides.length / 2} md:grid-cols-${slides.length}`,
43
- mqEnableThreshold: () => !window.matchMedia("(min-width: 48rem)").matches,
92
+ options: {
93
+ interval: 10000,
94
+ intervalIndicator: false,
95
+ controlPosition: "floating",
96
+ },
44
97
  },
45
98
  };
@@ -1,6 +1,40 @@
1
- .ui-slider-marker {
2
- font-size: 0.5rem;
3
- top: -1px;
1
+ @layer components {
2
+ .ui-slider-marker {
3
+ font-size: 0.5rem;
4
+ top: -1px;
4
5
 
5
- @apply leading-none px-4 relative;
6
+ @apply leading-none px-4 relative;
7
+ }
8
+
9
+ @keyframes fillAnimation {
10
+ 0% {
11
+ width: 0%;
12
+ }
13
+ 100% {
14
+ width: 100%;
15
+ }
16
+ }
17
+
18
+ .ui-icon-cta {
19
+ @apply cursor-pointer overflow-hidden;
20
+ @apply rounded border-2 border-mid-grey hover:border-active-orange;
21
+ transition: all 0.4s;
22
+ }
23
+
24
+ @screen sm {
25
+ .ui-icon-cta-left:hover .ui-icon-cta-holder {
26
+ transform: translateX(-120%);
27
+ }
28
+ .ui-icon-cta-right .ui-icon-cta-holder {
29
+ transform: translateX(-120%);
30
+ }
31
+ .ui-icon-cta-right:hover .ui-icon-cta-holder {
32
+ transform: translateX(0%);
33
+ }
34
+ }
35
+
36
+ .ui-icon-cta-holder {
37
+ @apply w-full h-full;
38
+ transition: all 0.4s;
39
+ }
6
40
  }
@@ -1,5 +1,3 @@
1
- import "./component.css";
2
-
3
1
  import throttle from "lodash.throttle";
4
2
 
5
3
  import { queryId, queryIdAll } from "../dom-query";
@@ -0,0 +1,224 @@
1
+ import React, { useState, useEffect, useRef, ReactNode } from "react";
2
+ import Icon from "./Icon";
3
+
4
+ interface SliderProps {
5
+ children: ReactNode[];
6
+ options?: {
7
+ interval?: number;
8
+ controlPosition?: "inline" | "floating";
9
+ intervalIndicator?: boolean;
10
+ };
11
+ }
12
+
13
+ interface SliderIndicatorProps {
14
+ numSlides: number;
15
+ activeIndex: number;
16
+ interval: number;
17
+ intervalIndicator?: boolean;
18
+ isInline?: boolean;
19
+ }
20
+
21
+ const SLIDE_TRANSITION_LENGTH = 300;
22
+
23
+ const SlideIndicator = ({
24
+ numSlides,
25
+ activeIndex,
26
+ interval,
27
+ intervalIndicator,
28
+ isInline,
29
+ }: SliderIndicatorProps) => {
30
+ return (
31
+ <ul
32
+ className={`flex gap-4 left-1/2 ${
33
+ isInline ? "bottom-0" : "absolute bottom-0 transform -translate-x-1/2"
34
+ }`}
35
+ >
36
+ {Array.from({ length: numSlides }, (_, i) =>
37
+ intervalIndicator ? (
38
+ <li
39
+ key={i}
40
+ className="relative w-40 h-4 mx-1 rounded-full bg-neutral-500"
41
+ >
42
+ {i === activeIndex && (
43
+ <span
44
+ className="absolute inset-0 rounded-full bg-active-orange"
45
+ style={{
46
+ animation: `fillAnimation ${interval}ms linear`,
47
+ }}
48
+ ></span>
49
+ )}
50
+ </li>
51
+ ) : (
52
+ <li key={i}>
53
+ <span
54
+ className={`ui-slider-marker ${
55
+ i === activeIndex ? "text-active-orange" : "text-cool-black"
56
+ }`}
57
+ data-id="slider-marker"
58
+ >
59
+ &#x2b24;
60
+ </span>
61
+ </li>
62
+ )
63
+ )}
64
+ </ul>
65
+ );
66
+ };
67
+
68
+ const setupSlides = (children: ReactNode[], activeIndex: number) => [
69
+ children[activeIndex === 0 ? children.length - 1 : activeIndex - 1],
70
+ children[activeIndex],
71
+ children[activeIndex === children.length - 1 ? 0 : activeIndex + 1],
72
+ ];
73
+
74
+ const Slider = ({ children, options }: SliderProps) => {
75
+ const [activeIndex, setActiveIndex] = useState(0);
76
+ const [touchStartX, setTouchStartX] = useState(0);
77
+ const [touchEndX, setTouchEndX] = useState(0);
78
+ const [slides, setSlides] = useState<ReactNode[]>(
79
+ setupSlides(children, activeIndex)
80
+ );
81
+ const [translationCoefficient, setTranslationCoefficient] = useState(0);
82
+ const timerRef = useRef<NodeJS.Timeout | null>(null);
83
+ const [slideLock, setSlideLock] = useState(false);
84
+
85
+ const isInline = options?.controlPosition === "inline";
86
+
87
+ const next = () => {
88
+ if (!slideLock) {
89
+ setActiveIndex((prevIndex) => (prevIndex + 1) % children.length);
90
+ setTranslationCoefficient(1);
91
+ resetInterval();
92
+ setSlideLock(true);
93
+ }
94
+ };
95
+
96
+ const prev = () => {
97
+ if (!slideLock) {
98
+ setActiveIndex((prevIndex) =>
99
+ prevIndex > 0 ? prevIndex - 1 : children.length - 1
100
+ );
101
+ setTranslationCoefficient(-1);
102
+ resetInterval();
103
+ setSlideLock(true);
104
+ }
105
+ };
106
+
107
+ const resetInterval = () => {
108
+ if (timerRef.current) clearInterval(timerRef.current);
109
+ timerRef.current = setInterval(next, options?.interval ?? 10000);
110
+ };
111
+
112
+ const handleTouchStart = (e) => {
113
+ setTouchStartX(e.touches[0].clientX);
114
+ };
115
+
116
+ const handleTouchMove = (e) => {
117
+ setTouchEndX(e.touches[0].clientX);
118
+ };
119
+
120
+ const handleTouchEnd = () => {
121
+ if (touchStartX - touchEndX > 50) {
122
+ next();
123
+ }
124
+ if (touchStartX - touchEndX < -50) {
125
+ prev();
126
+ }
127
+ };
128
+
129
+ useEffect(() => {
130
+ resetInterval();
131
+ return () => {
132
+ if (timerRef.current) clearInterval(timerRef.current);
133
+ };
134
+ }, [children.length, options?.interval]);
135
+
136
+ useEffect(() => {
137
+ setTimeout(() => {
138
+ setSlides(setupSlides(children, activeIndex));
139
+ setTranslationCoefficient(0);
140
+ setSlideLock(false);
141
+ }, SLIDE_TRANSITION_LENGTH);
142
+ }, [activeIndex]);
143
+
144
+ return (
145
+ <div
146
+ className="relative"
147
+ onTouchStart={handleTouchStart}
148
+ onTouchMove={handleTouchMove}
149
+ onTouchEnd={handleTouchEnd}
150
+ >
151
+ <div className="overflow-y-visible overflow-x-clip w-full py-40">
152
+ <div
153
+ className={`flex items-center ${
154
+ translationCoefficient !== 0
155
+ ? `transition-transform ease-in-out duration-${SLIDE_TRANSITION_LENGTH}`
156
+ : ""
157
+ } `}
158
+ style={{
159
+ transform: `translateX(-${(translationCoefficient + 1) * 100}%)`,
160
+ }}
161
+ >
162
+ {slides.map((child, index) => (
163
+ <div
164
+ key={index}
165
+ className="w-full flex-shrink-0 flex justify-center sm:px-60"
166
+ >
167
+ {child}
168
+ </div>
169
+ ))}
170
+ </div>
171
+ </div>
172
+
173
+ <div
174
+ className={`flex items-center pointer-events-none ${
175
+ isInline
176
+ ? "ui-standard-container justify-center gap-24 -mt-16"
177
+ : "sm:flex sm:absolute inset-0 justify-between"
178
+ }`}
179
+ >
180
+ <button
181
+ className={`${
182
+ isInline ? "w-32 h-32" : "hidden sm:flex w-48 h-48"
183
+ } pointer-events-auto rounded border border-mid-grey hover:border-active-orange flex justify-center items-center ui-icon-cta ui-icon-cta-left`}
184
+ onClick={prev}
185
+ >
186
+ <div className="ui-icon-cta-holder flex gap-4">
187
+ <div className="w-full h-full flex-shrink-0 flex items-center justify-center">
188
+ <Icon name="icon-gui-arrow-left" size="1.5rem" />
189
+ </div>
190
+ <div className="w-full h-full flex-shrink-0 flex items-center justify-center">
191
+ <Icon name="icon-gui-arrow-left" size="1.5rem" />
192
+ </div>
193
+ </div>
194
+ </button>
195
+
196
+ <SlideIndicator
197
+ numSlides={children.length}
198
+ activeIndex={activeIndex}
199
+ interval={options?.interval ?? 10000}
200
+ intervalIndicator={options?.intervalIndicator}
201
+ isInline={isInline}
202
+ />
203
+
204
+ <button
205
+ className={`${
206
+ isInline ? "w-32 h-32" : "hidden sm:flex w-48 h-48"
207
+ } pointer-events-auto rounded border border-mid-grey hover:border-active-orange justify-center items-center ui-icon-cta ui-icon-cta-right`}
208
+ onClick={next}
209
+ >
210
+ <div className="ui-icon-cta-holder flex gap-4">
211
+ <div className="w-full h-full flex-shrink-0 flex items-center justify-center">
212
+ <Icon name="icon-gui-arrow-right" size="1.5rem" />
213
+ </div>
214
+ <div className="w-full h-full flex-shrink-0 flex items-center justify-center">
215
+ <Icon name="icon-gui-arrow-right" size="1.5rem" />
216
+ </div>
217
+ </div>
218
+ </button>
219
+ </div>
220
+ </div>
221
+ );
222
+ };
223
+
224
+ export default Slider;
@@ -1,29 +1,57 @@
1
- import React, { PropsWithChildren, ReactElement, cloneElement } from "react";
1
+ import React, {
2
+ PropsWithChildren,
3
+ ReactElement,
4
+ TableHTMLAttributes,
5
+ cloneElement,
6
+ } from "react";
2
7
 
3
8
  type TableProps = {
4
9
  id?: string;
5
10
  };
6
11
 
7
- export const Table = ({ id, children }: PropsWithChildren<TableProps>) => (
8
- <table id={id} className="ui-standard-container mb-4 sm:table-fixed">
12
+ export const Table = ({
13
+ id,
14
+ children,
15
+ ...rest
16
+ }: PropsWithChildren<TableProps & TableHTMLAttributes<HTMLTableElement>>) => (
17
+ <table
18
+ id={id}
19
+ {...rest}
20
+ className={`ui-standard-container mb-4 sm:table-fixed ${
21
+ rest?.className ?? ""
22
+ }`}
23
+ >
9
24
  {children}
10
25
  </table>
11
26
  );
12
27
 
13
- export const TableBody = ({ children }: PropsWithChildren) => (
14
- <tbody>{children}</tbody>
28
+ export const TableBody = ({
29
+ children,
30
+ ...rest
31
+ }: PropsWithChildren<TableHTMLAttributes<HTMLTableSectionElement>>) => (
32
+ <tbody {...rest}>{children}</tbody>
15
33
  );
16
34
 
17
- export const TableHeader = ({ children }: PropsWithChildren) => (
18
- <thead className="sticky bg-white z-10 top-0" key="sticky-block">
35
+ export const TableHeader = ({
36
+ children,
37
+ ...rest
38
+ }: PropsWithChildren<TableHTMLAttributes<HTMLTableSectionElement>>) => (
39
+ <thead
40
+ {...rest}
41
+ className={`sticky bg-white z-10 top-0 ${rest?.className ?? ""}`}
42
+ >
19
43
  {cloneElement(children as ReactElement, { isHeader: true })}
20
44
  </thead>
21
45
  );
22
46
 
23
- export const TableRowHeader = ({ children }: PropsWithChildren) => (
47
+ export const TableRowHeader = ({
48
+ children,
49
+ ...rest
50
+ }: PropsWithChildren<TableHTMLAttributes<HTMLTableRowElement>>) => (
24
51
  <tr
25
- className="-ml-24 mt-8 sm:ml-0 sm:mt-0 ui-text-overline1 !text-cool-black bg-light-grey sm:sticky z-10"
26
- style={{ top: "4rem" }}
52
+ className={`-ml-24 mt-8 sm:ml-0 sm:mt-0 sm:sticky z-10 ${
53
+ rest?.className ?? ""
54
+ }`}
27
55
  >
28
56
  {cloneElement(children as ReactElement, { isRowHeader: true })}
29
57
  </tr>
@@ -1,37 +1,16 @@
1
1
  import React, { PropsWithChildren } from "react";
2
- import Icon from "../Icon/component.tsx";
3
2
 
4
3
  type TableCellProps = {
5
4
  isRowHeader?: boolean;
6
5
  } & React.TdHTMLAttributes<HTMLTableCellElement>;
7
6
 
8
- const Supported = () => (
9
- <Icon
10
- name="icon-gui-check-circled-fill"
11
- size="1.5rem"
12
- color="text-gui-success"
13
- additionalCSS="flex-grow-0 flex-shrink-0"
14
- data-testid="supported-icon"
15
- />
16
- );
17
-
18
- const Unsupported = () => (
19
- <Icon
20
- name="icon-gui-cross-circled-fill"
21
- size="1.5rem"
22
- color="text-gui-error"
23
- additionalCSS="flex-grow-0 flex-shrink-0"
24
- data-testid="unsupported-icon"
25
- />
26
- );
27
-
28
7
  const LabelCell = ({
29
8
  children,
30
9
  ...rest
31
10
  }: PropsWithChildren<React.TdHTMLAttributes<HTMLTableCellElement>>) => {
32
11
  const classes = `
33
- ui-text-p1 !font-bold pt-24 pb-8 border-light-grey sm:p-24 sm:relative sm:top-2 flex sm:table-cell ${
34
- rest.className ?? ""
12
+ ui-text-p1 font-bold pt-24 pb-8 border-light-grey sm:p-24 sm:relative sm:top-2 flex sm:table-cell ${
13
+ rest?.className ?? ""
35
14
  }
36
15
  `;
37
16
 
@@ -56,7 +35,7 @@ const TableCell = ({
56
35
  ? "rounded-l-none rounded-r sm:rounded-lg py-20 px-24"
57
36
  : "py-6"
58
37
  }
59
- ${rest.className ?? ""}
38
+ ${rest?.className ?? ""}
60
39
  `}
61
40
  >
62
41
  {children}
@@ -67,7 +46,12 @@ const HeaderCell = ({
67
46
  children,
68
47
  ...rest
69
48
  }: PropsWithChildren<React.TdHTMLAttributes<HTMLTableCellElement>>) => (
70
- <td {...rest} className="ui-text-h3 px-24 py-24 hidden sm:table-cell">
49
+ <td
50
+ {...rest}
51
+ className={`ui-text-h3 px-24 py-24 hidden sm:table-cell ${
52
+ rest?.className ?? ""
53
+ }`}
54
+ >
71
55
  {children}
72
56
  </td>
73
57
  );
@@ -76,9 +60,12 @@ const CtaCell = ({
76
60
  children,
77
61
  ...rest
78
62
  }: PropsWithChildren<React.TdHTMLAttributes<HTMLTableCellElement>>) => (
79
- <td {...rest} className="pt-24 hidden sm:table-cell">
63
+ <td
64
+ {...rest}
65
+ className={`pt-24 hidden sm:table-cell ${rest?.className ?? ""}`}
66
+ >
80
67
  {children}
81
68
  </td>
82
69
  );
83
70
 
84
- export { TableCell, LabelCell, HeaderCell, CtaCell, Supported, Unsupported };
71
+ export { TableCell, LabelCell, HeaderCell, CtaCell };
@@ -1,8 +1,28 @@
1
1
  import React, { Fragment } from "react";
2
2
 
3
- import Tooltip from "../../Tooltip/component";
4
- import { Supported, Unsupported } from "../TableCell";
5
- import Table from "..";
3
+ import Tooltip from "../Tooltip";
4
+ import Table from "../Table";
5
+ import Icon from "../Icon";
6
+
7
+ const Supported = () => (
8
+ <Icon
9
+ name="icon-gui-check-circled-fill"
10
+ size="1.5rem"
11
+ color="text-gui-success"
12
+ additionalCSS="flex-grow-0 flex-shrink-0"
13
+ data-testid="supported-icon"
14
+ />
15
+ );
16
+
17
+ const Unsupported = () => (
18
+ <Icon
19
+ name="icon-gui-cross-circled-fill"
20
+ size="1.5rem"
21
+ color="text-gui-error"
22
+ additionalCSS="flex-grow-0 flex-shrink-0"
23
+ data-testid="unsupported-icon"
24
+ />
25
+ );
6
26
 
7
27
  const testRow = (index) => ({
8
28
  label: `Label ${index + 1}`,
@@ -1,13 +1,6 @@
1
- import { Table, TableRowHeader, TableHeader, TableBody } from "./Table";
2
- import { TableRow } from "./TableRow";
3
- import {
4
- TableCell,
5
- LabelCell,
6
- HeaderCell,
7
- CtaCell,
8
- Supported,
9
- Unsupported,
10
- } from "./TableCell";
1
+ import { Table, TableRowHeader, TableHeader, TableBody } from "./Table/Table";
2
+ import { TableRow } from "./Table/TableRow";
3
+ import { TableCell, LabelCell, HeaderCell, CtaCell } from "./Table/TableCell";
11
4
 
12
5
  export default {
13
6
  Root: Table,
@@ -19,6 +12,4 @@ export default {
19
12
  RowHeader: TableRowHeader,
20
13
  Body: TableBody,
21
14
  Header: TableHeader,
22
- Supported,
23
- Unsupported,
24
15
  };
@@ -1,5 +1,5 @@
1
1
  import React from "react";
2
- import Tooltip from "./component";
2
+ import Tooltip from "../Tooltip";
3
3
 
4
4
  export default {
5
5
  title: "Components/Tooltip",
@@ -1,7 +1,24 @@
1
- import React, { PropsWithChildren, useEffect, useRef, useState } from "react";
2
- import Icon from "../Icon/component.tsx";
1
+ import React, {
2
+ ButtonHTMLAttributes,
3
+ HTMLAttributes,
4
+ PropsWithChildren,
5
+ useEffect,
6
+ useRef,
7
+ useState,
8
+ } from "react";
9
+ import Icon from "./Icon";
3
10
 
4
- const Tooltip = ({ children }: PropsWithChildren) => {
11
+ type TooltipProps = {
12
+ triggerProps?: ButtonHTMLAttributes<HTMLButtonElement>;
13
+ tooltipProps?: HTMLAttributes<HTMLDivElement>;
14
+ } & HTMLAttributes<HTMLDivElement>;
15
+
16
+ const Tooltip = ({
17
+ children,
18
+ triggerProps,
19
+ tooltipProps,
20
+ ...rest
21
+ }: PropsWithChildren<TooltipProps>) => {
5
22
  const [open, setOpen] = useState(false);
6
23
  const [position, setPosition] = useState({ x: 0, y: 0 });
7
24
  const offset = 8;
@@ -27,21 +44,28 @@ const Tooltip = ({ children }: PropsWithChildren) => {
27
44
  }, [open]);
28
45
 
29
46
  return (
30
- <div className="relative inline-block align-top h-16">
47
+ <div
48
+ {...rest}
49
+ className={`relative inline-block align-top h-16 ${
50
+ rest?.className ?? ""
51
+ }`}
52
+ >
31
53
  <button
32
54
  onMouseEnter={() => setOpen(true)}
33
55
  onMouseLeave={() => setOpen(false)}
34
- className="ml-8 p-0 relative top-1 focus:outline-none"
35
56
  type="button"
36
57
  ref={reference}
37
58
  aria-describedby="tooltip"
59
+ {...triggerProps}
60
+ className={`ml-8 p-0 relative top-1 focus:outline-none ${
61
+ triggerProps?.className ?? ""
62
+ }`}
38
63
  >
39
64
  <Icon name="icon-gui-info" size="1rem" />
40
65
  </button>
41
66
 
42
67
  {open ? (
43
68
  <div
44
- className="bg-light-grey p-12 rounded pointer-events-none absolute z-20"
45
69
  role="tooltip"
46
70
  ref={floating}
47
71
  style={{
@@ -49,6 +73,10 @@ const Tooltip = ({ children }: PropsWithChildren) => {
49
73
  left: -position.x,
50
74
  boxShadow: "4px 4px 15px rgba(0, 0, 0, 0.2)",
51
75
  }}
76
+ {...tooltipProps}
77
+ className={`bg-light-grey p-12 rounded pointer-events-none absolute z-20 ${
78
+ tooltipProps?.className ?? ""
79
+ }`}
52
80
  >
53
81
  <div className="w-256">{children}</div>
54
82
  </div>