Skip to content

Commit 0a35489

Browse files
Fix layout of "this person is in your contacts" tooltip
1 parent dc918ae commit 0a35489

File tree

4 files changed

+46
-96
lines changed

4 files changed

+46
-96
lines changed

stylesheets/_modules.scss

Lines changed: 20 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -2792,38 +2792,6 @@ $timer-icons: '55', '50', '45', '40', '35', '30', '25', '20', '15', '10', '05',
27922792
}
27932793
}
27942794

2795-
span.module-in-contacts-icon__tooltip {
2796-
/* Written in this way to add more specificity and avoid !important */
2797-
.module-tooltip {
2798-
color: $color-white;
2799-
background-color: $ultramarine-ui-light;
2800-
2801-
&[data-placement='top'] {
2802-
.module-tooltip-arrow::after {
2803-
border-top-color: $ultramarine-ui-light;
2804-
}
2805-
}
2806-
2807-
&[data-placement='right'] {
2808-
.module-tooltip-arrow::after {
2809-
border-right-color: $ultramarine-ui-light;
2810-
}
2811-
}
2812-
2813-
&[data-placement='bottom'] {
2814-
.module-tooltip-arrow::after {
2815-
border-bottom-color: $ultramarine-ui-light;
2816-
}
2817-
}
2818-
2819-
&[data-placement='left'] {
2820-
.module-tooltip-arrow::after {
2821-
border-left-color: $ultramarine-ui-light;
2822-
}
2823-
}
2824-
}
2825-
}
2826-
28272795
// Module: Conversation Header
28282796

28292797
.module-conversation-header {
@@ -10434,22 +10402,29 @@ $contact-modal-padding: 18px;
1043410402
}
1043510403

1043610404
.module-tooltip {
10405+
--tooltip-text-color: #{$color-gray-75};
10406+
--tooltip-background-color: #{$color-gray-02};
10407+
10408+
@mixin tooltip-dark-theme-variables {
10409+
--tooltip-text-color: #{$color-gray-05};
10410+
--tooltip-background-color: #{$color-gray-65};
10411+
}
10412+
&--dark-theme {
10413+
@include tooltip-dark-theme-variables;
10414+
}
10415+
@include dark-theme {
10416+
@include tooltip-dark-theme-variables;
10417+
}
10418+
10419+
background-color: var(--tooltip-background-color);
1043710420
border-radius: 8px;
10421+
color: var(--tooltip-text-color);
1043810422
display: inline-block;
1043910423
padding: 8px 21px;
1044010424
position: fixed;
1044110425
text-align: center;
1044210426
z-index: 999;
1044310427

10444-
@include light-theme {
10445-
background-color: $color-gray-02;
10446-
color: $color-gray-75;
10447-
}
10448-
@include dark-theme {
10449-
background-color: $color-gray-65;
10450-
color: $color-gray-05;
10451-
}
10452-
1045310428
.module-tooltip-arrow {
1045410429
position: absolute;
1045510430
}
@@ -10474,13 +10449,7 @@ $contact-modal-padding: 18px;
1047410449

1047510450
.module-tooltip-arrow::after {
1047610451
bottom: -12px;
10477-
10478-
@include light-theme {
10479-
border-top-color: $color-gray-02;
10480-
}
10481-
@include dark-theme {
10482-
border-top-color: $color-gray-65;
10483-
}
10452+
border-top-color: var(--tooltip-background-color);
1048410453
}
1048510454
}
1048610455

@@ -10493,13 +10462,7 @@ $contact-modal-padding: 18px;
1049310462

1049410463
.module-tooltip-arrow::after {
1049510464
left: -6px;
10496-
10497-
@include light-theme {
10498-
border-right-color: $color-gray-02;
10499-
}
10500-
@include dark-theme {
10501-
border-right-color: $color-gray-65;
10502-
}
10465+
border-right-color: var(--tooltip-background-color);
1050310466
}
1050410467
}
1050510468

@@ -10512,13 +10475,7 @@ $contact-modal-padding: 18px;
1051210475

1051310476
.module-tooltip-arrow::after {
1051410477
top: -6px;
10515-
10516-
@include light-theme {
10517-
border-bottom-color: $color-gray-02;
10518-
}
10519-
@include dark-theme {
10520-
border-bottom-color: $color-gray-65;
10521-
}
10478+
border-bottom-color: var(--tooltip-background-color);
1052210479
}
1052310480
}
1052410481

@@ -10531,13 +10488,7 @@ $contact-modal-padding: 18px;
1053110488

1053210489
.module-tooltip-arrow::after {
1053310490
right: -12px;
10534-
10535-
@include light-theme {
10536-
border-left-color: $color-gray-02;
10537-
}
10538-
@include dark-theme {
10539-
border-left-color: $color-gray-65;
10540-
}
10491+
border-left-color: var(--tooltip-background-color);
1054110492
}
1054210493
}
1054310494
}

ts/components/InContactsIcon.tsx

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2020 Signal Messenger, LLC
1+
// Copyright 2020-2021 Signal Messenger, LLC
22
// SPDX-License-Identifier: AGPL-3.0-only
33

44
import React from 'react';
@@ -17,16 +17,14 @@ export const InContactsIcon = (props: PropsType): JSX.Element => {
1717

1818
/* eslint-disable jsx-a11y/no-noninteractive-tabindex */
1919
return (
20-
<span className="module-in-contacts-icon__tooltip">
21-
<Tooltip content={i18n('contactInAddressBook')}>
22-
<span
23-
aria-label={i18n('contactInAddressBook')}
24-
className={classNames('module-in-contacts-icon__icon', className)}
25-
role="img"
26-
tabIndex={0}
27-
/>
28-
</Tooltip>
29-
</span>
20+
<Tooltip content={i18n('contactInAddressBook')}>
21+
<span
22+
aria-label={i18n('contactInAddressBook')}
23+
className={classNames('module-in-contacts-icon__icon', className)}
24+
role="img"
25+
tabIndex={0}
26+
/>
27+
</Tooltip>
3028
);
3129
/* eslint-enable jsx-a11y/no-noninteractive-tabindex */
3230
};

ts/components/Tooltip.tsx

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
// Copyright 2020 Signal Messenger, LLC
1+
// Copyright 2020-2021 Signal Messenger, LLC
22
// SPDX-License-Identifier: AGPL-3.0-only
33

44
import React from 'react';
5+
import classNames from 'classnames';
56
import { noop } from 'lodash';
67
import { Manager, Reference, Popper } from 'react-popper';
78
import { Theme, themeClassName } from '../util/theme';
@@ -97,7 +98,9 @@ export const Tooltip: React.FC<PropsType> = ({
9798

9899
const showTooltip = isHovering || Boolean(sticky);
99100

100-
const tooltipTheme = theme ? themeClassName(theme) : undefined;
101+
const tooltipThemeClassName = theme
102+
? `module-tooltip--${themeClassName(theme)}`
103+
: undefined;
101104

102105
return (
103106
<Manager>
@@ -111,20 +114,18 @@ export const Tooltip: React.FC<PropsType> = ({
111114
<Popper placement={direction}>
112115
{({ arrowProps, placement, ref, style }) =>
113116
showTooltip && (
114-
<div className={tooltipTheme}>
117+
<div
118+
className={classNames('module-tooltip', tooltipThemeClassName)}
119+
ref={ref}
120+
style={style}
121+
data-placement={placement}
122+
>
123+
{content}
115124
<div
116-
className="module-tooltip"
117-
ref={ref}
118-
style={style}
119-
data-placement={placement}
120-
>
121-
{content}
122-
<div
123-
className="module-tooltip-arrow"
124-
ref={arrowProps.ref}
125-
style={arrowProps.style}
126-
/>
127-
</div>
125+
className="module-tooltip-arrow"
126+
ref={arrowProps.ref}
127+
style={arrowProps.style}
128+
/>
128129
</div>
129130
)
130131
}

ts/util/lint/exceptions.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14694,7 +14694,7 @@
1469414694
"rule": "React-useRef",
1469514695
"path": "ts/components/Tooltip.js",
1469614696
"line": " const wrapperRef = react_1.default.useRef(null);",
14697-
"lineNumber": 17,
14697+
"lineNumber": 18,
1469814698
"reasonCategory": "usageTrusted",
1469914699
"updated": "2020-12-04T00:11:08.128Z",
1470014700
"reasonDetail": "Used to add (and remove) event listeners."

0 commit comments

Comments
 (0)