UNPKG

stream-chat-react

Version:

React components to create chat conversations or livestream style chat

31 lines (30 loc) 1.78 kB
import React from 'react'; import clsx from 'clsx'; import { useChannelMembershipState } from '../ChannelList'; import { Icon } from './icons'; import { useTranslationContext } from '../../context'; export function ChannelPreviewActionButtons({ channel, }) { const membership = useChannelMembershipState(channel); const { t } = useTranslationContext(); return (React.createElement("div", { className: 'str-chat__channel-preview__action-buttons' }, React.createElement("button", { "aria-label": membership.pinned_at ? t('Unpin') : t('Pin'), className: clsx('str-chat__channel-preview__action-button', 'str-chat__channel-preview__action-button--pin', membership.pinned_at && 'str-chat__channel-preview__action-button--active'), onClick: (e) => { e.stopPropagation(); if (membership.pinned_at) { channel.unpin(); } else { channel.pin(); } }, title: membership.pinned_at ? t('Unpin') : t('Pin') }, React.createElement(Icon.Pin, null)), React.createElement("button", { "aria-label": membership.archived_at ? t('Unarchive') : t('Archive'), className: clsx('str-chat__channel-preview__action-button', 'str-chat__channel-preview__action-button--archive', membership.archived_at && 'str-chat__channel-preview__action-button--active'), onClick: (e) => { e.stopPropagation(); if (membership.archived_at) { channel.unarchive(); } else { channel.archive(); } }, title: membership.archived_at ? t('Unarchive') : t('Archive') }, React.createElement(Icon.ArchiveBox, null)))); }