From 2f2668a3b269da79f15c1d51391c42ef5429b3c1 Mon Sep 17 00:00:00 2001
From: Jamie Henson
Date: Tue, 19 Mar 2024 14:54:45 +0000
Subject: [PATCH] chore: port JSX assets to TSX
---
.editorconfig | 4 +-
.eslintrc.js | 18 +-
.github/workflows/push.yml | 4 +-
.prettierignore | 1 +
.prettierrc.json | 2 +-
README.md | 4 +-
package.json | 7 +-
src/core/Code/Code.stories.tsx | 2 +-
src/core/Code/component.jsx | 31 --
src/core/Code/component.tsx | 45 +++
.../{component.jsx => component.tsx} | 10 +-
.../ContactFooter/ContactFooter.stories.tsx | 2 +-
src/core/ContactFooter/component.jsx | 66 ----
src/core/ContactFooter/component.tsx | 92 ++++++
.../CookieMessage/CookieMessage.stories.tsx | 2 +-
src/core/CookieMessage/component.css | 22 +-
.../{component.jsx => component.tsx} | 25 +-
.../CustomerLogos/CustomerLogos.stories.tsx | 2 +-
src/core/CustomerLogos/component.jsx | 28 --
src/core/CustomerLogos/component.tsx | 35 ++
.../DropdownMenu/DropdownMenu.stories.tsx | 4 +-
.../{component.jsx => component.tsx} | 100 +++---
.../FeaturedLink/FeaturedLink.stories.tsx | 2 +-
.../{component.jsx => component.tsx} | 44 +--
src/core/Flash/Flash.stories.tsx | 2 +-
.../Flash/{component.jsx => component.tsx} | 114 ++++---
src/core/Footer/Footer.stories.tsx | 2 +-
.../Footer/{component.jsx => component.tsx} | 306 ++++++++++++++----
src/core/Icon/Icon.stories.tsx | 2 +-
src/core/Icon/component.jsx | 19 --
src/core/Icon/component.tsx | 26 ++
src/core/Loader/Loader.stories.tsx | 2 +-
.../Loader/{component.jsx => component.tsx} | 19 +-
src/core/Logo/Logo.stories.tsx | 2 +-
src/core/Logo/component.jsx | 20 --
src/core/Logo/component.tsx | 29 ++
src/core/Meganav/Meganav.stories.tsx | 2 +-
src/core/Meganav/component.js | 13 +-
src/core/Meganav/component.jsx | 123 -------
src/core/Meganav/component.tsx | 228 +++++++++++++
.../{component.jsx => component.tsx} | 29 +-
.../{component.jsx => component.tsx} | 115 +++++--
.../{component.jsx => component.tsx} | 132 ++++++--
src/core/MeganavContentProducts/component.jsx | 105 ------
src/core/MeganavContentProducts/component.tsx | 165 ++++++++++
src/core/MeganavContentUseCases/component.jsx | 147 ---------
src/core/MeganavContentUseCases/component.tsx | 244 ++++++++++++++
.../{component.jsx => component.tsx} | 30 +-
.../{component.jsx => component.tsx} | 10 +-
.../{component.jsx => component.tsx} | 25 +-
.../component.jsx | 25 --
.../component.tsx | 32 ++
src/core/MeganavItemsDesktop/component.jsx | 49 ---
src/core/MeganavItemsDesktop/component.tsx | 68 ++++
src/core/MeganavItemsMobile/component.jsx | 137 --------
src/core/MeganavItemsMobile/component.tsx | 197 +++++++++++
.../{component.jsx => component.tsx} | 82 +++--
src/core/MeganavSearch/component.jsx | 33 --
src/core/MeganavSearch/component.tsx | 36 +++
.../MeganavSearchAutocomplete/component.jsx | 14 -
.../MeganavSearchAutocomplete/component.tsx | 12 +
src/core/MeganavSearchPanel/component.jsx | 39 ---
src/core/MeganavSearchPanel/component.tsx | 52 +++
.../MeganavSearchSuggestions/component.jsx | 49 ---
.../MeganavSearchSuggestions/component.tsx | 62 ++++
src/core/Notice/component.js | 2 +-
src/core/Notice/component.jsx | 71 ----
src/core/Notice/component.tsx | 104 ++++++
src/core/SignOutLink/component.jsx | 32 --
src/core/SignOutLink/component.tsx | 51 +++
src/core/Slider/Slider.stories.tsx | 2 +-
src/core/Slider/component.jsx | 86 -----
src/core/Slider/component.tsx | 112 +++++++
.../{react-renderer.js => react-renderer.tsx} | 5 +-
src/pages/Buttons.mdx | 2 +-
src/pages/Chips.mdx | 2 +-
src/pages/Forms.mdx | 4 +-
tailwind.config.js | 2 +-
tailwind.extend.js | 2 +-
tsconfig.json | 1 -
webpack.common.js | 8 +-
81 files changed, 2372 insertions(+), 1464 deletions(-)
delete mode 100644 src/core/Code/component.jsx
create mode 100644 src/core/Code/component.tsx
rename src/core/ConnectStateWrapper/{component.jsx => component.tsx} (81%)
delete mode 100644 src/core/ContactFooter/component.jsx
create mode 100644 src/core/ContactFooter/component.tsx
rename src/core/CookieMessage/{component.jsx => component.tsx} (69%)
delete mode 100644 src/core/CustomerLogos/component.jsx
create mode 100644 src/core/CustomerLogos/component.tsx
rename src/core/DropdownMenu/{component.jsx => component.tsx} (54%)
rename src/core/FeaturedLink/{component.jsx => component.tsx} (73%)
rename src/core/Flash/{component.jsx => component.tsx} (60%)
rename src/core/Footer/{component.jsx => component.tsx} (58%)
delete mode 100644 src/core/Icon/component.jsx
create mode 100644 src/core/Icon/component.tsx
rename src/core/Loader/{component.jsx => component.tsx} (90%)
delete mode 100644 src/core/Logo/component.jsx
create mode 100644 src/core/Logo/component.tsx
delete mode 100644 src/core/Meganav/component.jsx
create mode 100644 src/core/Meganav/component.tsx
rename src/core/MeganavBlogPostsList/{component.jsx => component.tsx} (71%)
rename src/core/MeganavContentCompany/{component.jsx => component.tsx} (52%)
rename src/core/MeganavContentDevelopers/{component.jsx => component.tsx} (51%)
delete mode 100644 src/core/MeganavContentProducts/component.jsx
create mode 100644 src/core/MeganavContentProducts/component.tsx
delete mode 100644 src/core/MeganavContentUseCases/component.jsx
create mode 100644 src/core/MeganavContentUseCases/component.tsx
rename src/core/MeganavControl/{component.jsx => component.tsx} (56%)
rename src/core/MeganavControlMobileDropdown/{component.jsx => component.tsx} (79%)
rename src/core/MeganavControlMobilePanelClose/{component.jsx => component.tsx} (51%)
delete mode 100644 src/core/MeganavControlMobilePanelOpen/component.jsx
create mode 100644 src/core/MeganavControlMobilePanelOpen/component.tsx
delete mode 100644 src/core/MeganavItemsDesktop/component.jsx
create mode 100644 src/core/MeganavItemsDesktop/component.tsx
delete mode 100644 src/core/MeganavItemsMobile/component.jsx
create mode 100644 src/core/MeganavItemsMobile/component.tsx
rename src/core/MeganavItemsSignedIn/{component.jsx => component.tsx} (51%)
delete mode 100644 src/core/MeganavSearch/component.jsx
create mode 100644 src/core/MeganavSearch/component.tsx
delete mode 100644 src/core/MeganavSearchAutocomplete/component.jsx
create mode 100644 src/core/MeganavSearchAutocomplete/component.tsx
delete mode 100644 src/core/MeganavSearchPanel/component.jsx
create mode 100644 src/core/MeganavSearchPanel/component.tsx
delete mode 100644 src/core/MeganavSearchSuggestions/component.jsx
create mode 100644 src/core/MeganavSearchSuggestions/component.tsx
delete mode 100644 src/core/Notice/component.jsx
create mode 100644 src/core/Notice/component.tsx
delete mode 100644 src/core/SignOutLink/component.jsx
create mode 100644 src/core/SignOutLink/component.tsx
delete mode 100644 src/core/Slider/component.jsx
create mode 100644 src/core/Slider/component.tsx
rename src/core/{react-renderer.js => react-renderer.tsx} (80%)
diff --git a/.editorconfig b/.editorconfig
index 5ce86bc41..87eabc131 100644
--- a/.editorconfig
+++ b/.editorconfig
@@ -13,8 +13,8 @@ max_line_length = 80
[*.md]
trim_trailing_whitespace = false
-[*.{css,html,js,jsx,json,rb,erb}]
+[*.{css,html,js,json,rb,erb}]
charset = utf-8
-[*.{html,jsx,erb,json}]
+[*.{html,erb,json}]
max_line_length = 160
diff --git a/.eslintrc.js b/.eslintrc.js
index ad402e2a4..dab2bf4bd 100644
--- a/.eslintrc.js
+++ b/.eslintrc.js
@@ -5,27 +5,13 @@ module.exports = {
node: true,
"cypress/globals": true,
},
- extends: [
- "eslint:recommended",
- "plugin:react/recommended",
- "prettier",
- "plugin:cypress/recommended",
- "plugin:storybook/recommended",
- ],
+ extends: ["eslint:recommended", "prettier", "plugin:cypress/recommended"],
parserOptions: {
- ecmaFeatures: {
- jsx: true,
- },
ecmaVersion: 12,
sourceType: "module",
},
- plugins: ["react", "cypress"],
+ plugins: ["cypress"],
rules: {},
- settings: {
- react: {
- version: "detect",
- },
- },
overrides: [
{
files: ["*.ts", "*.tsx"],
diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml
index 87f9c7d4a..3374e6913 100644
--- a/.github/workflows/push.yml
+++ b/.github/workflows/push.yml
@@ -29,11 +29,11 @@ jobs:
with:
eslint: true
eslint_dir: src
- eslint_extensions: js,ts,jsx,tsx
+ eslint_extensions: js,ts,tsx
eslint_auto_fix: false
prettier: true
prettier_dir: src
- prettier_extensions: js,ts,jsx,tsx
+ prettier_extensions: js,ts,tsx
prettier_auto_fix: false
# Cypress disabled until tests rewritten to use new SB paths
# - name: Cypress
diff --git a/.prettierignore b/.prettierignore
index fdbc0c9ad..28c048724 100644
--- a/.prettierignore
+++ b/.prettierignore
@@ -3,3 +3,4 @@ vendor
./reset
preview
node_modules
+public
\ No newline at end of file
diff --git a/.prettierrc.json b/.prettierrc.json
index e2b9a9442..de2d6fea1 100644
--- a/.prettierrc.json
+++ b/.prettierrc.json
@@ -1,7 +1,7 @@
{
"overrides": [
{
- "files": ["*.html", "*.jsx"],
+ "files": ["*.html"],
"options": {
"printWidth": 160,
"htmlWhitespaceSensitivity": "strict"
diff --git a/README.md b/README.md
index 173763249..878090325 100644
--- a/README.md
+++ b/README.md
@@ -233,7 +233,7 @@ All components live in `src` and follow a directory and filename convention:
- component directory (TitleCase)
- `component.js` - this is the entry file for a component and is the only required file
- `components.css` - additional CSS
- - for react, `components.jsx`
+ - for react, `components.tsx`
For example:
@@ -244,7 +244,7 @@ For example:
- Accordion
- component.js
- component.css
- - component.jsx
+ - component.tsx
```
#### CSS
diff --git a/package.json b/package.json
index 606579454..4b4a0a8e8 100644
--- a/package.json
+++ b/package.json
@@ -66,9 +66,9 @@
"build": "node scripts/build.js",
"build:verbose": "node scripts/build.js -v",
"watch": "node scripts/build.js -w",
- "format:check": "yarn prettier -c *.{js,ts} src/**/*.{js,jsx,ts,tsx} cypress",
- "format:write": "yarn prettier -w *.{js,ts} src/**/*.{js,jsx,ts,tsx} cypress",
- "lint": "eslint *.{js,ts} src/**/*.{js,jsx,ts,tsx} cypress",
+ "format:check": "yarn prettier -c *.{js,ts} src/**/*.{js,ts,tsx} cypress",
+ "format:write": "yarn prettier -w *.{js,ts} src/**/*.{js,ts,tsx} cypress",
+ "lint": "eslint *.{js,ts} src/**/*.{js,ts,tsx} cypress",
"cy:open": "cypress open",
"cy:headless": "cypress run --quiet",
"update:all": "./scripts/update-dependents.sh",
@@ -87,7 +87,6 @@
"js-cookie": "^2.2.1",
"lodash.throttle": "^4.1.1",
"nanoid": "^4.0.0",
- "prop-types": "^15.7.2",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"redux": "^4.0.5",
diff --git a/src/core/Code/Code.stories.tsx b/src/core/Code/Code.stories.tsx
index 0a6454b64..484828a6c 100644
--- a/src/core/Code/Code.stories.tsx
+++ b/src/core/Code/Code.stories.tsx
@@ -1,4 +1,4 @@
-import Code from "./component.jsx";
+import Code from "./component.tsx";
export default {
title: "Components/Code",
diff --git a/src/core/Code/component.jsx b/src/core/Code/component.jsx
deleted file mode 100644
index aee66ee71..000000000
--- a/src/core/Code/component.jsx
+++ /dev/null
@@ -1,31 +0,0 @@
-import React from "react";
-import T from "prop-types";
-
-import "../utils/syntax-highlighter.css";
-import { highlightSnippet, registerDefaultLanguages } from "../utils/syntax-highlighter";
-import languagesRegistry from "../utils/syntax-highlighter-registry";
-
-registerDefaultLanguages(languagesRegistry);
-
-const Code = ({ language, snippet, textSize = "ui-text-code", padding = "p-32", additionalCSS = "" }) => {
- const HTMLraw = highlightSnippet(language, `${snippet}`.trim());
- const className = `language-${language} ${textSize}`;
-
- return (
-
- );
-};
-
-Code.propTypes = {
- language: T.string,
- snippet: T.string,
- textSize: T.string,
- padding: T.string,
- additionalCSS: T.string,
-};
-
-export default Code;
diff --git a/src/core/Code/component.tsx b/src/core/Code/component.tsx
new file mode 100644
index 000000000..f479f778b
--- /dev/null
+++ b/src/core/Code/component.tsx
@@ -0,0 +1,45 @@
+import React from "react";
+
+import "../utils/syntax-highlighter.css";
+import {
+ highlightSnippet,
+ registerDefaultLanguages,
+} from "../utils/syntax-highlighter";
+import languagesRegistry from "../utils/syntax-highlighter-registry";
+
+registerDefaultLanguages(languagesRegistry);
+
+type CodeProps = {
+ language: string;
+ snippet: string;
+ textSize?: string;
+ padding?: string;
+ additionalCSS?: string;
+};
+
+const Code = ({
+ language,
+ snippet,
+ textSize = "ui-text-code",
+ padding = "p-32",
+ additionalCSS = "",
+}: CodeProps) => {
+ const HTMLraw = highlightSnippet(language, `${snippet}`.trim()) ?? "";
+ const className = `language-${language} ${textSize}`;
+
+ return (
+
+ );
+};
+
+export default Code;
diff --git a/src/core/ConnectStateWrapper/component.jsx b/src/core/ConnectStateWrapper/component.tsx
similarity index 81%
rename from src/core/ConnectStateWrapper/component.jsx
rename to src/core/ConnectStateWrapper/component.tsx
index 275a05f3c..3a4bc0572 100644
--- a/src/core/ConnectStateWrapper/component.jsx
+++ b/src/core/ConnectStateWrapper/component.tsx
@@ -12,14 +12,18 @@ import { connectState, getRemoteDataStore } from "../remote-data-store";
- initial state is set in useEffect so the wrapped component needs to handle it's props set to undefined initially
*/
-export const ConnectStateWrapper = (Component, selectors) => {
+const ConnectStateWrapper = (Component, selectors) => {
const [state, setState] = useState({});
- const setStateForKey = (key) => (storeState) => setState(() => ({ [key]: storeState }));
+ const setStateForKey = (key) => (storeState) =>
+ setState(() => ({ [key]: storeState }));
useEffect(() => {
const store = getRemoteDataStore();
- const resolvedState = Object.keys(selectors).reduce((acc, key) => ({ ...acc, [key]: selectors[key](store) }), {});
+ const resolvedState = Object.keys(selectors).reduce(
+ (acc, key) => ({ ...acc, [key]: selectors[key](store) }),
+ {}
+ );
// Set initial state
setState(resolvedState);
diff --git a/src/core/ContactFooter/ContactFooter.stories.tsx b/src/core/ContactFooter/ContactFooter.stories.tsx
index 233f7f56f..ee83a6089 100644
--- a/src/core/ContactFooter/ContactFooter.stories.tsx
+++ b/src/core/ContactFooter/ContactFooter.stories.tsx
@@ -1,4 +1,4 @@
-import ContactFooter from "./component.jsx";
+import ContactFooter from "./component.tsx";
export default {
title: "Components/Contact Footer",
diff --git a/src/core/ContactFooter/component.jsx b/src/core/ContactFooter/component.jsx
deleted file mode 100644
index b0399c66b..000000000
--- a/src/core/ContactFooter/component.jsx
+++ /dev/null
@@ -1,66 +0,0 @@
-import React, { useEffect } from "react";
-import T from "prop-types";
-
-import Icon from "../Icon/component.jsx";
-import _absUrl from "../url-base";
-
-import toggleChatWidget from "./component.js";
-
-export default function ContactFooter({ urlBase }) {
- useEffect(() => toggleChatWidget(), []);
- const absUrl = (path) => _absUrl(path, urlBase);
-
- return (
-
-
-
-
-
-
Live Chat
-
Reach out team of experts over chat powered by Ably.
-
-
-
-
-
-
-
-
Call us
-
-
- +1 877 434 5287 (USA, toll free)
-
-
- +44 20 3318 4689 (UK)
-
-
-
-
-
-
-
-
-
Technical and account support
-
We're standing by to help with any questions or code.
-
-
- Get support now
-
-
-
-
- );
-}
-
-ContactFooter.propTypes = {
- urlBase: T.string,
-};
diff --git a/src/core/ContactFooter/component.tsx b/src/core/ContactFooter/component.tsx
new file mode 100644
index 000000000..438a7da28
--- /dev/null
+++ b/src/core/ContactFooter/component.tsx
@@ -0,0 +1,92 @@
+import React, { useEffect } from "react";
+
+import Icon from "../Icon/component.tsx";
+import _absUrl from "../url-base.js";
+import toggleChatWidget from "../hubspot-chat-toggle";
+import "./component.css";
+
+type ContactFooterProps = {
+ urlBase: string;
+};
+
+const ContactFooter = ({ urlBase }: ContactFooterProps) => {
+ useEffect(() => toggleChatWidget({ dataId: "contact-footer" }), []);
+ const absUrl = (path) => _absUrl(path, urlBase);
+
+ return (
+
+
+
+
+
+
Live Chat
+
+ Reach out team of experts over chat powered by Ably.
+
+
+
+
+
+
+
+
+
Call us
+
+
+ +1 877 434 5287 (USA,
+ toll free)
+
+
+ +44 20 3318 4689 (UK)
+
+
+
+
+
+
+
+
+
+ Technical and account support
+
+
+ We're standing by to help with any questions or code.
+
+
+
+ Get support now
+
+
+
+
+ );
+};
+
+export default ContactFooter;
diff --git a/src/core/CookieMessage/CookieMessage.stories.tsx b/src/core/CookieMessage/CookieMessage.stories.tsx
index 72b141410..d43e57291 100644
--- a/src/core/CookieMessage/CookieMessage.stories.tsx
+++ b/src/core/CookieMessage/CookieMessage.stories.tsx
@@ -1,4 +1,4 @@
-import CookieMessage from "./component.jsx";
+import CookieMessage from "./component.tsx";
export default {
title: "Components/Cookie Message",
diff --git a/src/core/CookieMessage/component.css b/src/core/CookieMessage/component.css
index 6d6844b0c..41bbae259 100644
--- a/src/core/CookieMessage/component.css
+++ b/src/core/CookieMessage/component.css
@@ -1,13 +1,11 @@
-@layer components {
- .ui-cookie-message {
- @apply rounded-lg bg-white font-sans;
- @apply justify-between items-center;
- @apply opacity-100 z-50 bottom-0 fixed sm:flex;
- @apply p-16 mb-16 ml-16;
- max-width: 70vw;
- box-shadow: 0px 24px 32px 0px #0000000d;
- border: 1px solid var(--color-mid-grey);
- border-left: 0.5rem solid var(--color-electric-cyan);
- transition: bottom 250ms ease-out, opacity 150ms ease-out;
- }
+.ui-cookie-message {
+ @apply rounded-lg bg-white font-sans;
+ @apply justify-between items-center;
+ @apply opacity-100 z-50 bottom-0 fixed sm:flex;
+ @apply p-16 mb-16 ml-16;
+ max-width: 70vw;
+ box-shadow: 0px 24px 32px 0px #0000000d;
+ border: 1px solid var(--color-mid-grey);
+ border-left: 0.5rem solid var(--color-electric-cyan);
+ transition: bottom 250ms ease-out, opacity 150ms ease-out;
}
diff --git a/src/core/CookieMessage/component.jsx b/src/core/CookieMessage/component.tsx
similarity index 69%
rename from src/core/CookieMessage/component.jsx
rename to src/core/CookieMessage/component.tsx
index 512c4720f..a61af340a 100644
--- a/src/core/CookieMessage/component.jsx
+++ b/src/core/CookieMessage/component.tsx
@@ -1,13 +1,18 @@
import React, { useRef, useEffect, useState } from "react";
-import T from "prop-types";
import Cookie from "js-cookie";
+import "./component.css";
import _absUrl from "../url-base";
const COOKIE_EXPIRY = 365;
-export default function CookieMessage({ cookieId, urlBase }) {
- const ref = useRef(null);
+type CookieMessageProps = {
+ cookieId: string;
+ urlBase: string;
+};
+
+const CookieMessage = ({ cookieId, urlBase }: CookieMessageProps) => {
+ const ref = useRef(null);
const [hideCookieMessage, setHideCookieMessage] = useState(true);
useEffect(() => {
@@ -18,7 +23,7 @@ export default function CookieMessage({ cookieId, urlBase }) {
const handleClose = () => {
Cookie.set(cookieId, "1", { expires: COOKIE_EXPIRY });
- ref.current.classList.add("bottom-1", "opacity-0");
+ ref.current?.classList.add("bottom-1", "opacity-0");
setTimeout(() => setHideCookieMessage(true), 500);
};
@@ -35,14 +40,14 @@ export default function CookieMessage({ cookieId, urlBase }) {
{" "}
to improve your experience.
-