Skip to content

Commit 08a7c31

Browse files
authored
chore: Use boxShadow for the glow in the Planets example and complete the code snippet (#9864)
## Summary The Planets example built its `:active` glow from iOS-only `shadowOpacity`/`shadowRadius` plus `elevation`, which renders as a barely visible gray shadow on Android. The glow is now a single cross-platform `boxShadow` transition (`` `0 0 0 0 ${color}00` `` -> `` `0 0 18px 4px ${color}` ``), and the code snippet shows all animated props (`:hover` name reveal, `:active` scale and glow) instead of only the `:hover` opacity. ## Example recording pressing a planet shows the planet-colored glow and 1.1x scale; releasing fades the glow and keeps the name revealed (sticky touch hover). https://github.com/user-attachments/assets/310c71ba-29f0-4f28-8394-1b17d4af2ad4
1 parent da17437 commit 08a7c31

1 file changed

Lines changed: 30 additions & 11 deletions

File tree

  • apps/common-app/src/apps/css/examples/transitions/screens/pseudoSelectors

apps/common-app/src/apps/css/examples/transitions/screens/pseudoSelectors/Planets.tsx

Lines changed: 30 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -51,19 +51,39 @@ export default function Planets() {
5151
description="Three differently sized planets orbit the screen center on a tilted (elliptical) path. Each planet's name is hidden until you hover; active enlarges it with a colored glow."
5252
title="Planets">
5353
<VerticalExampleCard
54-
title="Hover a planet to reveal its name"
54+
title="Hover a planet to reveal its name, press it for a glow"
5555
code={`<Animated.View
5656
style={{
57-
// 0.02 not 0: iOS skips alpha<0.01 views in hit-testing
58-
opacity: { default: 0.02, ':hover': 1 },
57+
transform: {
58+
default: [{ scale: 1 }],
59+
':active': [{ scale: 1.1 }],
60+
},
61+
boxShadow: {
62+
default: \`0 0 0 0 \${color}00\`,
63+
':active': \`0 0 18px 4px \${color}\`,
64+
},
5965
transitionDuration: '200ms',
60-
}}
61-
onStartShouldSetResponder={() => true}>
62-
<Text>{name}</Text>
66+
}}>
67+
<Animated.View
68+
style={{
69+
opacity: { default: 0.02, ':hover': 1 },
70+
transitionDuration: '200ms',
71+
}}
72+
onStartShouldSetResponder={() => true}>
73+
<Text>{name}</Text>
74+
</Animated.View>
6375
</Animated.View>`}
6476
collapsedCode={`opacity: {
6577
default: 0.02,
6678
':hover': 1,
79+
},
80+
transform: {
81+
default: [{ scale: 1 }],
82+
':active': [{ scale: 1.1 }],
83+
},
84+
boxShadow: {
85+
default: \`0 0 0 0 \${color}00\`,
86+
':active': \`0 0 18px 4px \${color}\`,
6787
},`}>
6888
<Animated.View style={styles.stage}>
6989
<Animated.View style={styles.orbitPlane}>
@@ -81,11 +101,11 @@ export default function Planets() {
81101
{
82102
backgroundColor: planet.color,
83103
borderRadius: planet.size / 2,
84-
elevation: { ':active': 12, default: 0 },
104+
boxShadow: {
105+
':active': `0 0 18px 4px ${planet.color}`,
106+
default: `0 0 0 0 ${planet.color}00`,
107+
},
85108
height: planet.size,
86-
shadowColor: planet.color,
87-
shadowOpacity: { ':active': 0.9, default: 0 },
88-
shadowRadius: { ':active': 18, default: 0 },
89109
transform: {
90110
':active': [{ scale: 1.1 }],
91111
default: [{ scale: 1 }],
@@ -137,7 +157,6 @@ const styles = StyleSheet.create({
137157
},
138158
orbiter: {
139159
position: 'absolute',
140-
shadowOffset: { height: 0, width: 0 },
141160
},
142161
orbitPlane: {
143162
height: PLANE_HEIGHT,

0 commit comments

Comments
 (0)