Skip to content

Commit

Permalink
fix(colors): avoid hard coded colors in GradientIcon (#6424)
Browse files Browse the repository at this point in the history
### Description

As the title - to avoid hard coded "muted" colors here, I am using a
semi transparent mask.

### Test plan

no visual changes

### Related issues

- Related to RET-1293

### Backwards compatibility

Y

### Network scalability

If a new NetworkId and/or Network are added in the future, the changes
in this PR will:

- [ ] Continue to work without code changes, OR trigger a compilation
error (guaranteeing we find it when a new network is added)
  • Loading branch information
kathaypacific authored Jan 20, 2025
1 parent 045998d commit 753750b
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions src/icons/GradientIcon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,15 @@ interface Props {
}

export default function GradientIcon({ radius = 50, borderWidth = 1, children }: Props) {
const gradientBackgroundStyles = [
styles.background,
{
borderRadius: radius,
height: radius - borderWidth * 2,
width: radius - borderWidth * 2,
},
]

return (
<View
style={[
Expand All @@ -31,19 +40,14 @@ export default function GradientIcon({ radius = 50, borderWidth = 1, children }:
/>
)}
<LinearGradient
colors={['#e8fbf2', '#fffaea']}
colors={[Colors.gradientBorderLeft, Colors.gradientBorderRight]}
locations={[0.1085, 1]}
useAngle={true}
angle={90}
style={[
styles.background,
{
borderRadius: radius,
height: radius - borderWidth * 2,
width: radius - borderWidth * 2,
},
]}
style={gradientBackgroundStyles}
/>
{/* Apply a semi-transparent white overlay to tone down the brand gradient. react-native-linear-gradient doesn't support semi-transparent gradients with different colors. */}
<View style={[gradientBackgroundStyles, styles.mask]} />
{children}
</View>
)
Expand All @@ -59,4 +63,8 @@ const styles = StyleSheet.create({
width: '100%',
height: '100%',
},
mask: {
backgroundColor: Colors.background,
opacity: 0.9,
},
})

0 comments on commit 753750b

Please sign in to comment.