fix: change `topicIds` to `topicTitles` (#5588)
* fix: change `topicIds` to `topicTitles` * fix: comma and gapfix/activity-gap
parent
71d84faf73
commit
cd35c77df1
6 changed files with 102 additions and 161 deletions
@ -0,0 +1,41 @@ |
||||
type ActivityTopicTitlesProps = { |
||||
topicTitles: string[]; |
||||
onSelectActivity?: () => void; |
||||
}; |
||||
|
||||
export function ActivityTopicTitles(props: ActivityTopicTitlesProps) { |
||||
const { topicTitles, onSelectActivity } = props; |
||||
const firstThreeTopics = topicTitles?.slice(0, 3); |
||||
const remainingTopics = topicTitles?.slice(3); |
||||
|
||||
return ( |
||||
<> |
||||
{firstThreeTopics.map((topicTitle, index) => { |
||||
return ( |
||||
<span className="font-medium"> |
||||
<> |
||||
{index > 0 && ', '} |
||||
{index === firstThreeTopics.length - 1 && |
||||
firstThreeTopics.length > 1 && |
||||
'and '} |
||||
{topicTitle} |
||||
</> |
||||
</span> |
||||
); |
||||
})} |
||||
|
||||
{remainingTopics?.length > 0 && ( |
||||
<> |
||||
and |
||||
<button |
||||
className="font-medium underline underline-offset-2 hover:text-black" |
||||
onClick={onSelectActivity} |
||||
> |
||||
{remainingTopics.length} more topic |
||||
{remainingTopics.length > 1 ? 's' : ''} |
||||
</button> |
||||
</> |
||||
)} |
||||
</> |
||||
); |
||||
} |
Loading…
Reference in new issue