@ably/ui 7.10.0-dev.e980a00 → 8.0.0-dev.27cfcb9
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/core/Meganav/component.js +1 -1
- package/core/Meganav.jsx +8463 -6601
- package/core/MeganavContentPlatform.jsx +27 -20
- package/core/MeganavControlMobileDropdown/component.js +1 -1
- package/core/MeganavItemsMobile.jsx +7 -6
- package/core/MeganavItemsSignedIn.jsx +10 -9
- package/core/MeganavSearch.jsx +10 -9
- package/core/MeganavSearchAutocomplete/component.js +1 -1
- package/core/MeganavSearchPanel.jsx +8 -7
- package/core/MeganavSearchSuggestions/component.js +1 -1
- package/core/MeganavSearchSuggestions.jsx +6 -6
- package/core/fonts/source-code-pro.css +3 -0
- package/core/styles.css +17 -22
- package/package.json +2 -2
- package/src/core/Code/component.css +1 -3
- package/src/core/Meganav/component.js +8 -2
- package/src/core/Meganav/component.jsx +3 -2
- package/src/core/MeganavContentPlatform/component.html.erb +24 -18
- package/src/core/MeganavContentPlatform/component.jsx +25 -20
- package/src/core/MeganavControlMobileDropdown/component.js +0 -31
- package/src/core/MeganavItemsMobile/component.html.erb +1 -0
- package/src/core/MeganavItemsMobile/component.jsx +1 -0
- package/src/core/MeganavItemsSignedIn/component.html.erb +2 -2
- package/src/core/MeganavSearch/component.html.erb +2 -2
- package/src/core/MeganavSearch/component.jsx +2 -2
- package/src/core/MeganavSearchAutocomplete/component.js +18 -10
- package/src/core/MeganavSearchPanel/component.html.erb +4 -4
- package/src/core/MeganavSearchPanel/component.jsx +2 -2
- package/src/core/MeganavSearchSuggestions/component.html.erb +6 -6
- package/src/core/MeganavSearchSuggestions/component.js +123 -0
- package/src/core/MeganavSearchSuggestions/component.jsx +6 -6
- package/src/core/fonts/source-code-pro.css +3 -0
- package/src/core/styles/properties.css +4 -3
- package/src/core/styles/text.css +12 -16
- package/tailwind.config.js +12 -4
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
<section class="ui-meganav-content grid-cols-12">
|
|
2
2
|
<div class="col-span-8">
|
|
3
3
|
<div class="mb-32">
|
|
4
|
-
|
|
4
|
+
<%= tag.form class: "flex items-start", action: abs_url("/search"), method: "get" do %>
|
|
5
5
|
<div class="relative w-full">
|
|
6
6
|
<%= render(AblyUi::Core::Icon.new(name: "icon-gui-search", size: "1.5rem", color: "text-cool-black", additional_css:"absolute top-12 left-16")) %>
|
|
7
|
-
<input type="search" name="q" class="ui-input pl-48 h-48" placeholder="Search" data-id="meganav-search-input" />
|
|
7
|
+
<input type="search" name="q" class="ui-input pl-48 h-48" placeholder="Search" autocomplete="off" data-id="meganav-search-input" />
|
|
8
8
|
|
|
9
9
|
<%= render(AblyUi::Core::MeganavSearchAutocomplete.new) %>
|
|
10
10
|
</div>
|
|
11
11
|
|
|
12
|
-
<button type="submit" class="ui-btn-secondary ml-8 sm:ml-16 md:ml-24 xl:ml-32">
|
|
12
|
+
<button type="submit" class="ui-btn-secondary flex-shrink-0 ml-8 sm:ml-16 md:ml-24 xl:ml-32">
|
|
13
13
|
Search
|
|
14
14
|
</button>
|
|
15
|
-
|
|
15
|
+
<% end %>
|
|
16
16
|
</div>
|
|
17
17
|
</div>
|
|
18
18
|
|
|
@@ -13,12 +13,12 @@ const MeganavSearchPanel = ({ absUrl }) => {
|
|
|
13
13
|
<form className="flex items-start" action={absUrl("/search")} method="get">
|
|
14
14
|
<div className="relative w-full">
|
|
15
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" data-id="meganav-search-input" />
|
|
16
|
+
<input type="search" name="q" className="ui-input pl-48 h-48" placeholder="Search" autoComplete="off" data-id="meganav-search-input" />
|
|
17
17
|
|
|
18
18
|
<MeganavSearchAutocomplete />
|
|
19
19
|
</div>
|
|
20
20
|
|
|
21
|
-
<button type="submit" className="ui-btn-secondary ml-8 sm:ml-16 md:ml-24 xl:ml-32">
|
|
21
|
+
<button type="submit" className="ui-btn-secondary flex-shrink-0 ml-8 sm:ml-16 md:ml-24 xl:ml-32">
|
|
22
22
|
Search
|
|
23
23
|
</button>
|
|
24
24
|
</form>
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
<p class="ui-text-overline2 text-cool-black py-12">Popular pages</p>
|
|
2
2
|
|
|
3
|
-
<div class="flex justify-between items-center overflow-
|
|
4
|
-
<ul class="flex">
|
|
3
|
+
<div class="flex justify-between items-center overflow-hidden">
|
|
4
|
+
<ul class="flex transition-transform">
|
|
5
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" %>
|
|
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
7
|
</li>
|
|
8
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" %>
|
|
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
10
|
</li>
|
|
11
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" %>
|
|
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
13
|
</li>
|
|
14
14
|
<li class="py-12 pl-8 flex-shrink-0">
|
|
15
|
-
<%= link_to 'Platform', abs_url("/docs/how-ably-works"), class: "ui-text-p2" %>
|
|
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
16
|
</li>
|
|
17
17
|
</ul>
|
|
18
18
|
|
|
@@ -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;
|
|
@@ -8,25 +8,25 @@ const MeganavSearchSuggestions = ({ absUrl, displaySupportLink }) => {
|
|
|
8
8
|
<>
|
|
9
9
|
<p className="ui-text-overline2 text-cool-black py-12">Popular pages</p>
|
|
10
10
|
|
|
11
|
-
<div className="flex justify-between items-center overflow-
|
|
12
|
-
<ul className="flex">
|
|
11
|
+
<div className="flex justify-between items-center overflow-hidden">
|
|
12
|
+
<ul className="flex transition-transform">
|
|
13
13
|
<li className="py-12 pr-8 flex-shrink-0">
|
|
14
|
-
<a href={absUrl("/docs/how-ably-works")} className="ui-text-p2">
|
|
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
15
|
How does Ably work?
|
|
16
16
|
</a>
|
|
17
17
|
</li>
|
|
18
18
|
<li className="py-12 px-8 flex-shrink-0">
|
|
19
|
-
<a href={absUrl("/docs/quick-start-guide")} className="ui-text-p2">
|
|
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
20
|
Quickstart guide
|
|
21
21
|
</a>
|
|
22
22
|
</li>
|
|
23
23
|
<li className="py-12 px-8 flex-shrink-0">
|
|
24
|
-
<a href={absUrl("/docs/core-features/pubsub")} className="ui-text-p2">
|
|
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
25
|
Publish/Subscribe Messaging
|
|
26
26
|
</a>
|
|
27
27
|
</li>
|
|
28
28
|
<li className="py-12 pl-8 flex-shrink-0">
|
|
29
|
-
<a href={absUrl("/platform")} className="ui-text-p2">
|
|
29
|
+
<a href={absUrl("/platform")} className="ui-text-p2 hover:text-gui-hover active:text-gui-active focus:text-gui-focus">
|
|
30
30
|
Platform
|
|
31
31
|
</a>
|
|
32
32
|
</li>
|
|
@@ -15,9 +15,10 @@
|
|
|
15
15
|
--color-charcoal-grey: #292831;
|
|
16
16
|
--color-gui-default: #0073e6;
|
|
17
17
|
--color-gui-hover: #0867c4;
|
|
18
|
-
--color-gui-focus: #
|
|
18
|
+
--color-gui-focus: #0073e6;
|
|
19
|
+
--color-gui-focus-outline: #80b9f2;
|
|
19
20
|
--color-gui-active: #074095;
|
|
20
|
-
--color-gui-
|
|
21
|
+
--color-gui-visited: #4887c2;
|
|
21
22
|
--color-gui-unavailable: #a8a8a8;
|
|
22
23
|
--color-gui-error: #fb0c0c;
|
|
23
24
|
--color-gui-success: #11cb24;
|
|
@@ -157,7 +158,7 @@
|
|
|
157
158
|
/* In components, when looking at implementing viewport margin and spacing between elements,
|
|
158
159
|
the values in the comments can be used as guide as they represent the grid the elements (should) sit on.
|
|
159
160
|
alternatively, look for ui-grid-* helpers. */
|
|
160
|
-
--bp-xs:
|
|
161
|
+
--bp-xs: 428px; /* gutters 8px, side-margin 24px */
|
|
161
162
|
--bp-sm: 768px; /* gutters 16px, side-margin 32px */
|
|
162
163
|
--bp-md: 1040px; /* gutters 24px, side-margin 40px, meganav desktop */
|
|
163
164
|
--bp-lg: 1280px; /* gutters 24px, side-margin 64px */
|
package/src/core/styles/text.css
CHANGED
|
@@ -30,17 +30,17 @@
|
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
.ui-text-p1 {
|
|
33
|
-
@apply font-sans font-light text-
|
|
33
|
+
@apply font-sans font-light text-charcoal-grey;
|
|
34
34
|
@apply text-p1;
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
.ui-text-p2 {
|
|
38
|
-
@apply font-sans font-light text-
|
|
38
|
+
@apply font-sans font-light text-charcoal-grey;
|
|
39
39
|
@apply text-p2;
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
.ui-text-p3 {
|
|
43
|
-
@apply font-sans font-light text-
|
|
43
|
+
@apply font-sans font-light text-charcoal-grey;
|
|
44
44
|
@apply text-p3;
|
|
45
45
|
}
|
|
46
46
|
|
|
@@ -146,21 +146,17 @@
|
|
|
146
146
|
@apply list-square;
|
|
147
147
|
}
|
|
148
148
|
|
|
149
|
-
/* visited needs to come before :hover et all else it overrides them */
|
|
150
|
-
.ui-link:visited {
|
|
151
|
-
@apply text-gui-viewed;
|
|
152
|
-
}
|
|
153
|
-
|
|
154
149
|
.ui-link {
|
|
155
|
-
@apply
|
|
156
|
-
text-
|
|
157
|
-
text-
|
|
158
|
-
|
|
159
|
-
text-decoration-thickness: 0.125rem;
|
|
150
|
+
@apply visited:text-gui-visited;
|
|
151
|
+
@apply hover:text-gui-hover active:text-gui-active disabled:text-gui-unavailable;
|
|
152
|
+
@apply focus:text-gui-focus focus:outline-gui-focus;
|
|
153
|
+
@apply underline;
|
|
160
154
|
}
|
|
161
155
|
|
|
162
|
-
.ui-link
|
|
163
|
-
@apply
|
|
164
|
-
text-
|
|
156
|
+
.ui-link-neutral {
|
|
157
|
+
@apply visited:text-dark-grey;
|
|
158
|
+
@apply hover:text-dark-grey active:text-cool-black disabled:text-gui-unavailable;
|
|
159
|
+
@apply focus:text-gui-focus focus:outline-gui-focus-neutral;
|
|
160
|
+
@apply underline;
|
|
165
161
|
}
|
|
166
162
|
}
|
package/tailwind.config.js
CHANGED
|
@@ -17,7 +17,7 @@ module.exports = {
|
|
|
17
17
|
theme: {
|
|
18
18
|
screens: {
|
|
19
19
|
// CSS custom properties can't be used in media queries
|
|
20
|
-
xs: "
|
|
20
|
+
xs: "428px",
|
|
21
21
|
sm: "768px",
|
|
22
22
|
md: "1040px",
|
|
23
23
|
lg: "1280px",
|
|
@@ -74,7 +74,7 @@ module.exports = {
|
|
|
74
74
|
"gui-hover": "var(--color-gui-hover)",
|
|
75
75
|
"gui-focus": "var(--color-gui-focus)",
|
|
76
76
|
"gui-active": "var(--color-gui-active)",
|
|
77
|
-
"gui-
|
|
77
|
+
"gui-visited": "var(--color-gui-visited)",
|
|
78
78
|
"gui-unavailable": "var(--color-gui-unavailable)",
|
|
79
79
|
"gui-error": "var(--color-gui-error)",
|
|
80
80
|
"gui-success": "var(--color-gui-success)",
|
|
@@ -183,7 +183,8 @@ module.exports = {
|
|
|
183
183
|
filter: "filter",
|
|
184
184
|
},
|
|
185
185
|
outline: {
|
|
186
|
-
"gui-focus": "
|
|
186
|
+
"gui-focus": "1.5px solid var(--color-gui-focus-outline)",
|
|
187
|
+
"gui-focus-neutral": "2px solid var(--color-white)",
|
|
187
188
|
},
|
|
188
189
|
width: {
|
|
189
190
|
"extend-8": "calc(100% + var(--spacing-8))",
|
|
@@ -210,7 +211,14 @@ module.exports = {
|
|
|
210
211
|
variants: {
|
|
211
212
|
extend: {
|
|
212
213
|
borderColor: ["hover", "focus", "active", "group-focus", "disabled"],
|
|
213
|
-
textColor: [
|
|
214
|
+
textColor: [
|
|
215
|
+
"hover",
|
|
216
|
+
"focus",
|
|
217
|
+
"active",
|
|
218
|
+
"group-focus",
|
|
219
|
+
"disabled",
|
|
220
|
+
"visited",
|
|
221
|
+
],
|
|
214
222
|
display: ["group-focus"],
|
|
215
223
|
backgroundColor: ["hover", "focus", "active", "group-focus", "disabled"],
|
|
216
224
|
backgroundImage: ["hover", "active", "focus"],
|