UNPKG

react-native-linear-gradient-text

Version:
44 lines 1.41 kB
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } import React from 'react'; import { Text, StyleSheet } from 'react-native'; import MaskedView from '@react-native-masked-view/masked-view'; import LinearGradient from 'react-native-linear-gradient'; export const LinearGradientText = props => { const { text, textStyle = {}, textProps = {}, colors, start = { x: 0, y: 1 }, end = { x: 1, y: 1 } } = props; return /*#__PURE__*/React.createElement(MaskedView, { maskElement: /*#__PURE__*/React.createElement(Text, { style: [styles.maskText, textStyle], testID: "mask-text" }, text) }, /*#__PURE__*/React.createElement(LinearGradient, { colors: colors, start: start, end: end, testID: "gradient-element" }, /*#__PURE__*/React.createElement(Text, _extends({ style: [styles.text, textStyle], testID: "gradient-text" }, textProps), text))); }; const styles = StyleSheet.create({ maskText: { backgroundColor: 'transparent' }, text: { opacity: 0 } }); //# sourceMappingURL=LinearGradientText.js.map