@ably/ui 7.9.3 → 7.10.0-dev.caff705

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 (69) hide show
  1. package/core/Logo.jsx +16 -29
  2. package/core/Meganav/component.css +5 -1
  3. package/core/Meganav/component.js +2 -1
  4. package/core/Meganav/component.js.LICENSE.txt +7 -0
  5. package/core/Meganav.jsx +8106 -4763
  6. package/core/MeganavContentWhyAbly.jsx +2 -2
  7. package/core/MeganavControl/component.js +1 -1
  8. package/core/MeganavControl.jsx +5 -3
  9. package/core/MeganavItemsDesktop.jsx +5 -3
  10. package/core/MeganavItemsMobile.jsx +188 -11
  11. package/core/MeganavItemsSignedIn.jsx +259 -7
  12. package/core/MeganavSearch/component.js +1 -0
  13. package/core/MeganavSearch.jsx +504 -0
  14. package/core/MeganavSearchAutocomplete/component.js +2 -0
  15. package/core/MeganavSearchAutocomplete/component.js.LICENSE.txt +7 -0
  16. package/core/MeganavSearchAutocomplete.jsx +117 -0
  17. package/core/MeganavSearchPanel/component.js +1 -0
  18. package/core/MeganavSearchPanel.jsx +455 -0
  19. package/core/MeganavSearchSuggestions/component.js +1 -0
  20. package/core/MeganavSearchSuggestions.jsx +366 -0
  21. package/core/fonts/.DS_Store +0 -0
  22. package/core/images/.DS_Store +0 -0
  23. package/core/scripts.js +1 -1
  24. package/core/styles.css +2 -15
  25. package/package.json +2 -1
  26. package/preview/vendor/bundle/ruby/3.0.0/bundler/gems/ably-ui-abffd210ec0f/preview/log/.keep +0 -0
  27. package/preview/vendor/bundle/ruby/3.0.0/bundler/gems/ably-ui-abffd210ec0f/preview/tmp/.keep +0 -0
  28. package/preview/vendor/bundle/ruby/3.0.0/bundler/gems/ably-ui-abffd210ec0f/preview/tmp/pids/.keep +0 -0
  29. package/src/.DS_Store +0 -0
  30. package/src/core/.DS_Store +0 -0
  31. package/src/core/Logo/component.jsx +1 -1
  32. package/src/core/Meganav/component.css +5 -1
  33. package/src/core/Meganav/component.html.erb +10 -5
  34. package/src/core/Meganav/component.js +8 -0
  35. package/src/core/Meganav/component.jsx +12 -5
  36. package/src/core/MeganavContentWhyAbly/component.html.erb +1 -1
  37. package/src/core/MeganavContentWhyAbly/component.jsx +1 -1
  38. package/src/core/MeganavControl/component.html.erb +2 -2
  39. package/src/core/MeganavControl/component.js +37 -12
  40. package/src/core/MeganavControl/component.jsx +3 -2
  41. package/src/core/MeganavControl/component.rb +3 -1
  42. package/src/core/MeganavItemsMobile/component.html.erb +30 -2
  43. package/src/core/MeganavItemsMobile/component.jsx +33 -2
  44. package/src/core/MeganavItemsSignedIn/component.html.erb +5 -1
  45. package/src/core/MeganavItemsSignedIn/component.jsx +7 -2
  46. package/src/core/MeganavSearch/component.html.erb +15 -0
  47. package/src/core/MeganavSearch/component.js +0 -0
  48. package/src/core/MeganavSearch/component.jsx +33 -0
  49. package/src/core/MeganavSearch/component.rb +13 -0
  50. package/src/core/MeganavSearchAutocomplete/component.html.erb +6 -0
  51. package/src/core/MeganavSearchAutocomplete/component.js +170 -0
  52. package/src/core/MeganavSearchAutocomplete/component.jsx +14 -0
  53. package/src/core/MeganavSearchAutocomplete/component.rb +6 -0
  54. package/src/core/MeganavSearchPanel/component.html.erb +22 -0
  55. package/src/core/MeganavSearchPanel/component.js +0 -0
  56. package/src/core/MeganavSearchPanel/component.jsx +39 -0
  57. package/src/core/MeganavSearchPanel/component.rb +13 -0
  58. package/src/core/MeganavSearchSuggestions/component.html.erb +22 -0
  59. package/src/core/MeganavSearchSuggestions/component.js +123 -0
  60. package/src/core/MeganavSearchSuggestions/component.jsx +49 -0
  61. package/src/core/MeganavSearchSuggestions/component.rb +18 -0
  62. package/src/core/fonts/.DS_Store +0 -0
  63. package/src/core/images/.DS_Store +0 -0
  64. package/src/core/remote-blogs-posts.js +1 -1
  65. package/src/core/remote-session-data.js +1 -1
  66. package/src/core/styles/properties.css +2 -0
  67. package/src/core/styles.components.css +0 -15
  68. package/src/reset/.DS_Store +0 -0
  69. package/tailwind.config.js +2 -0
@@ -0,0 +1,39 @@
1
+ import React from "react";
2
+ import T from "prop-types";
3
+
4
+ import Icon from "../Icon/component.jsx";
5
+ import MeganavSearchSuggestions from "../MeganavSearchSuggestions/component.jsx";
6
+ import MeganavSearchAutocomplete from "../MeganavSearchAutocomplete/component.jsx";
7
+
8
+ const MeganavSearchPanel = ({ absUrl }) => {
9
+ return (
10
+ <section className="ui-meganav-content grid-cols-12">
11
+ <div className="col-span-8">
12
+ <div className="mb-32">
13
+ <form className="flex items-start" action={absUrl("/search")} method="get">
14
+ <div className="relative w-full">
15
+ <Icon name="icon-gui-search" color="text-cool-black" size="1.5rem" additionalCSS="absolute top-12 left-16" />
16
+ <input type="search" name="q" className="ui-input pl-48 h-48" placeholder="Search" autoComplete="off" data-id="meganav-search-input" />
17
+
18
+ <MeganavSearchAutocomplete />
19
+ </div>
20
+
21
+ <button type="submit" className="ui-btn-secondary ml-8 sm:ml-16 md:ml-24 xl:ml-32">
22
+ Search
23
+ </button>
24
+ </form>
25
+ </div>
26
+ </div>
27
+
28
+ <div className="col-span-12">
29
+ <MeganavSearchSuggestions displaySupportLink={true} absUrl={absUrl} />
30
+ </div>
31
+ </section>
32
+ );
33
+ };
34
+
35
+ MeganavSearchPanel.propTypes = {
36
+ absUrl: T.func,
37
+ };
38
+
39
+ export default MeganavSearchPanel;
@@ -0,0 +1,13 @@
1
+ module AblyUi
2
+ module Core
3
+ class MeganavSearchPanel < ViewComponent::Base
4
+ include Util
5
+
6
+ attr_reader :url_base
7
+
8
+ def initialize(url_base:)
9
+ @url_base = url_base
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,22 @@
1
+ <p class="ui-text-overline2 text-cool-black py-12">Popular pages</p>
2
+
3
+ <div class="flex justify-between items-center overflow-x-scroll md:overflow-auto">
4
+ <ul class="flex">
5
+ <li class="py-12 pr-8 flex-shrink-0">
6
+ <%= link_to 'How does Ably work?', abs_url("/docs/how-ably-works"), class: "ui-text-p2 hover:text-gui-hover active:text-gui-active focus:text-gui-focus" %>
7
+ </li>
8
+ <li class="py-12 px-8 flex-shrink-0">
9
+ <%= link_to 'Quickstart guide', abs_url("/docs/quick-start-guide"), class: "ui-text-p2 hover:text-gui-hover active:text-gui-active focus:text-gui-focus" %>
10
+ </li>
11
+ <li class="py-12 px-8 flex-shrink-0">
12
+ <%= link_to 'Publish/Subscribe Messaging', abs_url("/docs/core-features/pubsub"), class: "ui-text-p2 hover:text-gui-hover active:text-gui-active focus:text-gui-focus" %>
13
+ </li>
14
+ <li class="py-12 pl-8 flex-shrink-0">
15
+ <%= link_to 'Platform', abs_url("/docs/how-ably-works"), class: "ui-text-p2 hover:text-gui-hover active:text-gui-active focus:text-gui-focus" %>
16
+ </li>
17
+ </ul>
18
+
19
+ <% if display_support_link? %>
20
+ <%= render(AblyUi::Core::FeaturedLink.new(url: abs_url("/support"), text_size: "text-p2")) do %>Support<% end %>
21
+ <% end %>
22
+ </div>
@@ -0,0 +1,123 @@
1
+ import { queryId } from "../dom-query";
2
+
3
+ const DRAG_BUFFER = 5;
4
+
5
+ const getTranslateX = (node) =>
6
+ new DOMMatrix(window.getComputedStyle(node).transform).e;
7
+
8
+ const updateTranslateX = (node, value) =>
9
+ (node.style.transform = `translateX(${value}px)`);
10
+
11
+ const dragLeftBoundary = (translateX, threshold) => translateX >= threshold;
12
+
13
+ const dragRightBoundary = (translateX, itemsWidth, windowWidth, threshold) =>
14
+ Math.abs(translateX - windowWidth + threshold) > itemsWidth;
15
+
16
+ const getDistance = (e, touchStartX) =>
17
+ e.changedTouches[0]?.clientX - touchStartX;
18
+
19
+ const withinBuffer = (distance) => Math.abs(distance) < DRAG_BUFFER;
20
+
21
+ const MeganavSearchSuggestions = () => {
22
+ const suggestionsToggle = queryId("meganav-mobile-search-input");
23
+ const suggestions = queryId("meganav-mobile-search-suggestions");
24
+ const list = suggestions.querySelector("ul");
25
+ const listItems = list.querySelectorAll("li");
26
+
27
+ const itemsTotalWidth = Array.from(listItems)
28
+ .map((item) => item.getBoundingClientRect().width)
29
+ .reduce((acc, val) => acc + val, 0);
30
+
31
+ const dragLeft = (distance, threshold) => {
32
+ const currentTranslateX = getTranslateX(list);
33
+ const translateX = Math.round(currentTranslateX + distance);
34
+ if (dragLeftBoundary(translateX, threshold)) return;
35
+ updateTranslateX(list, translateX);
36
+ };
37
+
38
+ const dragLeftEnd = (distance, threshold) => {
39
+ const currentTranslateX = getTranslateX(list);
40
+ let translateX = Math.round(currentTranslateX + distance);
41
+
42
+ if (dragLeftBoundary(translateX, threshold)) {
43
+ translateX = 0;
44
+ }
45
+
46
+ updateTranslateX(list, translateX);
47
+ };
48
+
49
+ const dragRight = (distance, threshold) => {
50
+ const listWidth = list.getBoundingClientRect().width;
51
+ const currentTranslateX = getTranslateX(list);
52
+ const translateX = Math.round(currentTranslateX + distance);
53
+
54
+ if (dragRightBoundary(translateX, itemsTotalWidth, listWidth, threshold)) {
55
+ return;
56
+ }
57
+
58
+ updateTranslateX(list, translateX);
59
+ };
60
+
61
+ const dragRightEnd = (distance, threshold) => {
62
+ const listWidth = list.getBoundingClientRect().width;
63
+ const currentTranslateX = getTranslateX(list);
64
+ let translateX = Math.round(currentTranslateX + distance);
65
+
66
+ if (dragRightBoundary(translateX, itemsTotalWidth, listWidth, threshold)) {
67
+ translateX = -(itemsTotalWidth - listWidth + threshold);
68
+ }
69
+
70
+ updateTranslateX(list, translateX);
71
+ };
72
+
73
+ let touchStartX;
74
+
75
+ const touchstartHandler = (e) => {
76
+ touchStartX = e.touches[0]?.clientX;
77
+ };
78
+
79
+ const touchmoveHandler = (e) => {
80
+ const distance = getDistance(e, touchStartX);
81
+ if (withinBuffer(distance)) return;
82
+ distance > 0 ? dragLeft(distance, 24) : dragRight(distance, 96);
83
+ };
84
+
85
+ const touchendHandler = (e) => {
86
+ const distance = getDistance(e, touchStartX);
87
+ if (withinBuffer(distance)) return;
88
+ distance > 0 ? dragLeftEnd(distance, 24) : dragRightEnd(distance, 48);
89
+ };
90
+
91
+ const focusSuggestionsHandler = () => {
92
+ suggestions.classList.add("max-h-96");
93
+ };
94
+
95
+ const blurSuggestionsHandler = (e) => {
96
+ if (e.relatedTarget === suggestions.querySelectorAll("a")[0]) {
97
+ return;
98
+ }
99
+ suggestions.classList.remove("max-h-96");
100
+ };
101
+
102
+ suggestionsToggle.addEventListener("focus", focusSuggestionsHandler);
103
+ suggestionsToggle.addEventListener("blur", blurSuggestionsHandler);
104
+ suggestions.addEventListener("touchstart", touchstartHandler);
105
+ suggestions.addEventListener("touchmove", touchmoveHandler);
106
+ suggestions.addEventListener("touchend", touchendHandler);
107
+
108
+ return {
109
+ teardown: () => {
110
+ suggestionsToggle.removeEventListener("focus", focusSuggestionsHandler);
111
+ suggestionsToggle.removeEventListener("blur", blurSuggestionsHandler);
112
+ suggestions.removeEventListener("touchstart", touchstartHandler);
113
+ suggestions.removeEventListener("touchmove", touchmoveHandler);
114
+ suggestions.removeEventListener("touchend", touchendHandler);
115
+ },
116
+ clear: () => {
117
+ suggestions.classList.remove("max-h-96");
118
+ list.style.transform = `translateX(0px)`;
119
+ },
120
+ };
121
+ };
122
+
123
+ export default MeganavSearchSuggestions;
@@ -0,0 +1,49 @@
1
+ import React from "react";
2
+ import T from "prop-types";
3
+
4
+ import FeaturedLink from "../FeaturedLink/component.jsx";
5
+
6
+ const MeganavSearchSuggestions = ({ absUrl, displaySupportLink }) => {
7
+ return (
8
+ <>
9
+ <p className="ui-text-overline2 text-cool-black py-12">Popular pages</p>
10
+
11
+ <div className="flex justify-between items-center overflow-hidden">
12
+ <ul className="flex transition-transform">
13
+ <li className="py-12 pr-8 flex-shrink-0">
14
+ <a href={absUrl("/docs/how-ably-works")} className="ui-text-p2 hover:text-gui-hover active:text-gui-active focus:text-gui-focus">
15
+ How does Ably work?
16
+ </a>
17
+ </li>
18
+ <li className="py-12 px-8 flex-shrink-0">
19
+ <a href={absUrl("/docs/quick-start-guide")} className="ui-text-p2 hover:text-gui-hover active:text-gui-active focus:text-gui-focus">
20
+ Quickstart guide
21
+ </a>
22
+ </li>
23
+ <li className="py-12 px-8 flex-shrink-0">
24
+ <a href={absUrl("/docs/core-features/pubsub")} className="ui-text-p2 hover:text-gui-hover active:text-gui-active focus:text-gui-focus">
25
+ Publish/Subscribe Messaging
26
+ </a>
27
+ </li>
28
+ <li className="py-12 pl-8 flex-shrink-0">
29
+ <a href={absUrl("/platform")} className="ui-text-p2 hover:text-gui-hover active:text-gui-active focus:text-gui-focus">
30
+ Platform
31
+ </a>
32
+ </li>
33
+ </ul>
34
+ {displaySupportLink ? (
35
+ <FeaturedLink url={absUrl("/support")} textSize="text-p2">
36
+ Support
37
+ </FeaturedLink>
38
+ ) : null}
39
+ </div>
40
+ </>
41
+ );
42
+ };
43
+
44
+ MeganavSearchSuggestions.propTypes = {
45
+ absUrl: T.func,
46
+ displaySupportLink: T.bool,
47
+ };
48
+
49
+ export default MeganavSearchSuggestions;
@@ -0,0 +1,18 @@
1
+ module AblyUi
2
+ module Core
3
+ class MeganavSearchSuggestions < ViewComponent::Base
4
+ include Util
5
+
6
+ attr_reader :url_base
7
+
8
+ def initialize(url_base:, display_support_link: true)
9
+ @url_base = url_base
10
+ @display_support_link = display_support_link
11
+ end
12
+
13
+ def display_support_link?
14
+ @display_support_link
15
+ end
16
+ end
17
+ end
18
+ end
Binary file
Binary file
@@ -3,7 +3,7 @@ import { isJsonResponse } from "./remote-data-util";
3
3
  const fetchBlogPosts = async (store, blogUrl) => {
4
4
  try {
5
5
  if (!blogUrl) {
6
- console.warn(
6
+ console.log(
7
7
  `Skipping fetching blog posts, invalid blogUrl: "${blogUrl}"`
8
8
  );
9
9
  return;
@@ -11,7 +11,7 @@ const fetchSessionData = async (store, sessionUrl) => {
11
11
 
12
12
  try {
13
13
  if (!sessionUrl) {
14
- console.warn(
14
+ console.log(
15
15
  `Skipping fetching session, invalid sessionUrl: "${sessionUrl}"`
16
16
  );
17
17
  sessionLoaded();
@@ -117,7 +117,9 @@
117
117
 
118
118
  --spacing-0: 0px;
119
119
  --spacing-1: 1px;
120
+ --spacing-2: 0.125rem;
120
121
  --spacing-4: 0.25rem;
122
+ --spacing-6: 0.375rem;
121
123
  --spacing-8: 0.5rem;
122
124
  --spacing-12: 0.75rem;
123
125
  --spacing-14: 0.875rem;
@@ -24,21 +24,6 @@
24
24
  stroke: var(--color-dark-grey);
25
25
  }
26
26
 
27
- /* Extend how tailwind does group hover for icons */
28
- .group {
29
- &:hover {
30
- .group-hover\:icon-gui-hover {
31
- stroke: var(--color-gui-hover);
32
- }
33
- }
34
-
35
- &:focus {
36
- .group-focus\:icon-gui-focus {
37
- stroke: var(--color-gui-focus);
38
- }
39
- }
40
- }
41
-
42
27
  .ui-version-tag {
43
28
  @apply inline-block absolute align-top uppercase font-bold whitespace-nowrap;
44
29
 
Binary file
@@ -114,7 +114,9 @@ module.exports = {
114
114
  spacing: {
115
115
  0: "var(--spacing-0)",
116
116
  1: "var(--spacing-1)",
117
+ 2: "var(--spacing-2)",
117
118
  4: "var(--spacing-4)",
119
+ 6: "var(--spacing-6)",
118
120
  8: "var(--spacing-8)",
119
121
  12: "var(--spacing-12)",
120
122
  14: "var(--spacing-14)",