Skip to content

Commit

Permalink
add integration mark
Browse files Browse the repository at this point in the history
  • Loading branch information
maxaleks committed Jan 23, 2024
1 parent e56e875 commit bb0c499
Show file tree
Hide file tree
Showing 7 changed files with 107 additions and 32 deletions.
3 changes: 3 additions & 0 deletions icons/integration/full.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions icons/integration/partial.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions lib/growthbook/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { STORAGE_KEY, STORAGE_LIMIT } from './consts';

export interface GrowthBookFeatures {
test_value: string;
marketplace_exp: boolean;
}

export const growthBook = (() => {
Expand Down
2 changes: 2 additions & 0 deletions public/icons/name.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@
| "globe"
| "graphQL"
| "info"
| "integration/full"
| "integration/partial"
| "key"
| "lightning"
| "link"
Expand Down
1 change: 1 addition & 0 deletions types/client/marketplace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export type MarketplaceAppPreview = {
shortDescription: string;
categories: Array<string>;
url: string;
internalWallet?: boolean;
}

export type MarketplaceAppOverview = MarketplaceAppPreview & {
Expand Down
128 changes: 96 additions & 32 deletions ui/marketplace/MarketplaceAppCard.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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) => {
Expand All @@ -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 (
<LinkBox
_hover={{
Expand All @@ -71,12 +94,14 @@ const MarketplaceAppCard = ({
role="group"
>
<Box
display={{ base: 'grid', sm: 'block' }}
display={{ base: 'grid', sm: isExperiment ? 'flex' : 'block' }}
flexDirection={ isExperiment ? 'column' : undefined }
gridTemplateColumns={{ base: '64px 1fr', sm: '1fr' }}
gridTemplateRows={{ base: 'none', sm: 'none' }}
gridRowGap={{ base: 2, sm: 'none' }}
gridColumnGap={{ base: 4, sm: 'none' }}
gridRowGap={{ base: 2, sm: 0 }}
gridColumnGap={{ base: 4, sm: 0 }}
height="100%"
alignContent={ isExperiment ? 'start' : undefined }
>
<Skeleton
isLoaded={ !isLoading }
Expand All @@ -103,7 +128,8 @@ const MarketplaceAppCard = ({
fontSize={{ base: 'sm', sm: 'lg' }}
fontWeight="semibold"
fontFamily="heading"
display="inline-block"
display={ isExperiment ? 'flex' : 'inline-block' }
alignItems={ isExperiment ? 'center' : undefined }
>
<MarketplaceAppCardLink
id={ id }
Expand All @@ -112,6 +138,24 @@ const MarketplaceAppCard = ({
title={ title }
onClick={ handleClick }
/>
{ isExperiment && (
<Tooltip
label={ integrationText }
textAlign="center"
padding={ 2 }
openDelay={ 300 }
maxW={ 400 }
>
<IconSvg
name={ integrationIcon }
marginLeft={ 2 }
boxSize={ 5 }
color={ integrationIconColor }
position="relative"
cursor="pointer"
/>
</Tooltip>
) }
</Skeleton>

<Skeleton
Expand All @@ -127,43 +171,63 @@ const MarketplaceAppCard = ({
isLoaded={ !isLoading }
fontSize={{ base: 'xs', sm: 'sm' }}
lineHeight="20px"
noOfLines={ 4 }
noOfLines={ isExperiment ? 3 : 4 }
>
{ shortDescription }
</Skeleton>

{ !isLoading && (
<Box
position="absolute"
right={{ base: 3, sm: '20px' }}
bottom={{ base: 3, sm: '20px' }}
paddingLeft={ 8 }
bgGradient={ moreButtonBgGradient }
>
<Link
fontSize={{ base: 'xs', sm: 'sm' }}
isExperiment ? (
<Box
display="flex"
alignItems="center"
paddingRight={{ sm: 2 }}
maxW="100%"
overflow="hidden"
href="#"
onClick={ handleInfoClick }
position={{ base: 'absolute', sm: 'relative' }}
bottom={{ base: 3, sm: 0 }}
left={{ base: 3, sm: 0 }}
marginTop={{ base: 0, sm: 'auto' }}
paddingTop={{ base: 0, sm: 4 }}
>
More

<IconSvg
name="arrows/north-east"
marginLeft={ 1 }
boxSize={ 4 }
/>
</Link>
</Box>
<Link
fontSize={{ base: 'xs', sm: 'sm' }}
paddingRight={{ sm: 2 }}
href="#"
onClick={ handleInfoClick }
>
More info
</Link>
</Box>
) : (
<Box
position="absolute"
right={{ base: 3, sm: '20px' }}
bottom={{ base: 3, sm: '20px' }}
paddingLeft={ 8 }
bgGradient={ moreButtonBgGradient }
>
<Link
fontSize={{ base: 'xs', sm: 'sm' }}
display="flex"
alignItems="center"
paddingRight={{ sm: 2 }}
maxW="100%"
overflow="hidden"
href="#"
onClick={ handleInfoClick }
>
More

<IconSvg
name="arrows/north-east"
marginLeft={ 1 }
boxSize={ 4 }
/>
</Link>
</Box>
)
) }

{ !isLoading && (
<IconButton
display={{ base: 'block', sm: isFavorite ? 'block' : 'none' }}
display={{ base: 'block', sm: isFavorite || isExperiment ? 'block' : 'none' }}
_groupHover={{ display: 'block' }}
position="absolute"
right={{ base: 3, sm: '10px' }}
Expand Down
1 change: 1 addition & 0 deletions ui/marketplace/MarketplaceList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ const MarketplaceList = ({ apps, onAppClick, favoriteApps, onFavoriteClick, isLo
onFavoriteClick={ onFavoriteClick }
isLoading={ isLoading }
showDisclaimer={ showDisclaimer }
internalWallet={ app.internalWallet }
/>
)) }
</Grid>
Expand Down

0 comments on commit bb0c499

Please sign in to comment.