From c1af8df24c8778998c0dc46e455bcf5a34789b70 Mon Sep 17 00:00:00 2001 From: Felipe Mendes Date: Wed, 5 Apr 2023 15:52:08 -0300 Subject: [PATCH] bug: UI colors not showing up on firefox for nfa (#208) * fix: color logo id without hashtag * feat: remove image from preview when the load fails * fix: dripStitches typing * refactor: move SVGPreview to components folder with NFAPreview name * fix: ens address variable --- ui/src/components/index.ts | 1 + ui/src/components/nfa-card/nfa-card.tsx | 4 +- ui/src/components/nfa-preview/index.ts | 1 + .../nfa-preview/nfa-preview.tsx} | 63 ++++++++++--------- ui/src/theme/themes.ts | 4 +- .../fields/ens-domain-field/ens-field.tsx | 2 +- ui/src/views/mint/nft-card/nft-card.tsx | 6 +- 7 files changed, 46 insertions(+), 35 deletions(-) create mode 100644 ui/src/components/nfa-preview/index.ts rename ui/src/{views/mint/nft-card/svg-preview.tsx => components/nfa-preview/nfa-preview.tsx} (86%) diff --git a/ui/src/components/index.ts b/ui/src/components/index.ts index 82ef219..69e8429 100644 --- a/ui/src/components/index.ts +++ b/ui/src/components/index.ts @@ -6,3 +6,4 @@ export * from './spinner'; export * from './toast'; export * from './step'; export * from './nfa-card'; +export * from './nfa-preview'; diff --git a/ui/src/components/nfa-card/nfa-card.tsx b/ui/src/components/nfa-card/nfa-card.tsx index 465de52..6cd545e 100644 --- a/ui/src/components/nfa-card/nfa-card.tsx +++ b/ui/src/components/nfa-card/nfa-card.tsx @@ -1,9 +1,9 @@ import { useMemo } from 'react'; import { To } from 'react-router-dom'; +import { NFAPreview } from '@/components'; import { lastNFAsPaginatedQuery } from '@/graphclient'; import { forwardStyledRef } from '@/theme'; -import { SVGPreview } from '@/views/mint/nft-card/svg-preview'; import { Flex } from '../layout'; import { NFACardStyles as S } from './nfa-card.styles'; @@ -45,7 +45,7 @@ export const NFACard: React.FC = forwardStyledRef< return ( - , + 'width' | 'height' | 'xmlns' | 'viewBox' +> & { color: string; logo: string; name: string; ens?: string; - css?: string; size: string; }; -/** - * SVGPreview renders the NFA image based in the provided props. - */ -export const SVGPreview: React.FC = ({ - color, - logo, - name, - ens = '', - css = '', - size, -}: SVGPreviewProps) => { +export const NFAPreview: React.FC = forwardStyledRef< + SVGSVGElement, + NFAPreviewProps +>(({ color, logo, name, ens = '', size, ...props }, ref) => { + const colorId = useMemo(() => color.slice(1), [color]); + return ( - @@ -43,7 +49,7 @@ export const SVGPreview: React.FC = ({ = ({ = ({ /> = ({ = ({ height="167" transform="matrix(0.987827 0.155557 -0.255261 0.966872 444.117 524.17)" href={logo} + onErrorCapture={(event) => (event.currentTarget.style.display = 'none')} /> @@ -161,7 +168,7 @@ export const SVGPreview: React.FC = ({ = ({ = ({ - + - + ); -}; +}); diff --git a/ui/src/theme/themes.ts b/ui/src/theme/themes.ts index 6a344ad..21a9c49 100644 --- a/ui/src/theme/themes.ts +++ b/ui/src/theme/themes.ts @@ -1,4 +1,5 @@ /* eslint-disable @typescript-eslint/ban-types */ +/* eslint-disable @typescript-eslint/explicit-function-return-type */ import { createStitches, DefaultThemeMap } from '@stitches/react'; import type { ConfigType } from '@stitches/react/types/config'; @@ -28,6 +29,7 @@ export interface CreateDripStitchesConfig< themeMap?: ConfigType.ThemeMap; utils?: ConfigType.Utils; } + export const createDripStitches = < Prefix extends string = '', Media extends {} = {}, @@ -36,7 +38,7 @@ export const createDripStitches = < Utils extends {} = {} >( config?: CreateDripStitchesConfig -): object => { +) => { const { prefix, theme, themeMap, utils, media } = config || {}; const _spacing = { diff --git a/ui/src/views/mint/nfa-step/form-step/fields/ens-domain-field/ens-field.tsx b/ui/src/views/mint/nfa-step/form-step/fields/ens-domain-field/ens-field.tsx index e97b82c..b10d289 100644 --- a/ui/src/views/mint/nfa-step/form-step/fields/ens-domain-field/ens-field.tsx +++ b/ui/src/views/mint/nfa-step/form-step/fields/ens-domain-field/ens-field.tsx @@ -12,7 +12,7 @@ export const EnsField: React.FC = () => { const { address } = useAccount(); const { data, error } = useQuery(getENSNamesDocument, { variables: { - address: address?.toString() || '', //should skip if undefined + address: address?.toLowerCase() || '', //should skip if undefined }, skip: address === undefined, }); diff --git a/ui/src/views/mint/nft-card/nft-card.tsx b/ui/src/views/mint/nft-card/nft-card.tsx index 45c8c0a..02ea9a2 100644 --- a/ui/src/views/mint/nft-card/nft-card.tsx +++ b/ui/src/views/mint/nft-card/nft-card.tsx @@ -1,7 +1,7 @@ import { Button, Card, Grid } from '@/components'; +import { NFAPreview } from '@/components'; import { useMintFormContext } from '../nfa-step/form-step'; -import { SVGPreview } from './svg-preview'; type NftCardProps = { title: string; @@ -44,13 +44,13 @@ export const NftCard: React.FC = ({ return ( -