From 0c413f3fb916d3424a2fac040bdc2284ab05acf8 Mon Sep 17 00:00:00 2001 From: Jaco Date: Wed, 25 Jan 2023 13:02:06 +0200 Subject: [PATCH] Adjust styled-component injection (#707) * Adjust styled-component injection * Adjust --- package.json | 2 +- packages/react-identicon/src/Identicon.tsx | 56 +++++++++---------- .../react-identicon/src/icons/Ethereum.tsx | 15 +++-- packages/react-qr/src/Display.tsx | 10 ++-- packages/react-qr/src/Scan.tsx | 10 ++-- yarn.lock | 10 ++-- 6 files changed, 57 insertions(+), 46 deletions(-) diff --git a/package.json b/package.json index c723cefc..d0f9b151 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ "@babel/runtime": "^7.20.13", "@polkadot/dev": "^0.67.187", "@polkadot/x-bundle": "^10.2.6", - "@types/jest": "^29.2.6", + "@types/jest": "^29.4.0", "babel-loader": "^8.3.0", "babel-plugin-transform-vue-template": "^0.4.2", "empty": "^0.10.1", diff --git a/packages/react-identicon/src/Identicon.tsx b/packages/react-identicon/src/Identicon.tsx index ca14ff19..996d60f7 100644 --- a/packages/react-identicon/src/Identicon.tsx +++ b/packages/react-identicon/src/Identicon.tsx @@ -31,32 +31,6 @@ const Components: Record> = { substrate: Jdenticon }; -const Wrapper = styled.div` - cursor: copy; - display: inline-block; - line-height: 0; - - > .container { - position: relative; - - > div, - > svg { - position: relative; - } - - &.highlight:before { - position: absolute; - top: 0; - left: 0; - right: 0; - bottom: 0; - border-radius: 50%; - box-shadow: 0 0 5px 2px #aaa; - content: ''; - } - } -`; - class BaseIcon extends React.PureComponent { public override state: State = { address: '', @@ -121,7 +95,7 @@ class BaseIcon extends React.PureComponent { : Custom || Components[theme === 'default' ? ICON_DEFAULT_HOST : theme] || Fallback; return ( - { publicKey={publicKey} size={size} /> - + ); } @@ -151,4 +125,30 @@ function Icon (props: Props): React.ReactElement { return ; } +const StyledDiv = styled.div` + cursor: copy; + display: inline-block; + line-height: 0; + + > .container { + position: relative; + + > div, + > svg { + position: relative; + } + + &.highlight:before { + position: absolute; + top: 0; + left: 0; + right: 0; + bottom: 0; + border-radius: 50%; + box-shadow: 0 0 5px 2px #aaa; + content: ''; + } + } +`; + export const Identicon = React.memo(Icon); diff --git a/packages/react-identicon/src/icons/Ethereum.tsx b/packages/react-identicon/src/icons/Ethereum.tsx index 5bf8a9ba..25668414 100644 --- a/packages/react-identicon/src/icons/Ethereum.tsx +++ b/packages/react-identicon/src/icons/Ethereum.tsx @@ -7,23 +7,30 @@ import makeBlockie from 'ethereum-blockies-base64'; import React, { useMemo } from 'react'; import styled from 'styled-components'; -function Identicon ({ address, className = '', style }: Props): React.ReactElement { +interface ImgProps { + size: number; +} + +function Identicon ({ address, className = '', size, style }: Props): React.ReactElement { const imgSrc = useMemo( () => makeBlockie(address), [address] ); return ( - ); } -export const Ethereum = React.memo(styled(Identicon)(({ size }: Props) => ` +const StyledImg = styled.img(({ size }: ImgProps) => ` display: block; height: ${size}px; width: ${size}px; -`)); +`); + +export const Ethereum = React.memo(Identicon); diff --git a/packages/react-qr/src/Display.tsx b/packages/react-qr/src/Display.tsx index 7e8b280d..69a8d953 100644 --- a/packages/react-qr/src/Display.tsx +++ b/packages/react-qr/src/Display.tsx @@ -120,7 +120,7 @@ function Display ({ className, size, skipEncoding, style, timerDelay = DEFAULT_F } return ( -
@@ -130,11 +130,11 @@ function Display ({ className, size, skipEncoding, style, timerDelay = DEFAULT_F >
- + ); } -export const QrDisplay = React.memo(styled(Display)` +const StyledDiv = styled.div` .ui--qr-Display { height: 100%; width: 100%; @@ -148,4 +148,6 @@ export const QrDisplay = React.memo(styled(Display)` width: auto !important; } } -`); +`; + +export const QrDisplay = React.memo(Display); diff --git a/packages/react-qr/src/Scan.tsx b/packages/react-qr/src/Scan.tsx index d330e1cb..f2d202cc 100644 --- a/packages/react-qr/src/Scan.tsx +++ b/packages/react-qr/src/Scan.tsx @@ -39,7 +39,7 @@ function Scan ({ className, delay = DEFAULT_DELAY, onError = DEFAULT_ERROR, onSc ); return ( -
@@ -50,11 +50,11 @@ function Scan ({ className, delay = DEFAULT_DELAY, onError = DEFAULT_ERROR, onSc onScan={_onScan} style={style} /> -
+ ); } -export const QrScan = React.memo(styled(Scan)` +const StyledDiv = styled.div` .ui--qr-Scan { display: inline-block; height: 100%; @@ -65,4 +65,6 @@ export const QrScan = React.memo(styled(Scan)` margin: 0; } } -`); +`; + +export const QrScan = React.memo(Scan); diff --git a/yarn.lock b/yarn.lock index a192c8e9..31cd53f1 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3254,13 +3254,13 @@ __metadata: languageName: node linkType: hard -"@types/jest@npm:^29.2.6": - version: 29.2.6 - resolution: "@types/jest@npm:29.2.6" +"@types/jest@npm:^29.4.0": + version: 29.4.0 + resolution: "@types/jest@npm:29.4.0" dependencies: expect: ^29.0.0 pretty-format: ^29.0.0 - checksum: 90190ac830334af1470d255853f9621fe657e5030b4d96773fc1f884833cd303c76580b00c1b86dc38a8db94f1c7141d462190437a10af31852b8845a57c48ba + checksum: 23760282362a252e6690314584d83a47512d4cd61663e957ed3398ecf98195fe931c45606ee2f9def12f8ed7d8aa102d492ec42d26facdaf8b78094a31e6568e languageName: node linkType: hard @@ -12993,7 +12993,7 @@ __metadata: "@babel/runtime": ^7.20.13 "@polkadot/dev": ^0.67.187 "@polkadot/x-bundle": ^10.2.6 - "@types/jest": ^29.2.6 + "@types/jest": ^29.4.0 babel-loader: ^8.3.0 babel-plugin-transform-vue-template: ^0.4.2 empty: ^0.10.1