From c74721f1e1b4270ddd17cab1ed51bece969e5d67 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Tue, 2 Aug 2022 20:52:27 -0500 Subject: [PATCH] Ads: display tooltip --- app/soapbox/components/ui/stack/stack.tsx | 5 ++++- app/soapbox/features/ads/components/ad.tsx | 21 ++++++++++++++++++--- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/app/soapbox/components/ui/stack/stack.tsx b/app/soapbox/components/ui/stack/stack.tsx index 9ecb4a104..984bae782 100644 --- a/app/soapbox/components/ui/stack/stack.tsx +++ b/app/soapbox/components/ui/stack/stack.tsx @@ -32,11 +32,13 @@ interface IStack extends React.HTMLAttributes { justifyContent?: 'center', /** Extra class names on the
element. */ className?: string, + /** Whether to let the flexbox grow. */ + grow?: boolean, } /** Vertical stack of child elements. */ const Stack: React.FC = (props) => { - const { space, alignItems, justifyContent, className, ...filteredProps } = props; + const { space, alignItems, justifyContent, className, grow, ...filteredProps } = props; return (
= (props) => { [alignItemsOptions[alignItems]]: typeof alignItems !== 'undefined', // @ts-ignore [justifyContentOptions[justifyContent]]: typeof justifyContent !== 'undefined', + 'flex-grow': grow, }, className)} /> ); diff --git a/app/soapbox/features/ads/components/ad.tsx b/app/soapbox/features/ads/components/ad.tsx index 6fe75efb9..7eb5ac892 100644 --- a/app/soapbox/features/ads/components/ad.tsx +++ b/app/soapbox/features/ads/components/ad.tsx @@ -1,12 +1,17 @@ import React, { useEffect } from 'react'; -import { FormattedMessage } from 'react-intl'; +import { FormattedMessage, defineMessages, useIntl } from 'react-intl'; -import { Stack, HStack, Card, Avatar, Text, Icon } from 'soapbox/components/ui'; +import { Stack, HStack, Card, Tooltip, Avatar, Text, Icon } from 'soapbox/components/ui'; +import IconButton from 'soapbox/components/ui/icon-button/icon-button'; import StatusCard from 'soapbox/features/status/components/card'; import { useAppSelector } from 'soapbox/hooks'; import type { Card as CardEntity } from 'soapbox/types/entities'; +const messages = defineMessages({ + tooltip: { id: 'sponsored.tooltip', defaultMessage: '{siteTitle} displays ads to help fund our service.' }, +}); + interface IAd { /** Embedded ad data in Card format (almost like OEmbed). */ card: CardEntity, @@ -16,6 +21,7 @@ interface IAd { /** Displays an ad in sponsored post format. */ const Ad: React.FC = ({ card, impression }) => { + const intl = useIntl(); const instance = useAppSelector(state => state.instance); // Fetch the impression URL (if any) upon displaying the ad. @@ -32,7 +38,7 @@ const Ad: React.FC = ({ card, impression }) => { - + {instance.title} @@ -52,6 +58,15 @@ const Ad: React.FC = ({ card, impression }) => { + + + + + + {}} horizontal />