Skip to content

Commit b36d175

Browse files
committed
Update ContributionChart component
1 parent 66718e5 commit b36d175

File tree

1 file changed

+18
-20
lines changed

1 file changed

+18
-20
lines changed

src/components/ContributionChart.tsx

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,23 @@ export const ContributionChart: FC<ContributionChartProps> = ({
166166
const dataIndex = weekIndex * 7 + dayIndex;
167167
const isValidData = day && day.value !== undefined;
168168

169+
// Create cell style
170+
const cellStyle = {
171+
...styles.cell,
172+
width: cellSize,
173+
height: cellSize,
174+
margin: cellSpacing / 2,
175+
borderRadius: cellBorderRadius,
176+
backgroundColor: isValidData
177+
? getColorForValue(day.value)
178+
: 'transparent',
179+
};
180+
181+
// Create animation style
182+
const animationStyle = {
183+
opacity: isValidData ? animatedValues[dataIndex] : 0,
184+
};
185+
169186
return (
170187
<TouchableOpacity
171188
key={dayIndex}
@@ -182,26 +199,7 @@ export const ContributionChart: FC<ContributionChartProps> = ({
182199
}
183200
}}
184201
>
185-
<Animated.View
186-
style={[
187-
styles.cell,
188-
{
189-
width: cellSize,
190-
height: cellSize,
191-
margin: cellSpacing / 2,
192-
borderRadius: cellBorderRadius,
193-
backgroundColor: isValidData
194-
? getColorForValue(day.value)
195-
: 'transparent',
196-
opacity: isValidData
197-
? animatedValues[dataIndex]?.interpolate({
198-
inputRange: [0, 1],
199-
outputRange: [0, 1],
200-
})
201-
: 0,
202-
},
203-
]}
204-
/>
202+
<Animated.View style={[cellStyle, animationStyle]} />
205203
</TouchableOpacity>
206204
);
207205
})}

0 commit comments

Comments
 (0)