-
Notifications
You must be signed in to change notification settings - Fork 414
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Refactor filePrice * Refactor Wallet Tip Components * Add backend sticker support for comments * Add stickers * Refactor commentCreate * Add Sticker Selector and sticker comment creation * Add stickers display to comments and hyperchats * Fix wrong checks for total Super Chats
- Loading branch information
1 parent
a77e59c
commit 5f1f702
Showing
26 changed files
with
1,404 additions
and
1,357 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
// @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 getListRow = (rowTitle: string, rowStickers: any) => ( | ||
<div className="stickerSelector__listBody-row"> | ||
<div id={rowTitle} className="stickerSelector__listBody-rowTitle"> | ||
{rowTitle} | ||
</div> | ||
<div className="stickerSelector__listBody-rowItems"> | ||
{rowStickers.map((sticker) => ( | ||
<Button | ||
key={sticker.name} | ||
title={sticker.name} | ||
button="alt" | ||
className="button--file-action" | ||
onClick={() => onSelect(sticker)} | ||
> | ||
<OptimizedImage src={sticker.url} waitLoad /> | ||
{sticker.price && sticker.price > 0 && ( | ||
<CreditAmount superChatLight amount={sticker.price} size={2} isFiat /> | ||
)} | ||
</Button> | ||
))} | ||
</div> | ||
</div> | ||
); | ||
|
||
return ( | ||
<div className="stickerSelector"> | ||
<div className="stickerSelector__header card__header--between"> | ||
<div className="stickerSelector__headerTitle card__title-section--small">{__('Stickers')}</div> | ||
</div> | ||
|
||
<div className="stickerSelector__list"> | ||
<div className="stickerSelector__listBody"> | ||
{getListRow(__('Free'), FREE_GLOBAL_STICKERS)} | ||
{!claimIsMine && getListRow(__('Tips'), PAID_GLOBAL_STICKERS)} | ||
</div> | ||
|
||
<div className="navigation__wrapper"> | ||
<ul className="navigation-links"> | ||
{STICKER_SIDE_LINKS.map( | ||
(linkProps) => | ||
((claimIsMine && linkProps.section !== 'Tips') || !claimIsMine) && ( | ||
<li key={linkProps.section}> | ||
<Button | ||
label={__(linkProps.section)} | ||
title={__(linkProps.section)} | ||
icon={linkProps.icon} | ||
iconSize={1} | ||
className="navigation-link" | ||
onClick={() => scrollToStickerSection(linkProps.section)} | ||
/> | ||
</li> | ||
) | ||
)} | ||
</ul> | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
} |
Oops, something went wrong.