From bb0c49936c8b501211e6f04288334291bfa6f045 Mon Sep 17 00:00:00 2001 From: Max Alekseenko Date: Tue, 23 Jan 2024 13:46:00 +0100 Subject: [PATCH] add integration mark --- icons/integration/full.svg | 3 + icons/integration/partial.svg | 3 + lib/growthbook/init.ts | 1 + public/icons/name.d.ts | 2 + types/client/marketplace.ts | 1 + ui/marketplace/MarketplaceAppCard.tsx | 128 +++++++++++++++++++------- ui/marketplace/MarketplaceList.tsx | 1 + 7 files changed, 107 insertions(+), 32 deletions(-) create mode 100644 icons/integration/full.svg create mode 100644 icons/integration/partial.svg diff --git a/icons/integration/full.svg b/icons/integration/full.svg new file mode 100644 index 0000000000..58f9ed00ce --- /dev/null +++ b/icons/integration/full.svg @@ -0,0 +1,3 @@ + + + diff --git a/icons/integration/partial.svg b/icons/integration/partial.svg new file mode 100644 index 0000000000..892ce910e2 --- /dev/null +++ b/icons/integration/partial.svg @@ -0,0 +1,3 @@ + + + diff --git a/lib/growthbook/init.ts b/lib/growthbook/init.ts index d98b2b94b7..15188c8c7c 100644 --- a/lib/growthbook/init.ts +++ b/lib/growthbook/init.ts @@ -7,6 +7,7 @@ import { STORAGE_KEY, STORAGE_LIMIT } from './consts'; export interface GrowthBookFeatures { test_value: string; + marketplace_exp: boolean; } export const growthBook = (() => { diff --git a/public/icons/name.d.ts b/public/icons/name.d.ts index 09d8e061ce..78b92e2949 100644 --- a/public/icons/name.d.ts +++ b/public/icons/name.d.ts @@ -53,6 +53,8 @@ | "globe" | "graphQL" | "info" + | "integration/full" + | "integration/partial" | "key" | "lightning" | "link" diff --git a/types/client/marketplace.ts b/types/client/marketplace.ts index 766e2e4885..44b97e2dda 100644 --- a/types/client/marketplace.ts +++ b/types/client/marketplace.ts @@ -7,6 +7,7 @@ export type MarketplaceAppPreview = { shortDescription: string; categories: Array; url: string; + internalWallet?: boolean; } export type MarketplaceAppOverview = MarketplaceAppPreview & { diff --git a/ui/marketplace/MarketplaceAppCard.tsx b/ui/marketplace/MarketplaceAppCard.tsx index 67bc781aa3..d172a95652 100644 --- a/ui/marketplace/MarketplaceAppCard.tsx +++ b/ui/marketplace/MarketplaceAppCard.tsx @@ -1,10 +1,12 @@ -import { Box, IconButton, Image, Link, LinkBox, Skeleton, useColorModeValue } from '@chakra-ui/react'; +import { Box, IconButton, Image, Link, LinkBox, Skeleton, useColorModeValue, Tooltip } from '@chakra-ui/react'; import type { MouseEvent } from 'react'; import React, { useCallback } from 'react'; import type { MarketplaceAppPreview } from 'types/client/marketplace'; +import useFeatureValue from 'lib/growthbook/useFeatureValue'; import * as mixpanel from 'lib/mixpanel/index'; +import type { IconName } from 'ui/shared/IconSvg'; import IconSvg from 'ui/shared/IconSvg'; import MarketplaceAppCardLink from './MarketplaceAppCardLink'; @@ -29,9 +31,13 @@ const MarketplaceAppCard = ({ onInfoClick, isFavorite, onFavoriteClick, - isLoading, + isLoading: isDataLoading, showDisclaimer, + internalWallet, }: Props) => { + const { value: isExperiment, isLoading: isExperimentLoading } = useFeatureValue('marketplace_exp', false); + const isLoading = isDataLoading || isExperimentLoading; + const categoriesLabel = categories.join(', '); const handleClick = useCallback((event: MouseEvent) => { @@ -55,6 +61,23 @@ const MarketplaceAppCard = ({ const logoUrl = useColorModeValue(logo, logoDarkMode || logo); const moreButtonBgGradient = `linear(to-r, ${ useColorModeValue('whiteAlpha.50', 'blackAlpha.50') }, ${ useColorModeValue('white', 'black') } 20%)`; + const [ integrationIcon, integrationIconColor, integrationText ] = React.useMemo(() => { + let icon: IconName = 'integration/partial'; + let color = 'gray.400'; + let text = 'This app opens in Blockscout without Blockscout wallet functionality. Use your external web3 wallet to connect directly to this application'; + + if (external) { + icon = 'arrows/north-east'; + text = 'This app opens in a separate tab'; + } else if (internalWallet) { + icon = 'integration/full'; + color = 'green.500'; + text = 'This app opens in Blockscout and your Blockscout wallet connects automatically'; + } + + return [ icon, color, text ]; + }, [ external, internalWallet ]); + return ( + { isExperiment && ( + + + + ) } { shortDescription } { !isLoading && ( - - - More - - - - + + More info + + + ) : ( + + + More + + + + + ) ) } { !isLoading && ( )) }