mirror of https://github.com/vector-im/riot-web
Add structure for mixed prototype UserMenu
parent
01b0acbe62
commit
02095389e7
|
@ -135,6 +135,44 @@ limitations under the License.
|
||||||
.mx_UserMenu_contextMenu {
|
.mx_UserMenu_contextMenu {
|
||||||
width: 247px;
|
width: 247px;
|
||||||
|
|
||||||
|
// These override the styles already present on the user menu rather than try to
|
||||||
|
// define a new menu. They are specifically for the stacked menu when a community
|
||||||
|
// is being represented as a prototype.
|
||||||
|
&.mx_UserMenu_contextMenu_prototype {
|
||||||
|
padding-bottom: 16px;
|
||||||
|
|
||||||
|
.mx_UserMenu_contextMenu_header {
|
||||||
|
padding-bottom: 0;
|
||||||
|
padding-top: 16px;
|
||||||
|
|
||||||
|
&:nth-child(n + 2) {
|
||||||
|
padding-top: 8px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
hr {
|
||||||
|
width: 85%;
|
||||||
|
opacity: 0.2;
|
||||||
|
border: none;
|
||||||
|
border-bottom: 1px solid $roomsublist-divider-color;
|
||||||
|
}
|
||||||
|
|
||||||
|
&.mx_IconizedContextMenu {
|
||||||
|
> .mx_IconizedContextMenu_optionList {
|
||||||
|
margin-top: 4px;
|
||||||
|
|
||||||
|
&::before {
|
||||||
|
border: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
> .mx_AccessibleButton {
|
||||||
|
padding-top: 2px;
|
||||||
|
padding-bottom: 2px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
&.mx_IconizedContextMenu .mx_IconizedContextMenu_optionList_red {
|
&.mx_IconizedContextMenu .mx_IconizedContextMenu_optionList_red {
|
||||||
.mx_AccessibleButton {
|
.mx_AccessibleButton {
|
||||||
padding-top: 16px;
|
padding-top: 16px;
|
||||||
|
@ -239,4 +277,12 @@ limitations under the License.
|
||||||
.mx_UserMenu_iconSignOut::before {
|
.mx_UserMenu_iconSignOut::before {
|
||||||
mask-image: url('$(res)/img/element-icons/leave.svg');
|
mask-image: url('$(res)/img/element-icons/leave.svg');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.mx_UserMenu_iconMembers::before {
|
||||||
|
mask-image: url('$(res)/img/element-icons/room/members.svg');
|
||||||
|
}
|
||||||
|
|
||||||
|
.mx_UserMenu_iconInvite::before {
|
||||||
|
mask-image: url('$(res)/img/element-icons/room/invite.svg');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -199,9 +199,32 @@ export default class UserMenu extends React.Component<IProps, IState> {
|
||||||
defaultDispatcher.dispatch({action: 'view_home_page'});
|
defaultDispatcher.dispatch({action: 'view_home_page'});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
private onCommunitySettingsClick = (ev: ButtonEvent) => {
|
||||||
|
ev.preventDefault();
|
||||||
|
ev.stopPropagation();
|
||||||
|
|
||||||
|
console.log("TODO@onCommunitySettingsClick");
|
||||||
|
};
|
||||||
|
|
||||||
|
private onCommunityMembersClick = (ev: ButtonEvent) => {
|
||||||
|
ev.preventDefault();
|
||||||
|
ev.stopPropagation();
|
||||||
|
|
||||||
|
console.log("TODO@onCommunityMembersClick");
|
||||||
|
};
|
||||||
|
|
||||||
|
private onCommunityInviteClick = (ev: ButtonEvent) => {
|
||||||
|
ev.preventDefault();
|
||||||
|
ev.stopPropagation();
|
||||||
|
|
||||||
|
console.log("TODO@onCommunityInviteClick");
|
||||||
|
};
|
||||||
|
|
||||||
private renderContextMenu = (): React.ReactNode => {
|
private renderContextMenu = (): React.ReactNode => {
|
||||||
if (!this.state.contextMenuPosition) return null;
|
if (!this.state.contextMenuPosition) return null;
|
||||||
|
|
||||||
|
const prototypeCommunityName = CommunityPrototypeStore.instance.getSelectedCommunityName();
|
||||||
|
|
||||||
let hostingLink;
|
let hostingLink;
|
||||||
const signupLink = getHostingLink("user-context-menu");
|
const signupLink = getHostingLink("user-context-menu");
|
||||||
if (signupLink) {
|
if (signupLink) {
|
||||||
|
@ -235,22 +258,135 @@ export default class UserMenu extends React.Component<IProps, IState> {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let primaryHeader = (
|
||||||
|
<div className="mx_UserMenu_contextMenu_name">
|
||||||
|
<span className="mx_UserMenu_contextMenu_displayName">
|
||||||
|
{OwnProfileStore.instance.displayName}
|
||||||
|
</span>
|
||||||
|
<span className="mx_UserMenu_contextMenu_userId">
|
||||||
|
{MatrixClientPeg.get().getUserId()}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
let primaryOptionList = (
|
||||||
|
<React.Fragment>
|
||||||
|
<IconizedContextMenuOptionList>
|
||||||
|
{homeButton}
|
||||||
|
<IconizedContextMenuOption
|
||||||
|
iconClassName="mx_UserMenu_iconBell"
|
||||||
|
label={_t("Notification settings")}
|
||||||
|
onClick={(e) => this.onSettingsOpen(e, USER_NOTIFICATIONS_TAB)}
|
||||||
|
/>
|
||||||
|
<IconizedContextMenuOption
|
||||||
|
iconClassName="mx_UserMenu_iconLock"
|
||||||
|
label={_t("Security & privacy")}
|
||||||
|
onClick={(e) => this.onSettingsOpen(e, USER_SECURITY_TAB)}
|
||||||
|
/>
|
||||||
|
<IconizedContextMenuOption
|
||||||
|
iconClassName="mx_UserMenu_iconSettings"
|
||||||
|
label={_t("All settings")}
|
||||||
|
onClick={(e) => this.onSettingsOpen(e, null)}
|
||||||
|
/>
|
||||||
|
{/* <IconizedContextMenuOption
|
||||||
|
iconClassName="mx_UserMenu_iconArchive"
|
||||||
|
label={_t("Archived rooms")}
|
||||||
|
onClick={this.onShowArchived}
|
||||||
|
/> */}
|
||||||
|
<IconizedContextMenuOption
|
||||||
|
iconClassName="mx_UserMenu_iconMessage"
|
||||||
|
label={_t("Feedback")}
|
||||||
|
onClick={this.onProvideFeedback}
|
||||||
|
/>
|
||||||
|
</IconizedContextMenuOptionList>
|
||||||
|
<IconizedContextMenuOptionList red>
|
||||||
|
<IconizedContextMenuOption
|
||||||
|
iconClassName="mx_UserMenu_iconSignOut"
|
||||||
|
label={_t("Sign out")}
|
||||||
|
onClick={this.onSignOutClick}
|
||||||
|
/>
|
||||||
|
</IconizedContextMenuOptionList>
|
||||||
|
</React.Fragment>
|
||||||
|
);
|
||||||
|
let secondarySection = null;
|
||||||
|
|
||||||
|
if (prototypeCommunityName) {
|
||||||
|
primaryHeader = (
|
||||||
|
<div className="mx_UserMenu_contextMenu_name">
|
||||||
|
<span className="mx_UserMenu_contextMenu_displayName">
|
||||||
|
{prototypeCommunityName}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
primaryOptionList = (
|
||||||
|
<IconizedContextMenuOptionList>
|
||||||
|
<IconizedContextMenuOption
|
||||||
|
iconClassName="mx_UserMenu_iconSettings"
|
||||||
|
label={_t("Settings")}
|
||||||
|
onClick={this.onCommunitySettingsClick}
|
||||||
|
/>
|
||||||
|
<IconizedContextMenuOption
|
||||||
|
iconClassName="mx_UserMenu_iconMembers"
|
||||||
|
label={_t("Members")}
|
||||||
|
onClick={this.onCommunityMembersClick}
|
||||||
|
/>
|
||||||
|
<IconizedContextMenuOption
|
||||||
|
iconClassName="mx_UserMenu_iconInvite"
|
||||||
|
label={_t("Invite")}
|
||||||
|
onClick={this.onCommunityInviteClick}
|
||||||
|
/>
|
||||||
|
</IconizedContextMenuOptionList>
|
||||||
|
);
|
||||||
|
secondarySection = (
|
||||||
|
<React.Fragment>
|
||||||
|
<hr />
|
||||||
|
<div className="mx_UserMenu_contextMenu_header">
|
||||||
|
<div className="mx_UserMenu_contextMenu_name">
|
||||||
|
<span className="mx_UserMenu_contextMenu_displayName">
|
||||||
|
{OwnProfileStore.instance.displayName}
|
||||||
|
</span>
|
||||||
|
<span className="mx_UserMenu_contextMenu_userId">
|
||||||
|
{MatrixClientPeg.get().getUserId()}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<IconizedContextMenuOptionList>
|
||||||
|
<IconizedContextMenuOption
|
||||||
|
iconClassName="mx_UserMenu_iconSettings"
|
||||||
|
label={_t("Settings")}
|
||||||
|
onClick={(e) => this.onSettingsOpen(e, null)}
|
||||||
|
/>
|
||||||
|
<IconizedContextMenuOption
|
||||||
|
iconClassName="mx_UserMenu_iconMessage"
|
||||||
|
label={_t("Feedback")}
|
||||||
|
onClick={this.onProvideFeedback}
|
||||||
|
/>
|
||||||
|
</IconizedContextMenuOptionList>
|
||||||
|
<IconizedContextMenuOptionList red>
|
||||||
|
<IconizedContextMenuOption
|
||||||
|
iconClassName="mx_UserMenu_iconSignOut"
|
||||||
|
label={_t("Sign out")}
|
||||||
|
onClick={this.onSignOutClick}
|
||||||
|
/>
|
||||||
|
</IconizedContextMenuOptionList>
|
||||||
|
</React.Fragment>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
const classes = classNames({
|
||||||
|
"mx_UserMenu_contextMenu": true,
|
||||||
|
"mx_UserMenu_contextMenu_prototype": !!prototypeCommunityName,
|
||||||
|
});
|
||||||
|
|
||||||
return <IconizedContextMenu
|
return <IconizedContextMenu
|
||||||
// -20 to overlap the context menu by just over the width of the `...` icon and make it look connected
|
// numerical adjustments to overlap the context menu by just over the width of the
|
||||||
left={this.state.contextMenuPosition.width + this.state.contextMenuPosition.left - 20}
|
// menu icon and make it look connected
|
||||||
top={this.state.contextMenuPosition.top + this.state.contextMenuPosition.height}
|
left={this.state.contextMenuPosition.width + this.state.contextMenuPosition.left - 10}
|
||||||
|
top={this.state.contextMenuPosition.top + this.state.contextMenuPosition.height + 8}
|
||||||
onFinished={this.onCloseMenu}
|
onFinished={this.onCloseMenu}
|
||||||
className="mx_UserMenu_contextMenu"
|
className={classes}
|
||||||
>
|
>
|
||||||
<div className="mx_UserMenu_contextMenu_header">
|
<div className="mx_UserMenu_contextMenu_header">
|
||||||
<div className="mx_UserMenu_contextMenu_name">
|
{primaryHeader}
|
||||||
<span className="mx_UserMenu_contextMenu_displayName">
|
|
||||||
{OwnProfileStore.instance.displayName}
|
|
||||||
</span>
|
|
||||||
<span className="mx_UserMenu_contextMenu_userId">
|
|
||||||
{MatrixClientPeg.get().getUserId()}
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
<AccessibleTooltipButton
|
<AccessibleTooltipButton
|
||||||
className="mx_UserMenu_contextMenu_themeButton"
|
className="mx_UserMenu_contextMenu_themeButton"
|
||||||
onClick={this.onSwitchThemeClick}
|
onClick={this.onSwitchThemeClick}
|
||||||
|
@ -264,41 +400,8 @@ export default class UserMenu extends React.Component<IProps, IState> {
|
||||||
</AccessibleTooltipButton>
|
</AccessibleTooltipButton>
|
||||||
</div>
|
</div>
|
||||||
{hostingLink}
|
{hostingLink}
|
||||||
<IconizedContextMenuOptionList>
|
{primaryOptionList}
|
||||||
{homeButton}
|
{secondarySection}
|
||||||
<IconizedContextMenuOption
|
|
||||||
iconClassName="mx_UserMenu_iconBell"
|
|
||||||
label={_t("Notification settings")}
|
|
||||||
onClick={(e) => this.onSettingsOpen(e, USER_NOTIFICATIONS_TAB)}
|
|
||||||
/>
|
|
||||||
<IconizedContextMenuOption
|
|
||||||
iconClassName="mx_UserMenu_iconLock"
|
|
||||||
label={_t("Security & privacy")}
|
|
||||||
onClick={(e) => this.onSettingsOpen(e, USER_SECURITY_TAB)}
|
|
||||||
/>
|
|
||||||
<IconizedContextMenuOption
|
|
||||||
iconClassName="mx_UserMenu_iconSettings"
|
|
||||||
label={_t("All settings")}
|
|
||||||
onClick={(e) => this.onSettingsOpen(e, null)}
|
|
||||||
/>
|
|
||||||
{/* <IconizedContextMenuOption
|
|
||||||
iconClassName="mx_UserMenu_iconArchive"
|
|
||||||
label={_t("Archived rooms")}
|
|
||||||
onClick={this.onShowArchived}
|
|
||||||
/> */}
|
|
||||||
<IconizedContextMenuOption
|
|
||||||
iconClassName="mx_UserMenu_iconMessage"
|
|
||||||
label={_t("Feedback")}
|
|
||||||
onClick={this.onProvideFeedback}
|
|
||||||
/>
|
|
||||||
</IconizedContextMenuOptionList>
|
|
||||||
<IconizedContextMenuOptionList red>
|
|
||||||
<IconizedContextMenuOption
|
|
||||||
iconClassName="mx_UserMenu_iconSignOut"
|
|
||||||
label={_t("Sign out")}
|
|
||||||
onClick={this.onSignOutClick}
|
|
||||||
/>
|
|
||||||
</IconizedContextMenuOptionList>
|
|
||||||
</IconizedContextMenu>;
|
</IconizedContextMenu>;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -2121,13 +2121,13 @@
|
||||||
"Uploading %(filename)s and %(count)s others|other": "Uploading %(filename)s and %(count)s others",
|
"Uploading %(filename)s and %(count)s others|other": "Uploading %(filename)s and %(count)s others",
|
||||||
"Uploading %(filename)s and %(count)s others|zero": "Uploading %(filename)s",
|
"Uploading %(filename)s and %(count)s others|zero": "Uploading %(filename)s",
|
||||||
"Uploading %(filename)s and %(count)s others|one": "Uploading %(filename)s and %(count)s other",
|
"Uploading %(filename)s and %(count)s others|one": "Uploading %(filename)s and %(count)s other",
|
||||||
"Switch to light mode": "Switch to light mode",
|
|
||||||
"Switch to dark mode": "Switch to dark mode",
|
|
||||||
"Switch theme": "Switch theme",
|
|
||||||
"Notification settings": "Notification settings",
|
"Notification settings": "Notification settings",
|
||||||
"Security & privacy": "Security & privacy",
|
"Security & privacy": "Security & privacy",
|
||||||
"All settings": "All settings",
|
"All settings": "All settings",
|
||||||
"Feedback": "Feedback",
|
"Feedback": "Feedback",
|
||||||
|
"Switch to light mode": "Switch to light mode",
|
||||||
|
"Switch to dark mode": "Switch to dark mode",
|
||||||
|
"Switch theme": "Switch theme",
|
||||||
"User menu": "User menu",
|
"User menu": "User menu",
|
||||||
"Community and user menu": "Community and user menu",
|
"Community and user menu": "Community and user menu",
|
||||||
"Could not load user profile": "Could not load user profile",
|
"Could not load user profile": "Could not load user profile",
|
||||||
|
|
Loading…
Reference in New Issue