From c3dfe6f93dd3c40adabebccc6c9e6da1d82976a3 Mon Sep 17 00:00:00 2001 From: Rishi Balakrishnan Date: Wed, 26 Aug 2026 21:50:19 -0400 Subject: [PATCH] feat(home): add tile sheen, gloss, and press response --- src/view/com/home/TileBoard/Sheen.tsx | 171 ++++++++++++++++++++++++++ src/view/com/home/TileBoard/index.tsx | 39 +++++- 2 files changed, 204 insertions(+), 6 deletions(-) create mode 100644 src/view/com/home/TileBoard/Sheen.tsx diff --git a/src/view/com/home/TileBoard/Sheen.tsx b/src/view/com/home/TileBoard/Sheen.tsx new file mode 100644 index 000000000..f5becb4ff --- /dev/null +++ b/src/view/com/home/TileBoard/Sheen.tsx @@ -0,0 +1,171 @@ +import {useEffect} from 'react' +import {type DimensionValue, View} from 'react-native' +import Animated, { + Easing, + useAnimatedStyle, + useSharedValue, + withDelay, + withRepeat, + withSequence, + withTiming, +} from 'react-native-reanimated' +import {LinearGradient} from 'expo-linear-gradient' + +import {atoms as a} from '#/alf' + +const SWEEP_WIDTH = 120 + +/** + * A light band that travels across the tile once on mount, staggered by + * position so the board catches the light tile by tile. + */ +export function Sheen({ + index, + width, + isDark, +}: { + index: number + width: number + isDark: boolean +}) { + const x = useSharedValue(-SWEEP_WIDTH) + + useEffect(() => { + x.set(-SWEEP_WIDTH) + x.set( + withDelay( + 200 + index * 110, + withTiming(width + SWEEP_WIDTH, { + duration: 900, + easing: Easing.inOut(Easing.cubic), + }), + ), + ) + }, [index, width, x]) + + const style = useAnimatedStyle(() => ({ + transform: [{translateX: x.get()}, {rotateZ: '18deg'}], + })) + + return ( + + + + + + ) +} + +/** + * Static specular highlight — a soft bloom in the top-left corner so the tile + * reads as a lit surface rather than a flat fill. + */ +export function Gloss({isDark}: {isDark: boolean}) { + return ( + + ) +} + +const TWINKLES: { + top: DimensionValue + left: DimensionValue + size: number + delay: number +}[] = [ + {top: '14%', left: '68%', size: 3, delay: 0}, + {top: '32%', left: '88%', size: 2, delay: 900}, + {top: '9%', left: '82%', size: 2.5, delay: 1800}, +] + +/** Slow, low-opacity glints. Hero tile only — everywhere would be noise. */ +export function Twinkles({isDark}: {isDark: boolean}) { + return ( + + {TWINKLES.map((tw, i) => ( + + ))} + + ) +} + +function Twinkle({ + top, + left, + size, + delay, + isDark, +}: { + top: DimensionValue + left: DimensionValue + size: number + delay: number + isDark: boolean +}) { + const v = useSharedValue(0) + + useEffect(() => { + v.set( + withDelay( + delay, + withRepeat( + withSequence( + withTiming(1, {duration: 700, easing: Easing.out(Easing.quad)}), + withTiming(0, {duration: 900, easing: Easing.in(Easing.quad)}), + withTiming(0, {duration: 1600}), + ), + -1, + false, + ), + ), + ) + }, [delay, v]) + + const style = useAnimatedStyle(() => ({ + opacity: v.get() * (isDark ? 0.7 : 0.9), + transform: [{scale: 0.6 + v.get() * 0.6}], + })) + + return ( + + ) +} diff --git a/src/view/com/home/TileBoard/index.tsx b/src/view/com/home/TileBoard/index.tsx index 3d882d122..853072fc9 100644 --- a/src/view/com/home/TileBoard/index.tsx +++ b/src/view/com/home/TileBoard/index.tsx @@ -10,6 +10,8 @@ import Animated, { useAnimatedRef, useAnimatedStyle, useScrollViewOffset, + useSharedValue, + withSpring, } from 'react-native-reanimated' import {Image} from 'expo-image' import {LinearGradient} from 'expo-linear-gradient' @@ -28,8 +30,11 @@ import {SortableGrid} from '#/components/SortableGrid' import {Text} from '#/components/Typography' import {IS_WEB} from '#/env' import {deriveTileSpan, layoutHeight, packLayout} from './layout' +import {Gloss, Sheen, Twinkles} from './Sheen' import {type TileTint, tintForFeed} from './tint' +const AnimatedPressable = Animated.createAnimatedComponent(Pressable) + const TILE_GAP = 8 const TILE_HEIGHT = 160 const TILE_RADIUS = 28 @@ -182,6 +187,10 @@ export function TileBoard({ renderItem={(feed, index) => ( ({ + transform: [{scale: 1 - press.get() * 0.035}], + })) return ( - { + press.set(withSpring(1, {mass: 0.4, damping: 14})) + }} + onPressOut={() => { + press.set(withSpring(0, {mass: 0.4, damping: 14})) + }} accessibilityRole="button" accessibilityLabel={feed.displayName} accessibilityHint={ @@ -282,6 +306,7 @@ function Tile({ shadowRadius: 14, elevation: 4, }, + pressStyle, ]}> + + {isHero && } + {feed.avatar && ( @@ -342,7 +369,7 @@ function Tile({ – )} - + ) } -- knotmirror 0.0.1