@ably/ui 14.0.5 → 14.0.6
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/Flash.js +1 -1
- package/package.json +7 -9
- package/src/core/Accordion/Accordion.stories.tsx +0 -39
- package/src/core/Accordion.tsx +0 -149
- package/src/core/Code/Code.stories.tsx +0 -71
- package/src/core/Code/component.css +0 -1
- package/src/core/Code/component.js +0 -27
- package/src/core/Code.tsx +0 -44
- package/src/core/ConnectStateWrapper.tsx +0 -43
- package/src/core/ContactFooter/ContactFooter.stories.tsx +0 -11
- package/src/core/ContactFooter/component.css +0 -11
- package/src/core/ContactFooter/component.js +0 -2
- package/src/core/ContactFooter.tsx +0 -91
- package/src/core/CookieMessage/CookieMessage.stories.tsx +0 -12
- package/src/core/CookieMessage/component.css +0 -15
- package/src/core/CookieMessage.tsx +0 -52
- package/src/core/CustomerLogos/CustomerLogos.stories.tsx +0 -43
- package/src/core/CustomerLogos.tsx +0 -35
- package/src/core/DropdownMenu/DropdownMenu.stories.tsx +0 -48
- package/src/core/DropdownMenu.tsx +0 -140
- package/src/core/Expander/Expander.stories.tsx +0 -132
- package/src/core/Expander.tsx +0 -63
- package/src/core/FeaturedLink/FeaturedLink.stories.tsx +0 -43
- package/src/core/FeaturedLink.tsx +0 -93
- package/src/core/Flash/Flash.stories.tsx +0 -37
- package/src/core/Flash/component.css +0 -28
- package/src/core/Flash.tsx +0 -233
- package/src/core/Footer/Footer.stories.tsx +0 -26
- package/src/core/Footer/component.css +0 -33
- package/src/core/Footer.tsx +0 -535
- package/src/core/Icon/Icon.stories.tsx +0 -151
- package/src/core/Icon.tsx +0 -26
- package/src/core/Loader/Loader.stories.tsx +0 -21
- package/src/core/Loader.tsx +0 -52
- package/src/core/Logo/Logo.stories.tsx +0 -12
- package/src/core/Logo.tsx +0 -29
- package/src/core/Meganav/Meganav.stories.tsx +0 -86
- package/src/core/Meganav/component.css +0 -114
- package/src/core/Meganav/component.js +0 -150
- package/src/core/Meganav/component.json +0 -37
- package/src/core/Meganav.tsx +0 -225
- package/src/core/MeganavBlogPostsList/component.js +0 -43
- package/src/core/MeganavBlogPostsList.tsx +0 -41
- package/src/core/MeganavContentCompany.tsx +0 -166
- package/src/core/MeganavContentDevelopers.tsx +0 -210
- package/src/core/MeganavContentProducts.tsx +0 -163
- package/src/core/MeganavContentUseCases.tsx +0 -244
- package/src/core/MeganavControl/component.js +0 -117
- package/src/core/MeganavControl.tsx +0 -39
- package/src/core/MeganavControlMobileDropdown/component.js +0 -46
- package/src/core/MeganavControlMobileDropdown.tsx +0 -31
- package/src/core/MeganavControlMobilePanelClose/component.js +0 -36
- package/src/core/MeganavControlMobilePanelClose.tsx +0 -34
- package/src/core/MeganavControlMobilePanelOpen/component.js +0 -59
- package/src/core/MeganavControlMobilePanelOpen.tsx +0 -31
- package/src/core/MeganavItemsDesktop.tsx +0 -68
- package/src/core/MeganavItemsMobile.tsx +0 -197
- package/src/core/MeganavItemsSignedIn.tsx +0 -130
- package/src/core/MeganavSearch.tsx +0 -36
- package/src/core/MeganavSearchAutocomplete/component.js +0 -177
- package/src/core/MeganavSearchAutocomplete.tsx +0 -12
- package/src/core/MeganavSearchPanel.tsx +0 -52
- package/src/core/MeganavSearchSuggestions/component.js +0 -133
- package/src/core/MeganavSearchSuggestions.tsx +0 -62
- package/src/core/Notice/component.css +0 -7
- package/src/core/Notice/component.js +0 -154
- package/src/core/Notice.tsx +0 -102
- package/src/core/SignOutLink.tsx +0 -51
- package/src/core/Slider/Slider.stories.tsx +0 -98
- package/src/core/Slider/component.css +0 -40
- package/src/core/Slider/component.js +0 -105
- package/src/core/Slider.tsx +0 -224
- package/src/core/Table/Table.stories.tsx +0 -12
- package/src/core/Table/Table.tsx +0 -58
- package/src/core/Table/TableCell.tsx +0 -71
- package/src/core/Table/TableRow.tsx +0 -25
- package/src/core/Table/data.tsx +0 -133
- package/src/core/Table.tsx +0 -15
- package/src/core/Tooltip/Tooltip.stories.tsx +0 -27
- package/src/core/Tooltip.tsx +0 -88
- package/src/core/css.js +0 -3
- package/src/core/dom-query.js +0 -5
- package/src/core/fonts/NEXT-Book-Light-Italic.eot +0 -0
- package/src/core/fonts/NEXT-Book-Light-Italic.otf +0 -0
- package/src/core/fonts/NEXT-Book-Light-Italic.woff +0 -0
- package/src/core/fonts/NEXT-Book-Light-Italic.woff2 +0 -0
- package/src/core/fonts/NEXT-Book-Light.eot +0 -0
- package/src/core/fonts/NEXT-Book-Light.otf +0 -0
- package/src/core/fonts/NEXT-Book-Light.woff +0 -0
- package/src/core/fonts/NEXT-Book-Light.woff2 +0 -0
- package/src/core/fonts/NEXT-Book-Medium-Italic.eot +0 -0
- package/src/core/fonts/NEXT-Book-Medium-Italic.otf +0 -0
- package/src/core/fonts/NEXT-Book-Medium-Italic.woff +0 -0
- package/src/core/fonts/NEXT-Book-Medium-Italic.woff2 +0 -0
- package/src/core/fonts/NEXT-Book-Medium.eot +0 -0
- package/src/core/fonts/NEXT-Book-Medium.otf +0 -0
- package/src/core/fonts/NEXT-Book-Medium.woff +0 -0
- package/src/core/fonts/NEXT-Book-Medium.woff2 +0 -0
- package/src/core/fonts/jetBrains-mono.css +0 -3
- package/src/core/fonts/manrope.css +0 -3
- package/src/core/fonts/next.css +0 -63
- package/src/core/fonts/source-code-pro.css +0 -3
- package/src/core/hubspot-chat-toggle.js +0 -67
- package/src/core/icons/discord.svg +0 -10
- package/src/core/icons/facebook.svg +0 -4
- package/src/core/icons/github.svg +0 -3
- package/src/core/icons/glassdoor.svg +0 -3
- package/src/core/icons/google.svg +0 -3
- package/src/core/icons/icon-display-48hrs.svg +0 -3
- package/src/core/icons/icon-display-about-ably-col.svg +0 -4
- package/src/core/icons/icon-display-api-keys.svg +0 -3
- package/src/core/icons/icon-display-api.svg +0 -3
- package/src/core/icons/icon-display-asset-tracking-col.svg +0 -18
- package/src/core/icons/icon-display-browser.svg +0 -10
- package/src/core/icons/icon-display-calendar.svg +0 -3
- package/src/core/icons/icon-display-call-mobile.svg +0 -3
- package/src/core/icons/icon-display-careers-col.svg +0 -9
- package/src/core/icons/icon-display-case-studies-col.svg +0 -5
- package/src/core/icons/icon-display-chat-col.svg +0 -4
- package/src/core/icons/icon-display-chat-stack-col.svg +0 -4
- package/src/core/icons/icon-display-chat-stack.svg +0 -4
- package/src/core/icons/icon-display-cloud-servers.svg +0 -3
- package/src/core/icons/icon-display-compare-tech-col.svg +0 -9
- package/src/core/icons/icon-display-customers-col.svg +0 -15
- package/src/core/icons/icon-display-data-broadcast-col.svg +0 -26
- package/src/core/icons/icon-display-data-synchronization-col.svg +0 -14
- package/src/core/icons/icon-display-docs-col.svg +0 -7
- package/src/core/icons/icon-display-documentation.svg +0 -3
- package/src/core/icons/icon-display-events-col.svg +0 -13
- package/src/core/icons/icon-display-examples-col.svg +0 -11
- package/src/core/icons/icon-display-gdpr.svg +0 -3
- package/src/core/icons/icon-display-general-comms.svg +0 -3
- package/src/core/icons/icon-display-hipaa.svg +0 -10
- package/src/core/icons/icon-display-integrations-col.svg +0 -8
- package/src/core/icons/icon-display-it-support-access.svg +0 -3
- package/src/core/icons/icon-display-it-support-helpdesk.svg +0 -3
- package/src/core/icons/icon-display-kafka-at-the-edge-col.svg +0 -8
- package/src/core/icons/icon-display-laptop.svg +0 -10
- package/src/core/icons/icon-display-lightbulb-col.svg +0 -10
- package/src/core/icons/icon-display-live-chat.svg +0 -3
- package/src/core/icons/icon-display-map-pin.svg +0 -3
- package/src/core/icons/icon-display-message.svg +0 -3
- package/src/core/icons/icon-display-padlock-closed.svg +0 -3
- package/src/core/icons/icon-display-platform.svg +0 -22
- package/src/core/icons/icon-display-play.svg +0 -3
- package/src/core/icons/icon-display-privacy-shield-framework.svg +0 -7
- package/src/core/icons/icon-display-push-notifications-col.svg +0 -6
- package/src/core/icons/icon-display-quickstart-guides-col.svg +0 -8
- package/src/core/icons/icon-display-resources-col.svg +0 -21
- package/src/core/icons/icon-display-sdks-col.svg +0 -11
- package/src/core/icons/icon-display-servers.svg +0 -3
- package/src/core/icons/icon-display-shopping-cart.svg +0 -10
- package/src/core/icons/icon-display-sla.svg +0 -3
- package/src/core/icons/icon-display-soc2-type2.svg +0 -3
- package/src/core/icons/icon-display-tech-account-comms.svg +0 -3
- package/src/core/icons/icon-display-tutorials-demos-col.svg +0 -25
- package/src/core/icons/icon-display-virtual-events-col.svg +0 -12
- package/src/core/icons/icon-display-virtual-events.svg +0 -12
- package/src/core/icons/icon-gui-ably-badge.svg +0 -3
- package/src/core/icons/icon-gui-arrow-bidirectional-horizontal.svg +0 -3
- package/src/core/icons/icon-gui-arrow-bidirectional-vertical.svg +0 -3
- package/src/core/icons/icon-gui-arrow-down.svg +0 -3
- package/src/core/icons/icon-gui-arrow-left.svg +0 -3
- package/src/core/icons/icon-gui-arrow-right.svg +0 -3
- package/src/core/icons/icon-gui-arrow-up.svg +0 -3
- package/src/core/icons/icon-gui-burger-menu.svg +0 -5
- package/src/core/icons/icon-gui-check-circled-fill-black.svg +0 -4
- package/src/core/icons/icon-gui-check-circled-fill.svg +0 -4
- package/src/core/icons/icon-gui-check-circled.svg +0 -3
- package/src/core/icons/icon-gui-checklist-checked.svg +0 -3
- package/src/core/icons/icon-gui-clock.svg +0 -3
- package/src/core/icons/icon-gui-close.svg +0 -3
- package/src/core/icons/icon-gui-copy.svg +0 -10
- package/src/core/icons/icon-gui-cross-circled-fill.svg +0 -4
- package/src/core/icons/icon-gui-cross-circled.svg +0 -3
- package/src/core/icons/icon-gui-dash-circled.svg +0 -3
- package/src/core/icons/icon-gui-disclosure-arrow.svg +0 -3
- package/src/core/icons/icon-gui-document-generic.svg +0 -3
- package/src/core/icons/icon-gui-enlarge.svg +0 -3
- package/src/core/icons/icon-gui-external-link.svg +0 -3
- package/src/core/icons/icon-gui-filter-flow-step-1.svg +0 -5
- package/src/core/icons/icon-gui-filter-flow-step-2.svg +0 -5
- package/src/core/icons/icon-gui-filter-flow-step-3.svg +0 -5
- package/src/core/icons/icon-gui-history.svg +0 -3
- package/src/core/icons/icon-gui-info.svg +0 -3
- package/src/core/icons/icon-gui-link-arrow.svg +0 -3
- package/src/core/icons/icon-gui-link.svg +0 -4
- package/src/core/icons/icon-gui-live-chat.svg +0 -3
- package/src/core/icons/icon-gui-minus.svg +0 -3
- package/src/core/icons/icon-gui-partial.svg +0 -4
- package/src/core/icons/icon-gui-plus.svg +0 -3
- package/src/core/icons/icon-gui-quote-marks-solid.svg +0 -3
- package/src/core/icons/icon-gui-refresh.svg +0 -10
- package/src/core/icons/icon-gui-resources.svg +0 -3
- package/src/core/icons/icon-gui-search.svg +0 -3
- package/src/core/icons/icon-gui-tick.svg +0 -3
- package/src/core/icons/icon-gui-warning.svg +0 -5
- package/src/core/icons/icon-live-updates-results-metrics-col.svg +0 -26
- package/src/core/icons/icon-multi-user-spaces-col.svg +0 -13
- package/src/core/icons/icon-social-x.svg +0 -3
- package/src/core/icons/icon-tech-apachekafka.svg +0 -3
- package/src/core/icons/linkedin.svg +0 -3
- package/src/core/icons/quote.svg +0 -3
- package/src/core/icons/stackoverflow.svg +0 -3
- package/src/core/icons/twitter.svg +0 -3
- package/src/core/icons/youtube.svg +0 -11
- package/src/core/icons.js +0 -6
- package/src/core/images/ably-logo.png +0 -0
- package/src/core/images/ably-logo.svg +0 -15
- package/src/core/images/ably-stack.svg +0 -14
- package/src/core/images/best-support-2023.svg +0 -1
- package/src/core/images/cust-logo-ao-col-pos.png +0 -0
- package/src/core/images/cust-logo-ao-col-pos@2x.png +0 -0
- package/src/core/images/cust-logo-ausopen-col-pos.png +0 -0
- package/src/core/images/cust-logo-ausopen-col-pos@2x.png +0 -0
- package/src/core/images/cust-logo-ausopen-mono-pos.svg +0 -5
- package/src/core/images/cust-logo-bloomberg-mono-pos.svg +0 -11
- package/src/core/images/cust-logo-hopin-mono-pos.svg +0 -4
- package/src/core/images/cust-logo-hubspot-col-pos.png +0 -0
- package/src/core/images/cust-logo-hubspot-col-pos@2x.png +0 -0
- package/src/core/images/cust-logo-hubspot-mono-pos.svg +0 -4
- package/src/core/images/cust-logo-lightspeed-col-pos.png +0 -0
- package/src/core/images/cust-logo-lightspeed-col-pos@2x.png +0 -0
- package/src/core/images/cust-logo-lightspeed-syst-col-pos.png +0 -0
- package/src/core/images/cust-logo-lightspeed-syst-col-pos@2x.png +0 -0
- package/src/core/images/cust-logo-mentimeter-mono-pos.svg +0 -17
- package/src/core/images/cust-logo-split-col-pos.png +0 -0
- package/src/core/images/cust-logo-split-col-pos@2x.png +0 -0
- package/src/core/images/cust-logo-split-mono-pos.svg +0 -9
- package/src/core/images/cust-logo-toyota-mono-pos.svg +0 -18
- package/src/core/images/cust-logo-vitac-col-pos.png +0 -0
- package/src/core/images/cust-logo-vitac-col-pos@2x.png +0 -0
- package/src/core/images/cust-logo-webflow-col-pos.svg +0 -3
- package/src/core/images/cust-photo-hubspot-max-freiert.jpg +0 -0
- package/src/core/images/cust-photo-split-pato-echague.jpg +0 -0
- package/src/core/images/cust-photo-vitac-joe-antonio.jpg +0 -0
- package/src/core/images/fastest-implementation-2023.svg +0 -1
- package/src/core/images/flexible-companies.png +0 -0
- package/src/core/images/high-performer-2022.png +0 -0
- package/src/core/images/high-performer-2023.svg +0 -1
- package/src/core/images/highest-user-adoption-2022.png +0 -0
- package/src/core/images/highest-user-adoption-2023.svg +0 -1
- package/src/core/images/icon-tech-aws.svg +0 -4
- package/src/core/images/rocket-list-2021.png +0 -0
- package/src/core/images/scale-motif-open-empathetic.svg +0 -1
- package/src/core/images/technical-support-01-800x533.jpg +0 -0
- package/src/core/images/users-love-us-2022.png +0 -0
- package/src/core/load-sprites.js +0 -11
- package/src/core/react-renderer.tsx +0 -29
- package/src/core/remote-blogs-posts.js +0 -42
- package/src/core/remote-data-store.js +0 -34
- package/src/core/remote-data-util.js +0 -4
- package/src/core/remote-session-data.js +0 -58
- package/src/core/scripts.js +0 -10
- package/src/core/styles/buttons.css +0 -124
- package/src/core/styles/forms.css +0 -64
- package/src/core/styles/layout.css +0 -21
- package/src/core/styles/properties.css +0 -278
- package/src/core/styles/text.css +0 -168
- package/src/core/styles/toggles.css +0 -38
- package/src/core/styles.base.css +0 -1
- package/src/core/styles.components.css +0 -44
- package/src/core/styles.css +0 -2
- package/src/core/url-base.js +0 -7
- package/src/core/utils/syntax-highlighter-registry.js +0 -63
- package/src/core/utils/syntax-highlighter.css +0 -71
- package/src/core/utils/syntax-highlighter.js +0 -103
- package/src/pages/Buttons.mdx +0 -121
- package/src/pages/Chips.mdx +0 -136
- package/src/pages/Colour.mdx +0 -23
- package/src/pages/Forms.mdx +0 -219
- package/src/pages/Layout.mdx +0 -58
- package/src/pages/Toggles.mdx +0 -42
- package/src/pages/Typography.mdx +0 -206
- package/src/pages/utils.ts +0 -80
- package/src/reset/scripts.js +0 -1
- package/src/reset/styles/normalize.css +0 -353
- package/src/reset/styles/reset.css +0 -139
- package/src/reset/styles.css +0 -2
|
@@ -1,177 +0,0 @@
|
|
|
1
|
-
import { queryId } from "../dom-query";
|
|
2
|
-
import AddSearchClient from "addsearch-js-client";
|
|
3
|
-
|
|
4
|
-
const init = ({ input, container, listContainer, clear, client }) => {
|
|
5
|
-
client.setAnalyticsTag("Meganav autocomplete");
|
|
6
|
-
client.setThrottleTime(400);
|
|
7
|
-
|
|
8
|
-
const clearResults = () => {
|
|
9
|
-
container.classList.add("hidden");
|
|
10
|
-
listContainer.innerHTML = "";
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
const toggleClearBtn = (query) => {
|
|
14
|
-
if ((query || "").length > 0 && clear) {
|
|
15
|
-
clear.classList.remove("invisible");
|
|
16
|
-
} else if (clear) {
|
|
17
|
-
clear.classList.add("invisible");
|
|
18
|
-
}
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
const markQueryInSuggestion = (suggestionValue, query) => {
|
|
22
|
-
return suggestionValue.replace(
|
|
23
|
-
query.toLowerCase(),
|
|
24
|
-
`<span class="font-light">${query}</span>`,
|
|
25
|
-
);
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
const navigateToUrl = (q) => (window.location = `/search?q=${q}`);
|
|
29
|
-
|
|
30
|
-
const focusNext = (index) => {
|
|
31
|
-
const nextSuggestion = listContainer.querySelector(
|
|
32
|
-
`[data-suggestion-index="${index + 1}"]`,
|
|
33
|
-
);
|
|
34
|
-
if (!nextSuggestion) return;
|
|
35
|
-
nextSuggestion.focus();
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
const focusPrevious = (index) => {
|
|
39
|
-
const previousIndex = index - 1;
|
|
40
|
-
|
|
41
|
-
const previousSuggestion = listContainer.querySelector(
|
|
42
|
-
`[data-suggestion-index="${previousIndex}"]`,
|
|
43
|
-
);
|
|
44
|
-
if (!previousSuggestion) return;
|
|
45
|
-
previousSuggestion.focus();
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
const renderResults =
|
|
49
|
-
(query) =>
|
|
50
|
-
(results = {}) => {
|
|
51
|
-
toggleClearBtn(query);
|
|
52
|
-
|
|
53
|
-
// Prevent invalid access error when key is invalid
|
|
54
|
-
if (!Array.isArray(results.suggestions)) {
|
|
55
|
-
clearResults();
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
// Prevent key error from invalid key
|
|
60
|
-
if (results.suggestions.length === 0) {
|
|
61
|
-
clearResults();
|
|
62
|
-
return;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
const items = results.suggestions.map((suggestion, index) => {
|
|
66
|
-
const li = document.createElement("li");
|
|
67
|
-
const button = document.createElement("button");
|
|
68
|
-
button.type = "button";
|
|
69
|
-
|
|
70
|
-
button.classList.add(
|
|
71
|
-
"ui-text-menu2",
|
|
72
|
-
"font-medium",
|
|
73
|
-
"p-8",
|
|
74
|
-
"w-full",
|
|
75
|
-
"text-left",
|
|
76
|
-
"rounded",
|
|
77
|
-
"hover:text-gui-hover",
|
|
78
|
-
"focus:outline-gui-focus",
|
|
79
|
-
"hover:bg-light-grey",
|
|
80
|
-
);
|
|
81
|
-
|
|
82
|
-
button.innerHTML = markQueryInSuggestion(suggestion.value, query);
|
|
83
|
-
|
|
84
|
-
button.dataset.suggestionIndex = index;
|
|
85
|
-
|
|
86
|
-
button.addEventListener("click", () => {
|
|
87
|
-
navigateToUrl(suggestion.value);
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
button.addEventListener("keydown", (e) => {
|
|
91
|
-
const key = e.key;
|
|
92
|
-
|
|
93
|
-
if (key === "ArrowDown") {
|
|
94
|
-
focusNext(index);
|
|
95
|
-
} else if (key === "ArrowUp" && index - 1 < 0) {
|
|
96
|
-
input.focus();
|
|
97
|
-
} else if (key === "ArrowUp" && index - 1 >= 0) {
|
|
98
|
-
focusPrevious(index);
|
|
99
|
-
} else if (key === "Enter" || key === "Space") {
|
|
100
|
-
navigateToUrl(suggestion.value);
|
|
101
|
-
}
|
|
102
|
-
});
|
|
103
|
-
|
|
104
|
-
li.appendChild(button);
|
|
105
|
-
return li;
|
|
106
|
-
});
|
|
107
|
-
|
|
108
|
-
listContainer.innerHTML = "";
|
|
109
|
-
items.forEach((item) => listContainer.appendChild(item));
|
|
110
|
-
container.classList.remove("hidden");
|
|
111
|
-
};
|
|
112
|
-
|
|
113
|
-
const keyupHandler = (e) => {
|
|
114
|
-
const query = e.target.value;
|
|
115
|
-
const key = e.key;
|
|
116
|
-
|
|
117
|
-
if (key === "ArrowDown") {
|
|
118
|
-
focusNext(0);
|
|
119
|
-
return;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
if (!query) {
|
|
123
|
-
clearResults();
|
|
124
|
-
} else {
|
|
125
|
-
client.suggestions(query, renderResults(query));
|
|
126
|
-
}
|
|
127
|
-
};
|
|
128
|
-
|
|
129
|
-
let clearHandler;
|
|
130
|
-
if (clear) {
|
|
131
|
-
clearHandler = () => {
|
|
132
|
-
input.value = "";
|
|
133
|
-
clear.classList.add("invisible");
|
|
134
|
-
clearResults();
|
|
135
|
-
};
|
|
136
|
-
clear.addEventListener("click", clearHandler);
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
input.addEventListener("keyup", keyupHandler);
|
|
140
|
-
|
|
141
|
-
return {
|
|
142
|
-
teardown: () => {
|
|
143
|
-
input.removeEventListener("keyup", keyupHandler);
|
|
144
|
-
if (clear) clear.removeEventListener("click", clearHandler);
|
|
145
|
-
},
|
|
146
|
-
clear: () => {
|
|
147
|
-
input.value = "";
|
|
148
|
-
clearResults();
|
|
149
|
-
},
|
|
150
|
-
};
|
|
151
|
-
};
|
|
152
|
-
|
|
153
|
-
export default (apiKey) => {
|
|
154
|
-
if (!apiKey) {
|
|
155
|
-
console.log(`No AddSearch API key provided, skipping search suggestions.`);
|
|
156
|
-
return [];
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
const client = new AddSearchClient(apiKey);
|
|
160
|
-
|
|
161
|
-
return [
|
|
162
|
-
queryId("meganav-search-input"),
|
|
163
|
-
queryId("meganav-mobile-search-input"),
|
|
164
|
-
]
|
|
165
|
-
.filter((i) => i)
|
|
166
|
-
.map((input) => {
|
|
167
|
-
const parent = input.parentNode;
|
|
168
|
-
const container = queryId(
|
|
169
|
-
"meganav-search-autocomplete-container",
|
|
170
|
-
parent,
|
|
171
|
-
);
|
|
172
|
-
const listContainer = queryId("meganav-search-autocomplete-list", parent);
|
|
173
|
-
const clear = queryId("meganav-search-input-clear", parent);
|
|
174
|
-
|
|
175
|
-
return init({ input, container, listContainer, client, clear });
|
|
176
|
-
});
|
|
177
|
-
};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
|
|
3
|
-
const MeganavSearchAutocomplete = () => (
|
|
4
|
-
<div
|
|
5
|
-
className="absolute w-full mt-8 z-10 hidden shadow-container rounded-lg bg-white border border-mid-grey"
|
|
6
|
-
data-id="meganav-search-autocomplete-container"
|
|
7
|
-
>
|
|
8
|
-
<ol className="m-16" data-id="meganav-search-autocomplete-list"></ol>
|
|
9
|
-
</div>
|
|
10
|
-
);
|
|
11
|
-
|
|
12
|
-
export default MeganavSearchAutocomplete;
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
|
|
3
|
-
import Icon from "./Icon";
|
|
4
|
-
import MeganavSearchSuggestions from "./MeganavSearchSuggestions";
|
|
5
|
-
import MeganavSearchAutocomplete from "./MeganavSearchAutocomplete";
|
|
6
|
-
import { AbsUrl } from "./Meganav";
|
|
7
|
-
|
|
8
|
-
const MeganavSearchPanel = ({ absUrl }: { absUrl: AbsUrl }) => (
|
|
9
|
-
<section className="ui-meganav-content grid-cols-12">
|
|
10
|
-
<div className="col-span-8">
|
|
11
|
-
<div className="mb-32">
|
|
12
|
-
<form
|
|
13
|
-
className="flex items-start"
|
|
14
|
-
action={absUrl("/search")}
|
|
15
|
-
method="get"
|
|
16
|
-
>
|
|
17
|
-
<div className="relative w-full">
|
|
18
|
-
<Icon
|
|
19
|
-
name="icon-gui-search"
|
|
20
|
-
color="text-cool-black"
|
|
21
|
-
size="1.5rem"
|
|
22
|
-
additionalCSS="absolute top-12 left-16"
|
|
23
|
-
/>
|
|
24
|
-
<input
|
|
25
|
-
type="search"
|
|
26
|
-
name="q"
|
|
27
|
-
className="ui-input pl-48 h-48"
|
|
28
|
-
placeholder="Search"
|
|
29
|
-
autoComplete="off"
|
|
30
|
-
data-id="meganav-search-input"
|
|
31
|
-
/>
|
|
32
|
-
|
|
33
|
-
<MeganavSearchAutocomplete />
|
|
34
|
-
</div>
|
|
35
|
-
|
|
36
|
-
<button
|
|
37
|
-
type="submit"
|
|
38
|
-
className="ui-btn-secondary flex-shrink-0 ml-8 sm:ml-16 md:ml-24 xl:ml-32"
|
|
39
|
-
>
|
|
40
|
-
Search
|
|
41
|
-
</button>
|
|
42
|
-
</form>
|
|
43
|
-
</div>
|
|
44
|
-
</div>
|
|
45
|
-
|
|
46
|
-
<div className="col-span-12">
|
|
47
|
-
<MeganavSearchSuggestions displaySupportLink={true} absUrl={absUrl} />
|
|
48
|
-
</div>
|
|
49
|
-
</section>
|
|
50
|
-
);
|
|
51
|
-
|
|
52
|
-
export default MeganavSearchPanel;
|
|
@@ -1,133 +0,0 @@
|
|
|
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 getItemsTotalWidth = (nodes) =>
|
|
22
|
-
nodes
|
|
23
|
-
.map((item) => item.getBoundingClientRect().width)
|
|
24
|
-
.reduce((acc, val) => acc + val, 0);
|
|
25
|
-
|
|
26
|
-
const MeganavSearchSuggestions = () => {
|
|
27
|
-
const suggestionsToggle = queryId("meganav-mobile-search-input");
|
|
28
|
-
const suggestions = queryId("meganav-mobile-search-suggestions");
|
|
29
|
-
const list = suggestions.querySelector("ul");
|
|
30
|
-
const listItems = Array.from(list.querySelectorAll("li"));
|
|
31
|
-
|
|
32
|
-
const dragLeft = (distance, threshold) => {
|
|
33
|
-
const currentTranslateX = getTranslateX(list);
|
|
34
|
-
const translateX = Math.round(currentTranslateX + distance);
|
|
35
|
-
if (dragLeftBoundary(translateX, threshold)) return;
|
|
36
|
-
updateTranslateX(list, translateX);
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
const dragLeftEnd = (distance, threshold) => {
|
|
40
|
-
const currentTranslateX = getTranslateX(list);
|
|
41
|
-
let translateX = Math.round(currentTranslateX + distance);
|
|
42
|
-
|
|
43
|
-
if (dragLeftBoundary(translateX, threshold)) {
|
|
44
|
-
translateX = 0;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
updateTranslateX(list, translateX);
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
const dragRight = (distance, threshold) => {
|
|
51
|
-
const listWidth = list.getBoundingClientRect().width;
|
|
52
|
-
const currentTranslateX = getTranslateX(list);
|
|
53
|
-
const translateX = Math.round(currentTranslateX + distance);
|
|
54
|
-
const itemsTotalWidth = getItemsTotalWidth(listItems);
|
|
55
|
-
|
|
56
|
-
if (dragRightBoundary(translateX, itemsTotalWidth, listWidth, threshold)) {
|
|
57
|
-
return;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
updateTranslateX(list, translateX);
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
const dragRightEnd = (distance, threshold) => {
|
|
64
|
-
const listWidth = list.getBoundingClientRect().width;
|
|
65
|
-
const currentTranslateX = getTranslateX(list);
|
|
66
|
-
const itemsTotalWidth = getItemsTotalWidth(listItems);
|
|
67
|
-
let translateX = Math.round(currentTranslateX + distance);
|
|
68
|
-
|
|
69
|
-
if (dragRightBoundary(translateX, itemsTotalWidth, listWidth, threshold)) {
|
|
70
|
-
translateX = -(itemsTotalWidth - listWidth + threshold);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
updateTranslateX(list, translateX);
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
let touchStartX;
|
|
77
|
-
|
|
78
|
-
const touchstartHandler = (e) => {
|
|
79
|
-
touchStartX = e.touches[0]?.clientX;
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
const touchmoveHandler = (e) => {
|
|
83
|
-
const distance = getDistance(e, touchStartX);
|
|
84
|
-
if (withinBuffer(distance)) return;
|
|
85
|
-
distance > 0 ? dragLeft(distance, 24) : dragRight(distance, 96);
|
|
86
|
-
};
|
|
87
|
-
|
|
88
|
-
const touchendHandler = (e) => {
|
|
89
|
-
const distance = getDistance(e, touchStartX);
|
|
90
|
-
if (withinBuffer(distance)) return;
|
|
91
|
-
distance > 0 ? dragLeftEnd(distance, 24) : dragRightEnd(distance, 48);
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
const focusSuggestionsHandler = () => {
|
|
95
|
-
suggestions.classList.add("max-h-96");
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
const blurSuggestionsHandler = (e) => {
|
|
99
|
-
if (e.relatedTarget === suggestions.querySelectorAll("a")[0]) {
|
|
100
|
-
return;
|
|
101
|
-
}
|
|
102
|
-
suggestions.classList.remove("max-h-96");
|
|
103
|
-
};
|
|
104
|
-
|
|
105
|
-
const wheelHandler = (e) => {
|
|
106
|
-
const distance = e.deltaY * 4;
|
|
107
|
-
if (withinBuffer(distance)) return;
|
|
108
|
-
distance > 0 ? dragLeftEnd(distance, 24) : dragRightEnd(distance, 48);
|
|
109
|
-
};
|
|
110
|
-
|
|
111
|
-
suggestionsToggle.addEventListener("focus", focusSuggestionsHandler);
|
|
112
|
-
suggestionsToggle.addEventListener("blur", blurSuggestionsHandler);
|
|
113
|
-
suggestions.addEventListener("touchstart", touchstartHandler);
|
|
114
|
-
suggestions.addEventListener("touchmove", touchmoveHandler);
|
|
115
|
-
suggestions.addEventListener("touchend", touchendHandler);
|
|
116
|
-
suggestions.addEventListener("wheel", wheelHandler);
|
|
117
|
-
|
|
118
|
-
return {
|
|
119
|
-
teardown: () => {
|
|
120
|
-
suggestionsToggle.removeEventListener("focus", focusSuggestionsHandler);
|
|
121
|
-
suggestionsToggle.removeEventListener("blur", blurSuggestionsHandler);
|
|
122
|
-
suggestions.removeEventListener("touchstart", touchstartHandler);
|
|
123
|
-
suggestions.removeEventListener("touchmove", touchmoveHandler);
|
|
124
|
-
suggestions.removeEventListener("touchend", touchendHandler);
|
|
125
|
-
},
|
|
126
|
-
clear: () => {
|
|
127
|
-
suggestions.classList.remove("max-h-96");
|
|
128
|
-
list.style.transform = `translateX(0px)`;
|
|
129
|
-
},
|
|
130
|
-
};
|
|
131
|
-
};
|
|
132
|
-
|
|
133
|
-
export default MeganavSearchSuggestions;
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
|
|
3
|
-
import FeaturedLink from "./FeaturedLink";
|
|
4
|
-
import { AbsUrl } from "./Meganav";
|
|
5
|
-
|
|
6
|
-
type MeganavSearchSuggestionsProps = {
|
|
7
|
-
absUrl: AbsUrl;
|
|
8
|
-
displaySupportLink: boolean;
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
const MeganavSearchSuggestions = ({
|
|
12
|
-
absUrl,
|
|
13
|
-
displaySupportLink,
|
|
14
|
-
}: MeganavSearchSuggestionsProps) => (
|
|
15
|
-
<>
|
|
16
|
-
<p className="ui-text-overline2 text-cool-black py-12">Popular pages</p>
|
|
17
|
-
|
|
18
|
-
<div className="flex justify-between items-center overflow-hidden">
|
|
19
|
-
<ul className="flex transition-transform">
|
|
20
|
-
<li className="py-12 pr-8 flex-shrink-0">
|
|
21
|
-
<a
|
|
22
|
-
href={absUrl("/docs/how-ably-works")}
|
|
23
|
-
className="ui-text-p2 hover:text-gui-hover active:text-gui-active focus:text-gui-focus"
|
|
24
|
-
>
|
|
25
|
-
How does Ably work?
|
|
26
|
-
</a>
|
|
27
|
-
</li>
|
|
28
|
-
<li className="py-12 px-8 flex-shrink-0">
|
|
29
|
-
<a
|
|
30
|
-
href={absUrl("/docs/quick-start-guide")}
|
|
31
|
-
className="ui-text-p2 hover:text-gui-hover active:text-gui-active focus:text-gui-focus"
|
|
32
|
-
>
|
|
33
|
-
Quickstart guide
|
|
34
|
-
</a>
|
|
35
|
-
</li>
|
|
36
|
-
<li className="py-12 px-8 flex-shrink-0">
|
|
37
|
-
<a
|
|
38
|
-
href={absUrl("/docs/core-features/pubsub")}
|
|
39
|
-
className="ui-text-p2 hover:text-gui-hover active:text-gui-active focus:text-gui-focus"
|
|
40
|
-
>
|
|
41
|
-
Publish/Subscribe Messaging
|
|
42
|
-
</a>
|
|
43
|
-
</li>
|
|
44
|
-
<li className="py-12 pl-8 flex-shrink-0">
|
|
45
|
-
<a
|
|
46
|
-
href={absUrl("/platform")}
|
|
47
|
-
className="ui-text-p2 hover:text-gui-hover active:text-gui-active focus:text-gui-focus"
|
|
48
|
-
>
|
|
49
|
-
Platform
|
|
50
|
-
</a>
|
|
51
|
-
</li>
|
|
52
|
-
</ul>
|
|
53
|
-
{displaySupportLink ? (
|
|
54
|
-
<FeaturedLink url={absUrl("/support")} textSize="text-p2">
|
|
55
|
-
Support
|
|
56
|
-
</FeaturedLink>
|
|
57
|
-
) : null}
|
|
58
|
-
</div>
|
|
59
|
-
</>
|
|
60
|
-
);
|
|
61
|
-
|
|
62
|
-
export default MeganavSearchSuggestions;
|
|
@@ -1,154 +0,0 @@
|
|
|
1
|
-
import Cookie from "js-cookie";
|
|
2
|
-
import throttle from "lodash.throttle";
|
|
3
|
-
|
|
4
|
-
import { queryId } from "../dom-query";
|
|
5
|
-
import { FLASH_DATA_ID } from "../Flash";
|
|
6
|
-
|
|
7
|
-
const COOKIE_EXPIRY = 90;
|
|
8
|
-
const COLLAPSE_TRIGGER_DISTANCE = 5;
|
|
9
|
-
const SCROLL_LISTENER_THROTTLE = 100;
|
|
10
|
-
const RESIZE_LISTENER_THROTTLE = 100;
|
|
11
|
-
|
|
12
|
-
const isMdViewport = () => !window.matchMedia(`(min-width: 65rem)`).matches;
|
|
13
|
-
|
|
14
|
-
const adjustFlashMargin = (open) => {
|
|
15
|
-
// HACK ALERT
|
|
16
|
-
// Add margin to flashes when opening the notice.
|
|
17
|
-
// Flashes are react components and this notice needs to work as a view-component and react component.
|
|
18
|
-
// We could do this with redux but then we potentially update state on every scroll event, which
|
|
19
|
-
// even with debounce will deplate our frame budget.
|
|
20
|
-
|
|
21
|
-
const flash = queryId(FLASH_DATA_ID);
|
|
22
|
-
|
|
23
|
-
if (flash) {
|
|
24
|
-
flash.style.marginTop = open ? `4rem` : null;
|
|
25
|
-
}
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
const hideOnMobile = (bannerContainer) => {
|
|
29
|
-
if (isMdViewport()) {
|
|
30
|
-
bannerContainer.style.display = "none";
|
|
31
|
-
} else {
|
|
32
|
-
bannerContainer.style.display = null;
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
const hideNotice = (bannerContainer) => {
|
|
37
|
-
bannerContainer.style.maxHeight = 0;
|
|
38
|
-
bannerContainer.style.overflow = "hidden";
|
|
39
|
-
|
|
40
|
-
adjustFlashMargin(false);
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
const showNotice = (bannerContainer) => {
|
|
44
|
-
bannerContainer.style.maxHeight = null;
|
|
45
|
-
bannerContainer.style.overflow = null;
|
|
46
|
-
|
|
47
|
-
adjustFlashMargin(true);
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
const setupRememberClosed = (cookieId, noticeId) => {
|
|
51
|
-
const cookie = Cookie.get(cookieId) || "";
|
|
52
|
-
|
|
53
|
-
Cookie.set(cookieId, `${cookie.replace(`${noticeId},`, "") + noticeId},`, {
|
|
54
|
-
expires: COOKIE_EXPIRY,
|
|
55
|
-
});
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
const hasBeenClosedBefore = (cookieId, noticeId) =>
|
|
59
|
-
(Cookie.get(cookieId) || "").includes(noticeId);
|
|
60
|
-
|
|
61
|
-
const setupNoticeCollapse = (bannerContainer) => {
|
|
62
|
-
const scrollTop = window.scrollY;
|
|
63
|
-
|
|
64
|
-
if (scrollTop > COLLAPSE_TRIGGER_DISTANCE) {
|
|
65
|
-
hideNotice(bannerContainer);
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
const listener = throttle(() => {
|
|
69
|
-
const scrollTop = window.scrollY;
|
|
70
|
-
|
|
71
|
-
if (scrollTop > COLLAPSE_TRIGGER_DISTANCE) {
|
|
72
|
-
hideNotice(bannerContainer);
|
|
73
|
-
} else if (bannerContainer.style.overflow) {
|
|
74
|
-
showNotice(bannerContainer);
|
|
75
|
-
}
|
|
76
|
-
}, SCROLL_LISTENER_THROTTLE);
|
|
77
|
-
|
|
78
|
-
document.addEventListener("scroll", listener);
|
|
79
|
-
|
|
80
|
-
return () => document.removeEventListener("scroll", listener);
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
const setupCloseBtn = (
|
|
84
|
-
bannerContainer,
|
|
85
|
-
cookieId,
|
|
86
|
-
noticeId,
|
|
87
|
-
collapseUnmountListeners,
|
|
88
|
-
) => {
|
|
89
|
-
const closeBtn = bannerContainer.querySelector("button");
|
|
90
|
-
|
|
91
|
-
if (!closeBtn) return () => {};
|
|
92
|
-
|
|
93
|
-
const listener = () => {
|
|
94
|
-
if (cookieId && noticeId) setupRememberClosed(cookieId, noticeId);
|
|
95
|
-
|
|
96
|
-
hideNotice(bannerContainer);
|
|
97
|
-
collapseUnmountListeners();
|
|
98
|
-
};
|
|
99
|
-
|
|
100
|
-
closeBtn.addEventListener("click", listener);
|
|
101
|
-
|
|
102
|
-
return () => document.removeEventListener("click", listener);
|
|
103
|
-
};
|
|
104
|
-
|
|
105
|
-
const resizeHandler = (bannerContainer) => {
|
|
106
|
-
const handler = throttle(() => {
|
|
107
|
-
hideOnMobile(bannerContainer);
|
|
108
|
-
}, RESIZE_LISTENER_THROTTLE);
|
|
109
|
-
|
|
110
|
-
window.addEventListener("resize", handler);
|
|
111
|
-
|
|
112
|
-
return () => window.removeEventListener("resize", handler);
|
|
113
|
-
};
|
|
114
|
-
|
|
115
|
-
const Notice = ({ bannerContainer, cookieId, noticeId, options }) => {
|
|
116
|
-
if (typeof window === "undefined") return () => {};
|
|
117
|
-
|
|
118
|
-
if (!bannerContainer) {
|
|
119
|
-
console.warn(
|
|
120
|
-
"A Notice component was initited but no notice container was found.",
|
|
121
|
-
);
|
|
122
|
-
return () => {};
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
if (hasBeenClosedBefore(cookieId, noticeId)) return () => {};
|
|
126
|
-
|
|
127
|
-
hideOnMobile(bannerContainer);
|
|
128
|
-
showNotice(bannerContainer);
|
|
129
|
-
|
|
130
|
-
const opts = { collapse: true, ...options };
|
|
131
|
-
|
|
132
|
-
const collapseUnmountListeners = opts.collapse
|
|
133
|
-
? setupNoticeCollapse(bannerContainer)
|
|
134
|
-
: () => {};
|
|
135
|
-
|
|
136
|
-
const closeBtnUnmountListeners = setupCloseBtn(
|
|
137
|
-
bannerContainer,
|
|
138
|
-
cookieId,
|
|
139
|
-
noticeId,
|
|
140
|
-
collapseUnmountListeners,
|
|
141
|
-
);
|
|
142
|
-
|
|
143
|
-
const resizeUnmountListener = resizeHandler(bannerContainer);
|
|
144
|
-
|
|
145
|
-
return () => {
|
|
146
|
-
[
|
|
147
|
-
closeBtnUnmountListeners,
|
|
148
|
-
collapseUnmountListeners,
|
|
149
|
-
resizeUnmountListener,
|
|
150
|
-
].forEach((unmount) => unmount());
|
|
151
|
-
};
|
|
152
|
-
};
|
|
153
|
-
|
|
154
|
-
export default Notice;
|
package/src/core/Notice.tsx
DELETED
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
import React, { ReactNode, useEffect } from "react";
|
|
2
|
-
|
|
3
|
-
import NoticeScripts from "./Notice/component.js";
|
|
4
|
-
import Icon from "./Icon";
|
|
5
|
-
type ContentWrapperProps = {
|
|
6
|
-
buttonLink: string;
|
|
7
|
-
children: ReactNode;
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
// TODO(jamiehenson):
|
|
11
|
-
// This type is a bit messed up currently due to the NoticeScripts import being interpreted as NoticeProps.
|
|
12
|
-
// Plan is to TS-ify the JS assets too, so this can be rectified then. The NoticeScripts-oriented props are
|
|
13
|
-
// the ones after the line break.
|
|
14
|
-
type NoticeProps = {
|
|
15
|
-
buttonLink?: string;
|
|
16
|
-
buttonLabel?: string;
|
|
17
|
-
bodyText?: string;
|
|
18
|
-
title?: string;
|
|
19
|
-
closeBtn?: boolean;
|
|
20
|
-
config?: {
|
|
21
|
-
collapse: boolean;
|
|
22
|
-
noticeId: string;
|
|
23
|
-
cookieId: string;
|
|
24
|
-
};
|
|
25
|
-
bgColor?: string;
|
|
26
|
-
textColor?: string;
|
|
27
|
-
|
|
28
|
-
bannerContainer?: Element | null;
|
|
29
|
-
cookieId?: string;
|
|
30
|
-
noticeId?: string;
|
|
31
|
-
options?: { collapse: boolean };
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
const contentWrapperClasses = "w-full pr-8 ui-text-p3 self-center";
|
|
35
|
-
|
|
36
|
-
const ContentWrapper = ({ buttonLink, children }: ContentWrapperProps) =>
|
|
37
|
-
buttonLink ? (
|
|
38
|
-
<a href={buttonLink} className={contentWrapperClasses}>
|
|
39
|
-
{children}
|
|
40
|
-
</a>
|
|
41
|
-
) : (
|
|
42
|
-
<div className={contentWrapperClasses}>{children}</div>
|
|
43
|
-
);
|
|
44
|
-
|
|
45
|
-
const Notice = ({
|
|
46
|
-
buttonLink,
|
|
47
|
-
buttonLabel,
|
|
48
|
-
bodyText,
|
|
49
|
-
title,
|
|
50
|
-
config,
|
|
51
|
-
closeBtn,
|
|
52
|
-
bgColor = "bg-gradient-active-orange",
|
|
53
|
-
textColor = "text-white",
|
|
54
|
-
}: NoticeProps) => {
|
|
55
|
-
useEffect(() => {
|
|
56
|
-
NoticeScripts({
|
|
57
|
-
bannerContainer: document.querySelector('[data-id="ui-notice"]'),
|
|
58
|
-
cookieId: config?.cookieId,
|
|
59
|
-
noticeId: config?.noticeId,
|
|
60
|
-
options: {
|
|
61
|
-
collapse: config?.collapse || false,
|
|
62
|
-
},
|
|
63
|
-
});
|
|
64
|
-
}, []);
|
|
65
|
-
|
|
66
|
-
const wrapperClasses = ["ui-announcement", bgColor, textColor].join(" ");
|
|
67
|
-
|
|
68
|
-
return (
|
|
69
|
-
<div
|
|
70
|
-
className={wrapperClasses}
|
|
71
|
-
data-id="ui-notice"
|
|
72
|
-
style={{ maxHeight: 0, overflow: "hidden" }}
|
|
73
|
-
>
|
|
74
|
-
<div className="ui-grid-px py-16 max-w-screen-xl mx-auto flex items-start">
|
|
75
|
-
<ContentWrapper buttonLink={buttonLink ?? "#"}>
|
|
76
|
-
<strong className="font-bold whitespace-nowrap pr-4">{title}</strong>
|
|
77
|
-
<span className="pr-4">{bodyText}</span>
|
|
78
|
-
{buttonLabel && (
|
|
79
|
-
<span className="underline cursor-pointer whitespace-nowrap">
|
|
80
|
-
{buttonLabel}
|
|
81
|
-
</span>
|
|
82
|
-
)}
|
|
83
|
-
</ContentWrapper>
|
|
84
|
-
|
|
85
|
-
{closeBtn && (
|
|
86
|
-
<button
|
|
87
|
-
type="button"
|
|
88
|
-
className="ml-auto h-20 w-20 border-none bg-none self-baseline"
|
|
89
|
-
>
|
|
90
|
-
<Icon
|
|
91
|
-
name="icon-gui-close"
|
|
92
|
-
size="1.25rem"
|
|
93
|
-
color="text-cool-black"
|
|
94
|
-
/>
|
|
95
|
-
</button>
|
|
96
|
-
)}
|
|
97
|
-
</div>
|
|
98
|
-
</div>
|
|
99
|
-
);
|
|
100
|
-
};
|
|
101
|
-
|
|
102
|
-
export default Notice;
|