reanimated-color-picker
Version:
A Pure JavaScript Color Picker for React Native
53 lines (52 loc) • 1.35 kB
JavaScript
import React from 'react';
import Animated, { useAnimatedStyle } from 'react-native-reanimated';
import { styles } from '../../../styles';
import { enableAndroidHardwareTextures, isRtl } from '../../../utils';
export default function TriangleUp({
width,
height,
thumbColor,
adaptiveColor,
thumbAnimatedStyle,
innerStyle,
style,
vertical,
}) {
const computedStyle = {
width,
height,
...(vertical
? {
justifyContent: 'center',
alignItems: isRtl ? 'flex-end' : 'flex-start',
}
: {
justifyContent: 'flex-end',
}),
};
const triangleStyle = {
borderBottomWidth: width / 2,
borderLeftWidth: width / 4,
borderRightWidth: width / 4,
transform: [
{
rotate: vertical ? '90deg' : '0deg',
},
],
};
const adaptiveColorStyle = useAnimatedStyle(() => {
return {
borderBottomColor: thumbColor ?? adaptiveColor.value,
};
}, [thumbColor, adaptiveColor]);
return /*#__PURE__*/ React.createElement(
Animated.View,
{
style: [styles.handle, style, computedStyle, thumbAnimatedStyle],
renderToHardwareTextureAndroid: enableAndroidHardwareTextures,
},
/*#__PURE__*/ React.createElement(Animated.View, {
style: [styles.triangle, triangleStyle, adaptiveColorStyle, innerStyle],
}),
);
}