From c819f6c5a674058c07baeabb78107022995a6d63 Mon Sep 17 00:00:00 2001 From: Thibaut Sardan Date: Tue, 22 Jun 2021 15:16:52 +0200 Subject: [PATCH 1/3] fix alerts --- .../common-components/src/Modal/Modal.tsx | 82 +++++++++---------- .../src/NumberInput/NumberInput.tsx | 12 +-- .../src/SearchBar/SearchBar.tsx | 5 +- .../src/TextInput/TextInput.tsx | 4 +- .../src/utils/colorManipulator.ts | 15 +--- .../src/Contexts/ThresholdKeyContext.tsx | 8 +- 6 files changed, 50 insertions(+), 76 deletions(-) diff --git a/packages/common-components/src/Modal/Modal.tsx b/packages/common-components/src/Modal/Modal.tsx index 958ca4b389..bb0beedfbd 100644 --- a/packages/common-components/src/Modal/Modal.tsx +++ b/packages/common-components/src/Modal/Modal.tsx @@ -142,9 +142,9 @@ interface IModalProps { testId?: string } -const Modal: React.FC = ({ +const Modal = ({ children, - className, + className = "", closePosition = "right", injectedClass, active = false, @@ -165,49 +165,49 @@ const Modal: React.FC = ({ useOnClickOutside(ref, () => handleClose()) - return active ? ( -
+
-
- {setActive && ( -
handleClose()} - className={clsx( - classes.closeIcon, + )} + > + {setActive && ( +
handleClose()} + className={clsx( + classes.closeIcon, injectedClass?.close, - `${closePosition}` - )} - > - -
- )} - {children} -
-
- ) : null + closePosition + )} + > + + + )} + {children} + + } export default Modal diff --git a/packages/common-components/src/NumberInput/NumberInput.tsx b/packages/common-components/src/NumberInput/NumberInput.tsx index 71f0e1354e..d5413f26c4 100644 --- a/packages/common-components/src/NumberInput/NumberInput.tsx +++ b/packages/common-components/src/NumberInput/NumberInput.tsx @@ -199,9 +199,7 @@ const useStyles = makeStyles( "& input": { fontSize: 16, lineHeight: "24px", - padding: `${constants.generalUnit}px ${ - constants.generalUnit * 1.5 - }px` + padding: `${constants.generalUnit}px ${constants.generalUnit * 1.5}px` }, "&.iconLeft input": { paddingLeft: @@ -227,9 +225,7 @@ const useStyles = makeStyles( }, "&.medium": { "& input": { - padding: `${constants.generalUnit * 0.625}px ${ - constants.generalUnit * 1.5 - }px`, + padding: `${constants.generalUnit * 0.625}px ${constants.generalUnit * 1.5}px`, fontSize: 16, lineHeight: "20px" }, @@ -257,9 +253,7 @@ const useStyles = makeStyles( }, "&.small": { "& input": { - padding: `${constants.generalUnit / constants.generalUnit}px ${ - constants.generalUnit - }px` + padding: `1px ${constants.generalUnit}px` }, "&.iconLeft input": { paddingLeft: diff --git a/packages/common-components/src/SearchBar/SearchBar.tsx b/packages/common-components/src/SearchBar/SearchBar.tsx index cd590742e9..2aa6af3cb4 100644 --- a/packages/common-components/src/SearchBar/SearchBar.tsx +++ b/packages/common-components/src/SearchBar/SearchBar.tsx @@ -23,7 +23,6 @@ const iconSize = { const useStyles = makeStyles( ({ constants, palette, animation, overrides, typography }: ITheme) => createStyles({ - // JSS in CSS goes here root: { ...typography.body2, display: "block", @@ -100,9 +99,7 @@ const useStyles = makeStyles( }, "&.small": { "& input": { - padding: `${constants.generalUnit / constants.generalUnit}px ${ - constants.generalUnit - }px` + padding: `1px ${constants.generalUnit}px` } } }, diff --git a/packages/common-components/src/TextInput/TextInput.tsx b/packages/common-components/src/TextInput/TextInput.tsx index 6e8c8f1c42..e959975f78 100644 --- a/packages/common-components/src/TextInput/TextInput.tsx +++ b/packages/common-components/src/TextInput/TextInput.tsx @@ -256,9 +256,7 @@ const useStyles = makeStyles( }, "&.small": { "& input": { - padding: `${constants.generalUnit / constants.generalUnit}px ${ - constants.generalUnit - }px` + padding: `1px ${constants.generalUnit}px` }, "&.iconLeft input": { paddingLeft: diff --git a/packages/common-theme/src/utils/colorManipulator.ts b/packages/common-theme/src/utils/colorManipulator.ts index 3b37c64b81..79865aa54e 100644 --- a/packages/common-theme/src/utils/colorManipulator.ts +++ b/packages/common-theme/src/utils/colorManipulator.ts @@ -124,20 +124,7 @@ export function decomposeColor(color: string): IColorObject { } // Converts a color object with type and values to a string. -export function recomposeColor(color: IColorObject) { - const { type } = color - const { values } = color - - let valuesArray: (number | string)[] = values - - if (type.indexOf("rgb") !== -1) { - // Only convert the first 3 values to int (i.e. not alpha) - valuesArray = values.map((n, i) => (i < 3 ? n : n)) as ColorValues - } else if (type.indexOf("hsl") !== -1) { - valuesArray[1] = `${values[1]}%` - valuesArray[2] = `${values[2]}%` - } - +export function recomposeColor({ type, values }: IColorObject) { return `${type}(${values.join(", ")})` } diff --git a/packages/files-ui/src/Contexts/ThresholdKeyContext.tsx b/packages/files-ui/src/Contexts/ThresholdKeyContext.tsx index b2681e31dc..2c97831ecb 100644 --- a/packages/files-ui/src/Contexts/ThresholdKeyContext.tsx +++ b/packages/files-ui/src/Contexts/ThresholdKeyContext.tsx @@ -500,7 +500,6 @@ const ThresholdKeyProvider = ({ children, network = "mainnet", enableLogging = f if (loginType === "web3") { let addressToUse = address - let signer if (!isReady || !provider) { const connected = await checkIsReady() @@ -508,10 +507,9 @@ const ThresholdKeyProvider = ({ children, network = "mainnet", enableLogging = f if (!connected || !provider) throw new Error("Unable to connect to wallet.") } - if(!signer){ - signer = provider.getSigner() - if (!signer) throw new Error("Signer undefined") - } + + const signer = provider.getSigner() + if (!signer) throw new Error("Signer undefined") if(!addressToUse){ // checkIsReady above doesn't make sure that the address is defined From 698ad53f634a944d39265943a53c7f5a4d9405e6 Mon Sep 17 00:00:00 2001 From: Thibaut Sardan Date: Tue, 22 Jun 2021 15:37:06 +0200 Subject: [PATCH 2/3] fix regex --- packages/files-ui/cypress/support/index.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/files-ui/cypress/support/index.ts b/packages/files-ui/cypress/support/index.ts index 9fd31b5693..cb8233c617 100644 --- a/packages/files-ui/cypress/support/index.ts +++ b/packages/files-ui/cypress/support/index.ts @@ -19,10 +19,11 @@ import "./commands" // the following gets rid of the exception "ResizeObserver loop limit exceeded" // which someone on the internet says we can safely ignore // source https://stackoverflow.com/questions/49384120/resizeobserver-loop-limit-exceeded -const resizeObserverLoopErrRe = /^[^(ResizeObserver loop limit exceeded)]/ Cypress.on("uncaught:exception", (err) => { /* returning false here prevents Cypress from failing the test */ - if (resizeObserverLoopErrRe.test(err.message)) { + if (err.message.includes("ResizeObserver loop limit exceeded")) { + // returning false here prevents Cypress from + // failing the test return false } }) From 6cddef2c72fedbcb76e44362121f03dab056383f Mon Sep 17 00:00:00 2001 From: Thibaut Sardan Date: Tue, 22 Jun 2021 15:58:39 +0200 Subject: [PATCH 3/3] indentation --- packages/common-components/src/Modal/Modal.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/common-components/src/Modal/Modal.tsx b/packages/common-components/src/Modal/Modal.tsx index bb0beedfbd..e0269a168b 100644 --- a/packages/common-components/src/Modal/Modal.tsx +++ b/packages/common-components/src/Modal/Modal.tsx @@ -198,8 +198,8 @@ const Modal = ({ onClick={() => handleClose()} className={clsx( classes.closeIcon, - injectedClass?.close, - closePosition + injectedClass?.close, + closePosition )} >