From 4bb78e98919f566b6f431eaa5af50687a9513a7d Mon Sep 17 00:00:00 2001 From: Maciek Date: Mon, 27 Feb 2023 16:44:48 +0100 Subject: [PATCH 1/8] chore(ui-toolkit): loader no rerender version only (#3011) --- apps/static/src/assets/preloader.css | 108 +++++++++++++ .../components/preloader/preloader.tsx | 2 +- apps/trading/pages/gen-styles.scss | 33 ++-- apps/trading/public/preloader.css | 146 +++++++++--------- .../src/components/loader/loader.tsx | 21 +-- 5 files changed, 202 insertions(+), 108 deletions(-) create mode 100644 apps/static/src/assets/preloader.css diff --git a/apps/static/src/assets/preloader.css b/apps/static/src/assets/preloader.css new file mode 100644 index 000000000..9ea72991c --- /dev/null +++ b/apps/static/src/assets/preloader.css @@ -0,0 +1,108 @@ +.pre-loader { + display: flex; + width: 100%; + min-height: 100vh; + justify-content: center; + align-items: center; +} +.pre-loader .loader-item { + width: 10px; + height: 10px; + background: #000; +} +.pre-loader .pre-loader-center { + align-items: center; + display: flex; + flex-direction: column; +} +.pre-loader .pre-loader-wrapper { + width: 50px; + height: 50px; + display: flex; + flex-wrap: wrap; +} +.loader-item:nth-child(0) { + animation-delay: 0ms; + animation-direction: reverse; +} +.loader-item:first-child { + animation-delay: -0.2s; + animation-direction: alternate; +} +.loader-item:nth-child(2) { + animation-delay: 0.4s; + animation-direction: reverse; +} +.loader-item:nth-child(3) { + animation-delay: -0.15s; + animation-direction: alternate; +} +.loader-item:nth-child(4) { + animation-delay: 0.6s; + animation-direction: reverse; +} +.loader-item:nth-child(5) { + animation-delay: -1s; + animation-direction: alternate; +} +.loader-item:nth-child(6) { + animation-delay: 0.3s; + animation-direction: reverse; +} +.loader-item:nth-child(7) { + animation-delay: -0.35s; + animation-direction: alternate; +} +.loader-item:nth-child(8) { + animation-delay: 2s; + animation-direction: reverse; +} +.loader-item:nth-child(9) { + animation-delay: -0.45s; + animation-direction: alternate; +} +.loader-item:nth-child(10) { + animation-delay: 2s; + animation-direction: reverse; +} +.loader-item:nth-child(11) { + animation-delay: -0.55s; + animation-direction: alternate; +} +.loader-item:nth-child(12) { + animation-delay: 1.2s; + animation-direction: reverse; +} +.loader-item:nth-child(13) { + animation-delay: -2.6s; + animation-direction: alternate; +} +.loader-item:nth-child(14) { + animation-delay: 2.8s; + animation-direction: reverse; +} +.loader-item:nth-child(15) { + animation-delay: -3s; + animation-direction: alternate; +} +.loader-item:nth-child(16) { + animation-delay: 1.6s; + animation-direction: reverse; +} +.loader-item { + animation: flickering 0.4s linear infinite alternate; +} +@keyframes flickering { + 0% { + opacity: 1; + } + 25% { + opacity: 1; + } + 26% { + opacity: 0; + } + to { + opacity: 0; + } +} diff --git a/apps/trading/components/preloader/preloader.tsx b/apps/trading/components/preloader/preloader.tsx index 7ae503363..a973d590b 100644 --- a/apps/trading/components/preloader/preloader.tsx +++ b/apps/trading/components/preloader/preloader.tsx @@ -13,7 +13,7 @@ export const Preloader = () => { `}
- +
); diff --git a/apps/trading/pages/gen-styles.scss b/apps/trading/pages/gen-styles.scss index 6737f9167..c25e95f6a 100644 --- a/apps/trading/pages/gen-styles.scss +++ b/apps/trading/pages/gen-styles.scss @@ -4,17 +4,10 @@ min-height: 100vh; justify-content: center; align-items: center; - - @for $i from 0 through 16 { - .loader-item:nth-child(#{$i}) { - @if $i % 2 == 0 { - animation-delay: #{$i * 50 * random(5)}ms; - animation-direction: reverse; - } @else { - animation-delay: #{$i * -50 * random(5)}ms; - animation-direction: alternate; - } - } + .loader-item { + width: 10px; + height: 10px; + background: black; } .pre-loader-center { align-items: center; @@ -27,13 +20,21 @@ display: flex; flex-wrap: wrap; } - .loader-item { - width: 10px; - height: 10px; - background: black; - animation: flickering 0.4s steps(2, jump-none) alternate infinite; +} +@for $i from 0 through 16 { + .loader-item:nth-child(#{$i}) { + @if $i % 2 == 0 { + animation-delay: #{$i * 50 * random(5)}ms; + animation-direction: reverse; + } @else { + animation-delay: #{$i * -50 * random(5)}ms; + animation-direction: alternate; + } } } +.loader-item { + animation: flickering 0.4s linear alternate infinite; +} @keyframes flickering { 0% { opacity: 1; diff --git a/apps/trading/public/preloader.css b/apps/trading/public/preloader.css index 33afae4ea..9ea72991c 100644 --- a/apps/trading/public/preloader.css +++ b/apps/trading/public/preloader.css @@ -5,73 +5,10 @@ justify-content: center; align-items: center; } -.pre-loader .loader-item:nth-child(0) { - animation-delay: 0ms; - animation-direction: reverse; -} -.pre-loader .loader-item:first-child { - animation-delay: -0.2s; - animation-direction: alternate; -} -.pre-loader .loader-item:nth-child(2) { - animation-delay: 0.1s; - animation-direction: reverse; -} -.pre-loader .loader-item:nth-child(3) { - animation-delay: -0.15s; - animation-direction: alternate; -} -.pre-loader .loader-item:nth-child(4) { - animation-delay: 1s; - animation-direction: reverse; -} -.pre-loader .loader-item:nth-child(5) { - animation-delay: -0.25s; - animation-direction: alternate; -} -.pre-loader .loader-item:nth-child(6) { - animation-delay: 0.3s; - animation-direction: reverse; -} -.pre-loader .loader-item:nth-child(7) { - animation-delay: -1.05s; - animation-direction: alternate; -} -.pre-loader .loader-item:nth-child(8) { - animation-delay: 0.8s; - animation-direction: reverse; -} -.pre-loader .loader-item:nth-child(9) { - animation-delay: -0.9s; - animation-direction: alternate; -} -.pre-loader .loader-item:nth-child(10) { - animation-delay: 0.5s; - animation-direction: reverse; -} -.pre-loader .loader-item:nth-child(11) { - animation-delay: -2.75s; - animation-direction: alternate; -} -.pre-loader .loader-item:nth-child(12) { - animation-delay: 2.4s; - animation-direction: reverse; -} -.pre-loader .loader-item:nth-child(13) { - animation-delay: -0.65s; - animation-direction: alternate; -} -.pre-loader .loader-item:nth-child(14) { - animation-delay: 0.7s; - animation-direction: reverse; -} -.pre-loader .loader-item:nth-child(15) { - animation-delay: -3s; - animation-direction: alternate; -} -.pre-loader .loader-item:nth-child(16) { - animation-delay: 2.4s; - animation-direction: reverse; +.pre-loader .loader-item { + width: 10px; + height: 10px; + background: #000; } .pre-loader .pre-loader-center { align-items: center; @@ -84,11 +21,76 @@ display: flex; flex-wrap: wrap; } -.pre-loader .loader-item { - width: 10px; - height: 10px; - background: #000; - animation: flickering 0.4s steps(2, jump-none) infinite alternate; +.loader-item:nth-child(0) { + animation-delay: 0ms; + animation-direction: reverse; +} +.loader-item:first-child { + animation-delay: -0.2s; + animation-direction: alternate; +} +.loader-item:nth-child(2) { + animation-delay: 0.4s; + animation-direction: reverse; +} +.loader-item:nth-child(3) { + animation-delay: -0.15s; + animation-direction: alternate; +} +.loader-item:nth-child(4) { + animation-delay: 0.6s; + animation-direction: reverse; +} +.loader-item:nth-child(5) { + animation-delay: -1s; + animation-direction: alternate; +} +.loader-item:nth-child(6) { + animation-delay: 0.3s; + animation-direction: reverse; +} +.loader-item:nth-child(7) { + animation-delay: -0.35s; + animation-direction: alternate; +} +.loader-item:nth-child(8) { + animation-delay: 2s; + animation-direction: reverse; +} +.loader-item:nth-child(9) { + animation-delay: -0.45s; + animation-direction: alternate; +} +.loader-item:nth-child(10) { + animation-delay: 2s; + animation-direction: reverse; +} +.loader-item:nth-child(11) { + animation-delay: -0.55s; + animation-direction: alternate; +} +.loader-item:nth-child(12) { + animation-delay: 1.2s; + animation-direction: reverse; +} +.loader-item:nth-child(13) { + animation-delay: -2.6s; + animation-direction: alternate; +} +.loader-item:nth-child(14) { + animation-delay: 2.8s; + animation-direction: reverse; +} +.loader-item:nth-child(15) { + animation-delay: -3s; + animation-direction: alternate; +} +.loader-item:nth-child(16) { + animation-delay: 1.6s; + animation-direction: reverse; +} +.loader-item { + animation: flickering 0.4s linear infinite alternate; } @keyframes flickering { 0% { diff --git a/libs/ui-toolkit/src/components/loader/loader.tsx b/libs/ui-toolkit/src/components/loader/loader.tsx index 47b8e6ede..89ada6310 100644 --- a/libs/ui-toolkit/src/components/loader/loader.tsx +++ b/libs/ui-toolkit/src/components/loader/loader.tsx @@ -1,5 +1,5 @@ import classNames from 'classnames'; -import { useEffect, useMemo, useState } from 'react'; +import { useMemo } from 'react'; const pseudoRandom = (seed: number) => { let value = seed; @@ -12,26 +12,9 @@ const pseudoRandom = (seed: number) => { export interface LoaderProps { size?: 'small' | 'large'; forceTheme?: 'dark' | 'light'; - preloader?: boolean; } -export const Loader = ({ - size = 'large', - forceTheme, - preloader, -}: LoaderProps) => { - const [, forceRender] = useState(false); - - useEffect(() => { - const interval = preloader - ? undefined - : setInterval(() => { - forceRender((x) => !x); - }, 100); - - return () => clearInterval(interval); - }, [preloader]); - +export const Loader = ({ size = 'large', forceTheme }: LoaderProps) => { const itemClasses = classNames('loader-item', { 'dark:bg-white bg-black': !forceTheme, 'bg-white': forceTheme === 'dark', From a02100b079e59ffa2abd48b4234325824c1c6ffb Mon Sep 17 00:00:00 2001 From: Maciek Date: Mon, 27 Feb 2023 16:51:50 +0100 Subject: [PATCH 2/8] chore(ui-toolkit): revert: loader no rerender version only --- apps/static/src/assets/preloader.css | 108 ------------- .../components/preloader/preloader.tsx | 2 +- apps/trading/pages/gen-styles.scss | 33 ++-- apps/trading/public/preloader.css | 146 +++++++++--------- .../src/components/loader/loader.tsx | 21 ++- 5 files changed, 108 insertions(+), 202 deletions(-) delete mode 100644 apps/static/src/assets/preloader.css diff --git a/apps/static/src/assets/preloader.css b/apps/static/src/assets/preloader.css deleted file mode 100644 index 9ea72991c..000000000 --- a/apps/static/src/assets/preloader.css +++ /dev/null @@ -1,108 +0,0 @@ -.pre-loader { - display: flex; - width: 100%; - min-height: 100vh; - justify-content: center; - align-items: center; -} -.pre-loader .loader-item { - width: 10px; - height: 10px; - background: #000; -} -.pre-loader .pre-loader-center { - align-items: center; - display: flex; - flex-direction: column; -} -.pre-loader .pre-loader-wrapper { - width: 50px; - height: 50px; - display: flex; - flex-wrap: wrap; -} -.loader-item:nth-child(0) { - animation-delay: 0ms; - animation-direction: reverse; -} -.loader-item:first-child { - animation-delay: -0.2s; - animation-direction: alternate; -} -.loader-item:nth-child(2) { - animation-delay: 0.4s; - animation-direction: reverse; -} -.loader-item:nth-child(3) { - animation-delay: -0.15s; - animation-direction: alternate; -} -.loader-item:nth-child(4) { - animation-delay: 0.6s; - animation-direction: reverse; -} -.loader-item:nth-child(5) { - animation-delay: -1s; - animation-direction: alternate; -} -.loader-item:nth-child(6) { - animation-delay: 0.3s; - animation-direction: reverse; -} -.loader-item:nth-child(7) { - animation-delay: -0.35s; - animation-direction: alternate; -} -.loader-item:nth-child(8) { - animation-delay: 2s; - animation-direction: reverse; -} -.loader-item:nth-child(9) { - animation-delay: -0.45s; - animation-direction: alternate; -} -.loader-item:nth-child(10) { - animation-delay: 2s; - animation-direction: reverse; -} -.loader-item:nth-child(11) { - animation-delay: -0.55s; - animation-direction: alternate; -} -.loader-item:nth-child(12) { - animation-delay: 1.2s; - animation-direction: reverse; -} -.loader-item:nth-child(13) { - animation-delay: -2.6s; - animation-direction: alternate; -} -.loader-item:nth-child(14) { - animation-delay: 2.8s; - animation-direction: reverse; -} -.loader-item:nth-child(15) { - animation-delay: -3s; - animation-direction: alternate; -} -.loader-item:nth-child(16) { - animation-delay: 1.6s; - animation-direction: reverse; -} -.loader-item { - animation: flickering 0.4s linear infinite alternate; -} -@keyframes flickering { - 0% { - opacity: 1; - } - 25% { - opacity: 1; - } - 26% { - opacity: 0; - } - to { - opacity: 0; - } -} diff --git a/apps/trading/components/preloader/preloader.tsx b/apps/trading/components/preloader/preloader.tsx index a973d590b..7ae503363 100644 --- a/apps/trading/components/preloader/preloader.tsx +++ b/apps/trading/components/preloader/preloader.tsx @@ -13,7 +13,7 @@ export const Preloader = () => { `}
- +
); diff --git a/apps/trading/pages/gen-styles.scss b/apps/trading/pages/gen-styles.scss index c25e95f6a..6737f9167 100644 --- a/apps/trading/pages/gen-styles.scss +++ b/apps/trading/pages/gen-styles.scss @@ -4,10 +4,17 @@ min-height: 100vh; justify-content: center; align-items: center; - .loader-item { - width: 10px; - height: 10px; - background: black; + + @for $i from 0 through 16 { + .loader-item:nth-child(#{$i}) { + @if $i % 2 == 0 { + animation-delay: #{$i * 50 * random(5)}ms; + animation-direction: reverse; + } @else { + animation-delay: #{$i * -50 * random(5)}ms; + animation-direction: alternate; + } + } } .pre-loader-center { align-items: center; @@ -20,21 +27,13 @@ display: flex; flex-wrap: wrap; } -} -@for $i from 0 through 16 { - .loader-item:nth-child(#{$i}) { - @if $i % 2 == 0 { - animation-delay: #{$i * 50 * random(5)}ms; - animation-direction: reverse; - } @else { - animation-delay: #{$i * -50 * random(5)}ms; - animation-direction: alternate; - } + .loader-item { + width: 10px; + height: 10px; + background: black; + animation: flickering 0.4s steps(2, jump-none) alternate infinite; } } -.loader-item { - animation: flickering 0.4s linear alternate infinite; -} @keyframes flickering { 0% { opacity: 1; diff --git a/apps/trading/public/preloader.css b/apps/trading/public/preloader.css index 9ea72991c..33afae4ea 100644 --- a/apps/trading/public/preloader.css +++ b/apps/trading/public/preloader.css @@ -5,10 +5,73 @@ justify-content: center; align-items: center; } -.pre-loader .loader-item { - width: 10px; - height: 10px; - background: #000; +.pre-loader .loader-item:nth-child(0) { + animation-delay: 0ms; + animation-direction: reverse; +} +.pre-loader .loader-item:first-child { + animation-delay: -0.2s; + animation-direction: alternate; +} +.pre-loader .loader-item:nth-child(2) { + animation-delay: 0.1s; + animation-direction: reverse; +} +.pre-loader .loader-item:nth-child(3) { + animation-delay: -0.15s; + animation-direction: alternate; +} +.pre-loader .loader-item:nth-child(4) { + animation-delay: 1s; + animation-direction: reverse; +} +.pre-loader .loader-item:nth-child(5) { + animation-delay: -0.25s; + animation-direction: alternate; +} +.pre-loader .loader-item:nth-child(6) { + animation-delay: 0.3s; + animation-direction: reverse; +} +.pre-loader .loader-item:nth-child(7) { + animation-delay: -1.05s; + animation-direction: alternate; +} +.pre-loader .loader-item:nth-child(8) { + animation-delay: 0.8s; + animation-direction: reverse; +} +.pre-loader .loader-item:nth-child(9) { + animation-delay: -0.9s; + animation-direction: alternate; +} +.pre-loader .loader-item:nth-child(10) { + animation-delay: 0.5s; + animation-direction: reverse; +} +.pre-loader .loader-item:nth-child(11) { + animation-delay: -2.75s; + animation-direction: alternate; +} +.pre-loader .loader-item:nth-child(12) { + animation-delay: 2.4s; + animation-direction: reverse; +} +.pre-loader .loader-item:nth-child(13) { + animation-delay: -0.65s; + animation-direction: alternate; +} +.pre-loader .loader-item:nth-child(14) { + animation-delay: 0.7s; + animation-direction: reverse; +} +.pre-loader .loader-item:nth-child(15) { + animation-delay: -3s; + animation-direction: alternate; +} +.pre-loader .loader-item:nth-child(16) { + animation-delay: 2.4s; + animation-direction: reverse; } .pre-loader .pre-loader-center { align-items: center; @@ -21,76 +84,11 @@ display: flex; flex-wrap: wrap; } -.loader-item:nth-child(0) { - animation-delay: 0ms; - animation-direction: reverse; -} -.loader-item:first-child { - animation-delay: -0.2s; - animation-direction: alternate; -} -.loader-item:nth-child(2) { - animation-delay: 0.4s; - animation-direction: reverse; -} -.loader-item:nth-child(3) { - animation-delay: -0.15s; - animation-direction: alternate; -} -.loader-item:nth-child(4) { - animation-delay: 0.6s; - animation-direction: reverse; -} -.loader-item:nth-child(5) { - animation-delay: -1s; - animation-direction: alternate; -} -.loader-item:nth-child(6) { - animation-delay: 0.3s; - animation-direction: reverse; -} -.loader-item:nth-child(7) { - animation-delay: -0.35s; - animation-direction: alternate; -} -.loader-item:nth-child(8) { - animation-delay: 2s; - animation-direction: reverse; -} -.loader-item:nth-child(9) { - animation-delay: -0.45s; - animation-direction: alternate; -} -.loader-item:nth-child(10) { - animation-delay: 2s; - animation-direction: reverse; -} -.loader-item:nth-child(11) { - animation-delay: -0.55s; - animation-direction: alternate; -} -.loader-item:nth-child(12) { - animation-delay: 1.2s; - animation-direction: reverse; -} -.loader-item:nth-child(13) { - animation-delay: -2.6s; - animation-direction: alternate; -} -.loader-item:nth-child(14) { - animation-delay: 2.8s; - animation-direction: reverse; -} -.loader-item:nth-child(15) { - animation-delay: -3s; - animation-direction: alternate; -} -.loader-item:nth-child(16) { - animation-delay: 1.6s; - animation-direction: reverse; -} -.loader-item { - animation: flickering 0.4s linear infinite alternate; +.pre-loader .loader-item { + width: 10px; + height: 10px; + background: #000; + animation: flickering 0.4s steps(2, jump-none) infinite alternate; } @keyframes flickering { 0% { diff --git a/libs/ui-toolkit/src/components/loader/loader.tsx b/libs/ui-toolkit/src/components/loader/loader.tsx index 89ada6310..47b8e6ede 100644 --- a/libs/ui-toolkit/src/components/loader/loader.tsx +++ b/libs/ui-toolkit/src/components/loader/loader.tsx @@ -1,5 +1,5 @@ import classNames from 'classnames'; -import { useMemo } from 'react'; +import { useEffect, useMemo, useState } from 'react'; const pseudoRandom = (seed: number) => { let value = seed; @@ -12,9 +12,26 @@ const pseudoRandom = (seed: number) => { export interface LoaderProps { size?: 'small' | 'large'; forceTheme?: 'dark' | 'light'; + preloader?: boolean; } -export const Loader = ({ size = 'large', forceTheme }: LoaderProps) => { +export const Loader = ({ + size = 'large', + forceTheme, + preloader, +}: LoaderProps) => { + const [, forceRender] = useState(false); + + useEffect(() => { + const interval = preloader + ? undefined + : setInterval(() => { + forceRender((x) => !x); + }, 100); + + return () => clearInterval(interval); + }, [preloader]); + const itemClasses = classNames('loader-item', { 'dark:bg-white bg-black': !forceTheme, 'bg-white': forceTheme === 'dark', From 4eb6e09bd49f8d78b9c628c9855cd8ef2eb88020 Mon Sep 17 00:00:00 2001 From: "m.ray" <16125548+MadalinaRaicu@users.noreply.github.com> Date: Mon, 27 Feb 2023 13:04:13 -0500 Subject: [PATCH 3/8] fix(trading): condense deal ticket & market info price range snags (#3012) --- .../app/components/markets/market-details.tsx | 5 +- libs/assets/src/lib/asset-details-dialog.tsx | 2 +- .../deal-ticket/deal-ticket-button.tsx | 2 +- .../deal-ticket/deal-ticket-fee-details.tsx | 2 +- .../deal-ticket/deal-ticket-limit-amount.tsx | 2 +- .../deal-ticket/deal-ticket-market-amount.tsx | 4 +- .../components/deal-ticket/deal-ticket.tsx | 12 +- .../components/market-info/info-market.tsx | 110 ++++++++++-------- .../src/lib/format/number.spec.tsx | 18 +++ .../src/components/form-group/form-group.tsx | 2 +- .../key-value-table/key-value-table.tsx | 6 +- 11 files changed, 96 insertions(+), 69 deletions(-) diff --git a/apps/explorer/src/app/components/markets/market-details.tsx b/apps/explorer/src/app/components/markets/market-details.tsx index 405f354a9..2b642a6d3 100644 --- a/apps/explorer/src/app/components/markets/market-details.tsx +++ b/apps/explorer/src/app/components/markets/market-details.tsx @@ -184,9 +184,8 @@ export const MarketDetails = ({ content: ( <>

- {`For liquidity orders count towards a commitment they have to be - within either the liquidity or price monitoring bounds (whichever is - tighter).`} + {`For liquidity orders to count towards a commitment, they must be + within the liquidity monitoring bounds.`}

{`The liquidity price range is a ${liquidityPriceRange} difference from the mid diff --git a/libs/assets/src/lib/asset-details-dialog.tsx b/libs/assets/src/lib/asset-details-dialog.tsx index 4c581df8f..a45789b3a 100644 --- a/libs/assets/src/lib/asset-details-dialog.tsx +++ b/libs/assets/src/lib/asset-details-dialog.tsx @@ -98,7 +98,7 @@ export const AssetDetailsDialog = ({ }} > {content} -

+

{t( 'There is 1 unit of the settlement asset (%s) to every 1 quote unit.', [assetSymbol] diff --git a/libs/deal-ticket/src/components/deal-ticket/deal-ticket-button.tsx b/libs/deal-ticket/src/components/deal-ticket/deal-ticket-button.tsx index 5960612bd..1eae3d5a6 100644 --- a/libs/deal-ticket/src/components/deal-ticket/deal-ticket-button.tsx +++ b/libs/deal-ticket/src/components/deal-ticket/deal-ticket-button.tsx @@ -12,7 +12,7 @@ export const DealTicketButton = ({ disabled, variant }: Props) => { const { pubKey, isReadOnly } = useVegaWallet(); const isDisabled = !pubKey || isReadOnly || disabled; return ( -

+