Force theming on tooltips for calling

This commit is contained in:
Josh Perez 2020-11-19 18:38:59 -05:00 committed by Josh Perez
parent 6a6f8e28ce
commit 8ff0ca9593
6 changed files with 60 additions and 21 deletions

View file

@ -3,7 +3,7 @@
import React from 'react'; import React from 'react';
import classNames from 'classnames'; import classNames from 'classnames';
import { Tooltip, TooltipPlacement } from './Tooltip'; import { Tooltip, TooltipPlacement, TooltipTheme } from './Tooltip';
import { LocalizerType } from '../types/Util'; import { LocalizerType } from '../types/Util';
export enum CallingButtonType { export enum CallingButtonType {
@ -60,7 +60,11 @@ export const CallingButton = ({
); );
return ( return (
<Tooltip content={tooltipContent} direction={tooltipDirection}> <Tooltip
content={tooltipContent}
direction={tooltipDirection}
theme={TooltipTheme.Dark}
>
<button <button
aria-label={tooltipContent} aria-label={tooltipContent}
type="button" type="button"

View file

@ -3,7 +3,7 @@
import React from 'react'; import React from 'react';
import { LocalizerType } from '../types/Util'; import { LocalizerType } from '../types/Util';
import { Tooltip } from './Tooltip'; import { Tooltip, TooltipTheme } from './Tooltip';
export type PropsType = { export type PropsType = {
canPip?: boolean; canPip?: boolean;
@ -37,6 +37,7 @@ export const CallingHeader = ({
content={i18n('calling__participants', [ content={i18n('calling__participants', [
String(remoteParticipants), String(remoteParticipants),
])} ])}
theme={TooltipTheme.Dark}
> >
<button <button
aria-label={i18n('calling__participants', [ aria-label={i18n('calling__participants', [
@ -50,7 +51,10 @@ export const CallingHeader = ({
</div> </div>
) : null} ) : null}
<div className="module-calling-tools__button"> <div className="module-calling-tools__button">
<Tooltip content={i18n('callingDeviceSelection__settings')}> <Tooltip
content={i18n('callingDeviceSelection__settings')}
theme={TooltipTheme.Dark}
>
<button <button
aria-label={i18n('callingDeviceSelection__settings')} aria-label={i18n('callingDeviceSelection__settings')}
className="module-calling-button__settings" className="module-calling-button__settings"
@ -61,7 +65,7 @@ export const CallingHeader = ({
</div> </div>
{canPip && ( {canPip && (
<div className="module-calling-tools__button"> <div className="module-calling-tools__button">
<Tooltip content={i18n('calling__pip--on')}> <Tooltip content={i18n('calling__pip--on')} theme={TooltipTheme.Dark}>
<button <button
aria-label={i18n('calling__pip--on')} aria-label={i18n('calling__pip--on')}
className="module-calling-button__pip" className="module-calling-button__pip"

View file

@ -2,7 +2,7 @@
// SPDX-License-Identifier: AGPL-3.0-only // SPDX-License-Identifier: AGPL-3.0-only
import React from 'react'; import React from 'react';
import { Tooltip } from './Tooltip'; import { Tooltip, TooltipTheme } from './Tooltip';
import { CallingPipRemoteVideo } from './CallingPipRemoteVideo'; import { CallingPipRemoteVideo } from './CallingPipRemoteVideo';
import { LocalizerType } from '../types/Util'; import { LocalizerType } from '../types/Util';
import { VideoFrameSource } from '../types/Calling'; import { VideoFrameSource } from '../types/Calling';
@ -184,7 +184,7 @@ export const CallingPip = ({
}} }}
type="button" type="button"
/> />
<Tooltip content={i18n('calling__pip--off')}> <Tooltip content={i18n('calling__pip--off')} theme={TooltipTheme.Dark}>
<button <button
aria-label={i18n('calling__pip--off')} aria-label={i18n('calling__pip--off')}
className="module-calling-pip__button--pip" className="module-calling-pip__button--pip"

View file

@ -3,7 +3,7 @@
import React from 'react'; import React from 'react';
import { Avatar } from './Avatar'; import { Avatar } from './Avatar';
import { Tooltip } from './Tooltip'; import { Tooltip, TooltipTheme } from './Tooltip';
import { ContactName } from './conversation/ContactName'; import { ContactName } from './conversation/ContactName';
import { LocalizerType } from '../types/Util'; import { LocalizerType } from '../types/Util';
import { ColorType } from '../types/Colors'; import { ColorType } from '../types/Colors';
@ -41,7 +41,7 @@ const CallButton = ({
tooltipContent, tooltipContent,
}: CallButtonProps): JSX.Element => { }: CallButtonProps): JSX.Element => {
return ( return (
<Tooltip content={tooltipContent}> <Tooltip content={tooltipContent} theme={TooltipTheme.Dark}>
<button <button
className={`module-incoming-call__button module-incoming-call__button--${classSuffix}`} className={`module-incoming-call__button module-incoming-call__button--${classSuffix}`}
onClick={onClick} onClick={onClick}

View file

@ -5,12 +5,13 @@ import * as React from 'react';
import { storiesOf } from '@storybook/react'; import { storiesOf } from '@storybook/react';
import { select } from '@storybook/addon-knobs'; import { select } from '@storybook/addon-knobs';
import { Tooltip, TooltipPlacement, PropsType } from './Tooltip'; import { Tooltip, TooltipPlacement, TooltipTheme, PropsType } from './Tooltip';
const createProps = (overrideProps: Partial<PropsType> = {}): PropsType => ({ const createProps = (overrideProps: Partial<PropsType> = {}): PropsType => ({
content: overrideProps.content || 'Hello World', content: overrideProps.content || 'Hello World',
direction: select('direction', TooltipPlacement, overrideProps.direction), direction: select('direction', TooltipPlacement, overrideProps.direction),
sticky: overrideProps.sticky, sticky: overrideProps.sticky,
theme: overrideProps.theme,
}); });
const story = storiesOf('Components/Tooltip', module); const story = storiesOf('Components/Tooltip', module);
@ -78,3 +79,14 @@ story.add('Sticky', () => (
{Trigger} {Trigger}
</Tooltip> </Tooltip>
)); ));
story.add('Dark Theme', () => (
<Tooltip
{...createProps({
sticky: true,
theme: TooltipTheme.Dark,
})}
>
{Trigger}
</Tooltip>
));

View file

@ -11,10 +11,17 @@ export enum TooltipPlacement {
Left = 'left', Left = 'left',
} }
export enum TooltipTheme {
System = 'system',
Light = 'light',
Dark = 'dark',
}
export type PropsType = { export type PropsType = {
content: string | JSX.Element; content: string | JSX.Element;
direction?: TooltipPlacement; direction?: TooltipPlacement;
sticky?: boolean; sticky?: boolean;
theme?: TooltipTheme;
}; };
export const Tooltip: React.FC<PropsType> = ({ export const Tooltip: React.FC<PropsType> = ({
@ -22,10 +29,20 @@ export const Tooltip: React.FC<PropsType> = ({
content, content,
direction, direction,
sticky, sticky,
theme = TooltipTheme.System,
}) => { }) => {
const isSticky = Boolean(sticky); const isSticky = Boolean(sticky);
const [showTooltip, setShowTooltip] = React.useState(isSticky); const [showTooltip, setShowTooltip] = React.useState(isSticky);
let tooltipTheme: string;
if (theme === TooltipTheme.Light) {
tooltipTheme = 'light-theme';
} else if (theme === TooltipTheme.Dark) {
tooltipTheme = 'dark-theme';
} else {
tooltipTheme = '';
}
return ( return (
<Manager> <Manager>
<Reference> <Reference>
@ -60,18 +77,20 @@ export const Tooltip: React.FC<PropsType> = ({
<Popper placement={direction}> <Popper placement={direction}>
{({ arrowProps, placement, ref, style }) => {({ arrowProps, placement, ref, style }) =>
showTooltip && ( showTooltip && (
<div <div className={tooltipTheme}>
className="module-tooltip"
ref={ref}
style={style}
data-placement={placement}
>
{content}
<div <div
className="module-tooltip-arrow" className="module-tooltip"
ref={arrowProps.ref} ref={ref}
style={arrowProps.style} style={style}
/> data-placement={placement}
>
{content}
<div
className="module-tooltip-arrow"
ref={arrowProps.ref}
style={arrowProps.style}
/>
</div>
</div> </div>
) )
} }