import React from 'react'; import styled, { CSSProperties } from 'styled-components'; import { Flex } from '../../basic/Flex'; import { SessionIconButton } from '../../icon'; export const StyledSubtitleContainer = styled.div` display: flex; flex-direction: column; align-items: center; justify-content: center; margin: 0 auto; min-width: 230px; div:first-child { span:last-child { margin-bottom: 0; } } `; const StyledSubtitleDot = styled.span<{ active: boolean }>` border-radius: 50%; background-color: ${props => props.active ? 'var(--text-primary-color)' : 'var(--text-secondary-color)'}; height: 5px; width: 5px; margin: 0 2px; `; const SubtitleDotMenu = ({ options, selectedOptionIndex, style, }: { options: Array; selectedOptionIndex: number; style: CSSProperties; }) => ( {options.map((option, index) => { if (!option) { return null; } return ( ); })} ); type ConversationHeaderSubitleProps = { subtitles: Array; currentIndex: number; setCurrentIndex: (index: number) => void; onClickFunction: () => void; showDisappearingMessageIcon: boolean; }; export const ConversationHeaderSubitle = (props: ConversationHeaderSubitleProps) => { const { subtitles, currentIndex, setCurrentIndex, onClickFunction, showDisappearingMessageIcon, } = props; const handleTitleCycle = (direction: 1 | -1) => { let newIndex = currentIndex + direction; if (newIndex > subtitles.length - 1) { newIndex = 0; } if (newIndex < 0) { newIndex = subtitles.length - 1; } if (subtitles[newIndex]) { setCurrentIndex(newIndex); } }; return ( { handleTitleCycle(-1); }} isHidden={subtitles.length < 2} tabIndex={0} /> {showDisappearingMessageIcon && ( )} { if (e.key === 'Enter') { e.preventDefault(); onClickFunction(); } }} tabIndex={0} > {subtitles[currentIndex]} { handleTitleCycle(1); }} isHidden={subtitles.length < 2} tabIndex={0} /> ); };