Something went wrong. Try again.
Bluesky app fork with some witchin' additions 💫 forked from jollywhoppers.com/witchsky.app
Something went wrong. Try again.
3.9 kB · 133 lines
TSX
at main
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134import {useMemo} from 'react'import {View} from 'react-native'import {Image} from 'expo-image'import {LinearGradient} from 'expo-linear-gradient'import {msg} from '@lingui/core/macro'import {useLingui} from '@lingui/react'
import {useCallOnce} from '#/lib/once'import {isBskyCustomFeedUrl} from '#/lib/strings/url-helpers'import {atoms as a, utils} from '#/alf'import {Live_Stroke2_Corner0_Rounded as LiveIcon} from '#/components/icons/Live'import {Link} from '#/components/Link'import {Text} from '#/components/Typography'import {useAnalytics} from '#/analytics'import { type LiveEventFeed, type LiveEventFeedMetricContext,} from '#/features/liveEvents/types'
const roundedStyles = [a.rounded_md, a.curve_continuous]
export function LiveEventFeedCardCompact({ feed, metricContext,}: { feed: LiveEventFeed metricContext: LiveEventFeedMetricContext}) { const {_} = useLingui() const ax = useAnalytics()
const layout = feed.layouts.compact const overlayColor = layout.overlayColor const textColor = layout.textColor const url = useMemo(() => { // Validated in multiple places on the backend if (isBskyCustomFeedUrl(feed.url)) { return new URL(feed.url).pathname } return '/' }, [feed.url])
useCallOnce(() => { ax.metric('liveEvents:feedBanner:seen', { feed: feed.url, context: metricContext, }) })()
return ( <Link to={url} label={_(msg`Live event happening now: ${feed.title}`)} style={[a.w_full]} onPress={() => { ax.metric('liveEvents:feedBanner:click', { feed: feed.url, context: metricContext, }) }}> {({hovered, pressed}) => ( <View style={[roundedStyles, a.shadow_md, a.w_full]}> <View style={[a.w_full, a.align_start, a.overflow_hidden, roundedStyles]}> <Image accessibilityIgnoresInvertColors source={{uri: layout.image}} placeholder={{blurhash: layout.blurhash}} style={[a.absolute, a.inset_0, a.w_full, a.h_full]} contentFit="cover" placeholderContentFit="cover" />
<LinearGradient colors={[overlayColor, utils.alpha(overlayColor, 0)]} locations={[0, 1]} start={{x: 0, y: 0}} end={{x: 1, y: 0}} style={[ a.absolute, a.inset_0, a.transition_opacity, { transitionDuration: '200ms', opacity: hovered || pressed ? 0.6 : 0, }, ]} />
<View style={[a.w_full, a.justify_end]}> <LinearGradient colors={[ overlayColor, utils.alpha(overlayColor, 0.7), utils.alpha(overlayColor, 0), ]} locations={[0, 0.8, 1]} start={{x: 0, y: 0}} end={{x: 1, y: 0}} style={[a.absolute, a.inset_0]} />
<View style={[ a.flex_1, a.flex_row, a.align_center, a.gap_xs, a.z_10, a.px_lg, a.py_md, ]}> <LiveIcon size="md" fill={textColor} /> <Text numberOfLines={1} style={[ a.flex_1, a.leading_snug, a.font_bold, a.text_lg, a.pr_xl, {color: textColor}, ]}> {layout.title} </Text> </View> </View> </View> </View> )} </Link> )}