// @flow import 'scss/component/_sticker-selector.scss'; import { FREE_GLOBAL_STICKERS, PAID_GLOBAL_STICKERS } from 'constants/stickers'; import * as ICONS from 'constants/icons'; import Button from 'component/button'; import CreditAmount from 'component/common/credit-amount'; import OptimizedImage from 'component/optimizedImage'; import React from 'react'; const buildStickerSideLink = (section: string, icon: string) => ({ section, icon }); const STICKER_SIDE_LINKS = [ buildStickerSideLink(__('Free'), ICONS.TAG), buildStickerSideLink(__('Tips'), ICONS.FINANCE), // Future work may include Channel, Subscriptions, ... ]; type Props = { claimIsMine: boolean, onSelect: (any) => void }; export default function StickerSelector(props: Props) { const { claimIsMine, onSelect } = props; function scrollToStickerSection(section: string) { const listBodyEl = document.querySelector('.stickerSelector__listBody'); const sectionToScroll = document.getElementById(section); if (listBodyEl && sectionToScroll) { // $FlowFixMe listBodyEl.scrollTo({ top: sectionToScroll.offsetTop - sectionToScroll.getBoundingClientRect().height * 2, behavior: 'smooth', }); } } const StickerWrapper = (stickerProps: any) => { const { price, children } = stickerProps; return price ?
{children}
: children; }; const getListRow = (rowTitle: string, rowStickers: any) => (
{rowTitle}
{rowStickers.map((sticker) => ( ))}
); return (
{__('Stickers')}
{getListRow(__('Free'), FREE_GLOBAL_STICKERS)} {!claimIsMine && getListRow(__('Tips'), PAID_GLOBAL_STICKERS)}
    {STICKER_SIDE_LINKS.map( (linkProps) => ((claimIsMine && linkProps.section !== 'Tips') || !claimIsMine) && (
  • ) )}
); }