sforkowany z mirror/soapbox
Hovercard: mouseout clears the card
rodzic
0c4eae5f10
commit
4630a5cd04
|
@ -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,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
|
@ -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 });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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));
|
||||||
|
|
|
@ -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 });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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 {
|
||||||
|
|
Ładowanie…
Reference in New Issue