mirror of
https://gitcode.com/GitHub_Trending/ji/jitsi-meet.git
synced 2025-12-30 11:22:31 +00:00
Create Tooltip component Fix Popover positioning calculations Add margins to popover Remove @atlaskit/tooltip Update all components to use the new Tooltip component Added tooltip actions and reducers for the following functionality: when a user hovers over an element is sees the tooltip for that element and then hovers another element that has a tooltip, instead of using the delay and animations we just unmount the current tooltip and mount the next one immediately
51 lines
1.4 KiB
TypeScript
51 lines
1.4 KiB
TypeScript
import ReducerRegistry from '../redux/ReducerRegistry';
|
|
|
|
import { HIDE_TOOLTIP, SHOW_TOOLTIP } from './actionTypes';
|
|
|
|
export interface ITooltipState {
|
|
content: string;
|
|
previousContent: string;
|
|
visible: boolean;
|
|
}
|
|
|
|
const DEFAULT_STATE = {
|
|
content: '',
|
|
previousContent: '',
|
|
visible: false
|
|
};
|
|
|
|
/**
|
|
* Reduces redux actions which mark the tooltip as displayed or hidden.
|
|
*
|
|
* @param {IDialogState} state - The current redux state.
|
|
* @param {Action} action - The redux action to reduce.
|
|
* @param {string} action.type - The type of the redux action to reduce..
|
|
* @returns {State} The next redux state that is the result of reducing the
|
|
* specified action.
|
|
*/
|
|
ReducerRegistry.register<ITooltipState>('features/base/tooltip', (state = DEFAULT_STATE, action): ITooltipState => {
|
|
switch (action.type) {
|
|
case SHOW_TOOLTIP:
|
|
return {
|
|
content: action.content,
|
|
previousContent: state.content,
|
|
visible: true
|
|
};
|
|
case HIDE_TOOLTIP: {
|
|
// The tooltip can be marked as hidden only if the hide action
|
|
// is dispatched by the tooltip that is displayed.
|
|
if (action.content === state.content) {
|
|
return {
|
|
content: '',
|
|
previousContent: '',
|
|
visible: false
|
|
};
|
|
}
|
|
|
|
return state;
|
|
}
|
|
}
|
|
|
|
return state;
|
|
});
|