import React, { memo } from '../../../lib/teact/teact'; import buildClassName from '../../../util/buildClassName'; import { hexToRgb, lerpRgb } from '../../../util/switchTheme'; import renderText from '../../common/helpers/renderText'; import useLastCallback from '../../../hooks/useLastCallback'; import ListItem from '../../ui/ListItem'; import styles from './PremiumFeatureItem.module.scss'; type OwnProps = { icon: string; isFontIcon?: boolean; title: string; text: string; index: number; count: number; section: T; onClick?: (section: T) => void; }; const COLORS = [ '#F2862D', '#EB7B4D', '#E46D72', '#DD6091', '#CC5FBA', '#B464E7', '#9873FF', '#768DFF', '#55A5FC', '#52B0C9', '#4FBC93', '#4CC663', ].map(hexToRgb); // eslint-disable-next-line @typescript-eslint/comma-dangle const PremiumFeatureItem = ({ icon, isFontIcon, title, text, index, count, section, onClick, }: OwnProps) => { const newIndex = (index / count) * COLORS.length; const colorA = COLORS[Math.floor(newIndex)]; const colorB = COLORS[Math.ceil(newIndex)] ?? colorA; const { r, g, b } = lerpRgb(colorA, colorB, 0.5); const handleClick = useLastCallback(() => { onClick?.(section); }); return ( {isFontIcon ? ( ) : ( )}
{renderText(title, ['br'])}
{text}
); }; export default memo(PremiumFeatureItem);