Hovercard: mouseout clears the card

better-thread-display
Alex Gleason 2020-09-10 20:18:04 -05:00
rodzic 0c4eae5f10
commit 4630a5cd04
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 7211D1F99744FBB7
6 zmienionych plików z 32 dodań i 13 usunięć

Wyświetl plik

@ -1,4 +1,5 @@
export const PROFILE_HOVER_CARD_OPEN = 'PROFILE_HOVER_CARD_OPEN'; export const PROFILE_HOVER_CARD_OPEN = 'PROFILE_HOVER_CARD_OPEN';
export const PROFILE_HOVER_CARD_CLEAR = 'PROFILE_HOVER_CARD_CLEAR';
export function openProfileHoverCard(ref, accountId) { export function openProfileHoverCard(ref, accountId) {
return { return {
@ -7,3 +8,9 @@ export function openProfileHoverCard(ref, accountId) {
accountId, accountId,
}; };
} }
export function clearProfileHoverCard() {
return {
type: PROFILE_HOVER_CARD_CLEAR,
};
}

Wyświetl plik

@ -81,7 +81,7 @@ class Status extends ImmutablePureComponent {
onEmbed: PropTypes.func, onEmbed: PropTypes.func,
onHeightChange: PropTypes.func, onHeightChange: PropTypes.func,
onToggleHidden: PropTypes.func, onToggleHidden: PropTypes.func,
onShowProfileCard: PropTypes.func, onShowHoverProfileCard: PropTypes.func,
muted: PropTypes.bool, muted: PropTypes.bool,
hidden: PropTypes.bool, hidden: PropTypes.bool,
unread: PropTypes.bool, unread: PropTypes.bool,
@ -256,17 +256,18 @@ class Status extends ImmutablePureComponent {
this.handleToggleMediaVisibility(); this.handleToggleMediaVisibility();
} }
showProfileCard = debounce(() => { showProfileHoverCard = debounce(() => {
const { onShowProfileCard, status } = this.props; const { onShowProfileHoverCard, status } = this.props;
onShowProfileCard(this.profileNode, status.getIn(['account', 'id'])); onShowProfileHoverCard(this.profileNode, status.getIn(['account', 'id']));
}, 1200); }, 1200);
handleProfileHover = e => { handleProfileHover = e => {
if (!isMobile(window.innerWidth)) this.showProfileCard(); if (!isMobile(window.innerWidth)) this.showProfileHoverCard();
} }
handleProfileLeave = e => { handleProfileLeave = e => {
this.showProfileCard.cancel(); this.showProfileHoverCard.cancel();
this.props.onClearProfileHoverCard();
this.setState({ profileCardVisible: false }); this.setState({ profileCardVisible: false });
} }

Wyświetl plik

@ -35,7 +35,10 @@ import {
groupRemoveStatus, groupRemoveStatus,
} from '../actions/groups'; } from '../actions/groups';
import { getSettings } from '../actions/settings'; import { getSettings } from '../actions/settings';
import { openProfileHoverCard } from 'soapbox/actions/profile_hover_card'; import {
openProfileHoverCard,
clearProfileHoverCard,
} from 'soapbox/actions/profile_hover_card';
const messages = defineMessages({ const messages = defineMessages({
deleteConfirm: { id: 'confirmations.delete.confirm', defaultMessage: 'Delete' }, deleteConfirm: { id: 'confirmations.delete.confirm', defaultMessage: 'Delete' },
@ -207,10 +210,14 @@ const mapDispatchToProps = (dispatch, { intl }) => ({
dispatch(groupRemoveStatus(groupId, statusId)); dispatch(groupRemoveStatus(groupId, statusId));
}, },
onShowProfileCard(ref, accountId) { onShowProfileHoverCard(ref, accountId) {
dispatch(openProfileHoverCard(ref, accountId)); dispatch(openProfileHoverCard(ref, accountId));
}, },
onClearProfileHoverCard() {
dispatch(clearProfileHoverCard());
},
}); });
export default injectIntl(connect(makeMapStateToProps, mapDispatchToProps)(Status)); export default injectIntl(connect(makeMapStateToProps, mapDispatchToProps)(Status));

Wyświetl plik

@ -86,16 +86,16 @@ export default class DetailedStatus extends ImmutablePureComponent {
window.open(href, 'soapbox-intent', 'width=445,height=600,resizable=no,menubar=no,status=no,scrollbars=yes'); window.open(href, 'soapbox-intent', 'width=445,height=600,resizable=no,menubar=no,status=no,scrollbars=yes');
} }
showProfileCard = debounce(() => { showProfileHoverCard = debounce(() => {
this.setState({ profileCardVisible: true }); this.setState({ profileCardVisible: true });
}, 1200); }, 1200);
handleProfileHover = e => { handleProfileHover = e => {
if (!isMobile(window.innerWidth)) this.showProfileCard(); if (!isMobile(window.innerWidth)) this.showProfileHoverCard();
} }
handleProfileLeave = e => { handleProfileLeave = e => {
this.showProfileCard.cancel(); this.showProfileHoverCard.cancel();
this.setState({ profileCardVisible: false }); this.setState({ profileCardVisible: false });
} }

Wyświetl plik

@ -1,4 +1,7 @@
import { PROFILE_HOVER_CARD_OPEN } from 'soapbox/actions/profile_hover_card'; import {
PROFILE_HOVER_CARD_OPEN,
PROFILE_HOVER_CARD_CLEAR,
} from 'soapbox/actions/profile_hover_card';
import { Map as ImmutableMap } from 'immutable'; import { Map as ImmutableMap } from 'immutable';
const initialState = ImmutableMap(); const initialState = ImmutableMap();
@ -10,6 +13,8 @@ export default function profileHoverCard(state = initialState, action) {
ref: action.ref, ref: action.ref,
accountId: action.accountId, accountId: action.accountId,
}); });
case PROFILE_HOVER_CARD_CLEAR:
return ImmutableMap();
default: default:
return state; return state;
} }

Wyświetl plik

@ -17,7 +17,6 @@
z-index: 200; z-index: 200;
top: 0; top: 0;
left: 0; left: 0;
padding: 20px;
margin-bottom: 10px; margin-bottom: 10px;
&--visible { &--visible {