Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add tooltip to mentions #30445

Merged
merged 3 commits into from
Sep 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions apps/meteor/packages/rocketchat-i18n/i18n/en.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -3320,6 +3320,11 @@
"Members_List": "Members List",
"mention-all": "Mention All",
"mention-all_description": "Permission to use the @all mention",
"Mentions_all_room_members": "Mentions all room members",
"Mentions_online_room_members": "Mentions online room members",
"Mentions_user": "Mentions user",
"Mentions_channel": "Mentions channel",
"Mentions_you": "Mentions you",
"mention-here": "Mention Here",
"mention-here_description": "Permission to use the @here mention",
"Mentions": "Mentions",
Expand Down Expand Up @@ -5933,6 +5938,7 @@
"Theme_match_system_description": "Automatically match the appearance of your system.",
"Theme_high_contrast": "High contrast",
"Theme_high_contrast_description": "Maximum tonal differentiation with bold colors and sharp contrasts provide enhanced accessibility.",
"Highlighted_chosen_word": "Highlighted chosen word",
"High_contrast_upsell_title": "Enable high contrast theme",
"High_contrast_upsell_subtitle": "Enhance your team’s reading experience",
"High_contrast_upsell_description": "Especially designed for individuals with visual impairments or conditions such as color vision deficiency, low vision, or sensitivity to low contrast.\n\nThis theme increases contrast between text and background elements, making content more distinguishable and easier to read.",
Expand Down
6 changes: 4 additions & 2 deletions packages/gazzodown/src/elements/PlainSpan.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { useTranslation } from '@rocket.chat/ui-contexts';
import { Fragment, memo, ReactElement, useContext, useMemo } from 'react';

import { MarkupInteractionContext } from '../MarkupInteractionContext';
Expand All @@ -7,6 +8,7 @@ type PlainSpanProps = {
};

const PlainSpan = ({ text }: PlainSpanProps): ReactElement => {
const t = useTranslation();
const { highlightRegex, markRegex } = useContext(MarkupInteractionContext);

const content = useMemo(() => {
Expand All @@ -20,7 +22,7 @@ const PlainSpan = ({ text }: PlainSpanProps): ReactElement => {
{chunks.map((chunk, i) => {
if (i % 2 === 0) {
return (
<mark key={i} className='highlight-text'>
<mark title={t('Highlighted_chosen_word')} key={i} className='highlight-text'>
{chunk}
</mark>
);
Expand Down Expand Up @@ -51,7 +53,7 @@ const PlainSpan = ({ text }: PlainSpanProps): ReactElement => {
}

return text;
}, [text, highlightRegex, markRegex]);
}, [highlightRegex, markRegex, text, t]);

return <>{content}</>;
};
Expand Down
4 changes: 3 additions & 1 deletion packages/gazzodown/src/mentions/ChannelMentionElement.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Message } from '@rocket.chat/fuselage';
import { useTranslation } from '@rocket.chat/ui-contexts';
import { memo, ReactElement, useContext, useMemo } from 'react';

import { MarkupInteractionContext } from '../MarkupInteractionContext';
Expand All @@ -10,6 +11,7 @@ type ChannelMentionElementProps = {
const handleChannelMention = (mention: string, withSymbol: boolean | undefined): string => (withSymbol ? `#${mention}` : mention);

const ChannelMentionElement = ({ mention }: ChannelMentionElementProps): ReactElement => {
const t = useTranslation();
const { resolveChannelMention, onChannelMentionClick, showMentionSymbol } = useContext(MarkupInteractionContext);

const resolved = useMemo(() => resolveChannelMention?.(mention), [mention, resolveChannelMention]);
Expand All @@ -20,7 +22,7 @@ const ChannelMentionElement = ({ mention }: ChannelMentionElementProps): ReactEl
}

return (
<Message.Highlight variant='link' clickable onClick={handleClick}>
<Message.Highlight title={t('Mentions_channel')} variant='link' clickable onClick={handleClick}>
{handleChannelMention(resolved.name ?? mention, showMentionSymbol)}
</Message.Highlight>
);
Expand Down
16 changes: 13 additions & 3 deletions packages/gazzodown/src/mentions/UserMentionElement.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Message } from '@rocket.chat/fuselage';
import { useTranslation } from '@rocket.chat/ui-contexts';
import { memo, ReactElement, useContext, useMemo } from 'react';

import { MarkupInteractionContext } from '../MarkupInteractionContext';
Expand All @@ -11,6 +12,7 @@ const handleUserMention = (mention: string | undefined, withSymbol: boolean | un
withSymbol ? `@${mention}` : mention;

const UserMentionElement = ({ mention }: UserMentionElementProps): ReactElement => {
const t = useTranslation();
const { resolveUserMention, onUserMentionClick, isMobile, ownUserId, useRealName, showMentionSymbol } =
useContext(MarkupInteractionContext);

Expand All @@ -20,11 +22,19 @@ const UserMentionElement = ({ mention }: UserMentionElementProps): ReactElement
const showRealName = useRealName && !isMobile;

if (mention === 'all') {
return <Message.Highlight variant='relevant'>{handleUserMention('all', showMentionSymbol)}</Message.Highlight>;
return (
<Message.Highlight title={t('Mentions_all_room_members')} variant='relevant'>
{handleUserMention('all', showMentionSymbol)}
</Message.Highlight>
);
}

if (mention === 'here') {
return <Message.Highlight variant='relevant'>{handleUserMention('here', showMentionSymbol)}</Message.Highlight>;
return (
<Message.Highlight title={t('Mentions_online_room_members')} variant='relevant'>
{handleUserMention('here', showMentionSymbol)}
</Message.Highlight>
);
}

if (!resolved) {
Expand All @@ -34,7 +44,7 @@ const UserMentionElement = ({ mention }: UserMentionElementProps): ReactElement
return (
<Message.Highlight
variant={resolved._id === ownUserId ? 'critical' : 'other'}
title={resolved.username || resolved.name}
title={resolved._id === ownUserId ? t('Mentions_you') : t('Mentions_user')}
clickable
onClick={handleClick}
data-uid={resolved._id}
Expand Down
3 changes: 2 additions & 1 deletion packages/password-policies/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"extends": "../../tsconfig.base.client.json",
"compilerOptions": {
"rootDir": "./src",
"outDir": "./dist"
"outDir": "./dist",
"module": "commonjs"
},
"include": ["./src/**/*"]
}