Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Update space panel expand mechanism #7230

Merged
merged 2 commits into from
Dec 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 30 additions & 11 deletions res/css/structures/_SpacePanel.scss
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,9 @@ $activeBorderColor: $primary-content;
flex-direction: column;

.mx_SpacePanel_toggleCollapse {
margin: 0 auto;
position: relative;
min-width: 32px;
min-height: 32px;
line-height: 32px;
color: $secondary-content;
height: 32px;
width: 32px;

&::before {
content: "";
Expand All @@ -50,23 +47,45 @@ $activeBorderColor: $primary-content;
height: 32px;
left: 0;
mask-position: center;
mask-size: contain;
mask-size: 24px;
mask-repeat: no-repeat;
background-color: $secondary-content;
mask-image: url('$(res)/img/element-icons/expand-space-panel.svg');
mask-image: url('$(res)/img/feather-customised/chevron-down.svg');
transform: rotate(270deg);
}

&:not(.expanded) {
position: absolute;
left: 68px;
top: 12px;
border-radius: 0 8px 8px 0;
background-color: $primary-content;
opacity: 0;

&::before {
background-color: $background;
}
}

&.expanded {
padding-left: 48px;
padding-right: 8px;
margin-left: $gutterSize;
margin-left: auto;
margin-right: -8px; // overflow into .mx_UserMenu's margin without butchering its bottom stroke
border-radius: 8px;

&::before {
transform: scaleX(-1);
transform: rotate(90deg);
}

&:hover {
background-color: $panel-actions;
}
}
}

&:hover .mx_SpacePanel_toggleCollapse {
opacity: 100%;
}

ul {
margin: 0;
list-style: none;
Expand Down
7 changes: 6 additions & 1 deletion res/css/structures/_UserMenu.scss
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ limitations under the License.
display: flex;
align-items: center;

.mx_AccessibleButton {
display: flex;
align-items: center;
}

.mx_UserMenu_userAvatar {
position: relative;
}
Expand All @@ -30,7 +35,7 @@ limitations under the License.
margin-left: 10px;
}

&.mx_UserMenu_cutout .mx_BaseAvatar {
.mx_UserMenu_cutout .mx_BaseAvatar {
mask-image: url('$(res)/img/element-icons/roomlist/dnd-avatar-mask.svg');
mask-position: center;
mask-size: contain;
Expand Down
4 changes: 0 additions & 4 deletions res/img/element-icons/expand-space-panel.svg

This file was deleted.

19 changes: 17 additions & 2 deletions src/KeyBindingsDefaults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,15 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

import { AutocompleteAction, IKeyBindingsProvider, KeyBinding, MessageComposerAction, NavigationAction, RoomAction,
RoomListAction } from "./KeyBindingsManager";
import {
AutocompleteAction,
IKeyBindingsProvider,
KeyBinding,
MessageComposerAction,
NavigationAction,
RoomAction,
RoomListAction,
} from "./KeyBindingsManager";
import { isMac, Key } from "./Keyboard";
import SettingsStore from "./settings/SettingsStore";

Expand Down Expand Up @@ -321,6 +328,14 @@ const navigationBindings = (): KeyBinding<NavigationAction>[] => {
ctrlOrCmd: true,
},
},
{
action: NavigationAction.ToggleSpacePanel,
keyCombo: {
key: Key.D,
ctrlOrCmd: true,
shiftKey: true,
},
},
{
action: NavigationAction.ToggleRoomSidePanel,
keyCombo: {
Expand Down
2 changes: 2 additions & 0 deletions src/KeyBindingsManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ export enum RoomAction {
export enum NavigationAction {
/** Jump to room search (search for a room) */
FocusRoomSearch = 'FocusRoomSearch',
/** Toggle the space panel */
ToggleSpacePanel = 'ToggleSpacePanel',
/** Toggle the room side panel */
ToggleRoomSidePanel = 'ToggleRoomSidePanel',
/** Toggle the user menu */
Expand Down
8 changes: 7 additions & 1 deletion src/accessibility/KeyboardShortcuts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,12 @@ const shortcuts: Record<Categories, IShortcut[]> = {
key: Key.SPACE,
}],
description: _td("Activate selected button"),
}, {
keybinds: [{
modifiers: [CMD_OR_CTRL, Modifiers.SHIFT],
key: Key.D,
}],
description: _td("Toggle space panel"),
}, {
keybinds: [{
modifiers: [CMD_OR_CTRL],
Expand Down Expand Up @@ -348,7 +354,7 @@ const Shortcut: React.FC<{
}

return <div key={s.key}>
{ s.modifiers && s.modifiers.map(m => {
{ s.modifiers?.map(m => {
return <React.Fragment key={m}>
<kbd>{ modifierIcon[m] || _t(m) }</kbd>+
</React.Fragment>;
Expand Down
11 changes: 6 additions & 5 deletions src/components/structures/LoggedInView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,14 @@ import { IMatrixClientCreds } from '../../MatrixClientPeg';
import SettingsStore from "../../settings/SettingsStore";

import ResizeHandle from '../views/elements/ResizeHandle';
import { Resizer, CollapseDistributor } from '../../resizer';
import { CollapseDistributor, Resizer } from '../../resizer';
import MatrixClientContext from "../../contexts/MatrixClientContext";
import * as KeyboardShortcuts from "../../accessibility/KeyboardShortcuts";
import HomePage from "./HomePage";
import ResizeNotifier from "../../utils/ResizeNotifier";
import PlatformPeg from "../../PlatformPeg";
import { DefaultTagID } from "../../stores/room-list/models";
import {
showToast as showServerLimitToast,
hideToast as hideServerLimitToast,
} from "../../toasts/ServerLimitToast";
import { hideToast as hideServerLimitToast, showToast as showServerLimitToast } from "../../toasts/ServerLimitToast";
import { Action } from "../../dispatcher/actions";
import LeftPanel from "./LeftPanel";
import CallContainer from '../views/voip/CallContainer';
Expand Down Expand Up @@ -505,6 +502,10 @@ class LoggedInView extends React.Component<IProps, IState> {
Modal.closeCurrentModal("homeKeyboardShortcut");
handled = true;
break;
case NavigationAction.ToggleSpacePanel:
dis.fire(Action.ToggleSpacePanel);
handled = true;
break;
case NavigationAction.ToggleRoomSidePanel:
if (this.props.page_type === "room_view" || this.props.page_type === "group_view") {
dis.dispatch<ToggleRightPanelPayload>({
Expand Down
8 changes: 5 additions & 3 deletions src/components/structures/UserMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -523,14 +523,14 @@ export default class UserMenu extends React.Component<IProps, IState> {
</div>;
}

return (
return <div className="mx_UserMenu">
<ContextMenuButton
onClick={this.onOpenMenuClick}
inputRef={this.buttonRef}
label={_t("User menu")}
isExpanded={!!this.state.contextMenuPosition}
onContextMenu={this.onContextMenu}
className={classNames("mx_UserMenu", {
className={classNames({
mx_UserMenu_cutout: badge,
})}
>
Expand All @@ -550,6 +550,8 @@ export default class UserMenu extends React.Component<IProps, IState> {

{ this.renderContextMenu() }
</ContextMenuButton>
);

{ this.props.children }
</div>;
}
}
36 changes: 27 additions & 9 deletions src/components/views/spaces/SpacePanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ import QuickSettingsButton from "./QuickSettingsButton";
import { useSettingValue } from "../../../hooks/useSettings";
import UserMenu from "../../structures/UserMenu";
import IndicatorScrollbar from "../../structures/IndicatorScrollbar";
import { isMac } from "../../../Keyboard";
import { useDispatcher } from "../../../hooks/useDispatcher";
import defaultDispatcher from "../../../dispatcher/dispatcher";
import { ActionPayload } from "../../../dispatcher/payloads";
import { Action } from "../../../dispatcher/actions";

const useSpaces = (): [Room[], MetaSpace[], Room[], SpaceKey] => {
const invites = useEventEmitterState<Room[]>(SpaceStore.instance, UPDATE_INVITED_SPACES, () => {
Expand Down Expand Up @@ -293,6 +298,12 @@ const SpacePanel = () => {
return () => UIStore.instance.stopTrackingElementDimensions("SpacePanel");
}, []);

useDispatcher(defaultDispatcher, (payload: ActionPayload) => {
if (payload.action === Action.ToggleSpacePanel) {
setPanelCollapsed(!isPanelCollapsed);
}
});

return (
<DragDropContext onDragEnd={result => {
if (!result.destination) return; // dropped outside the list
Expand All @@ -307,7 +318,21 @@ const SpacePanel = () => {
aria-label={_t("Spaces")}
ref={ref}
>
<UserMenu isPanelCollapsed={isPanelCollapsed} />
<UserMenu isPanelCollapsed={isPanelCollapsed}>
<AccessibleTooltipButton
className={classNames("mx_SpacePanel_toggleCollapse", { expanded: !isPanelCollapsed })}
onClick={() => setPanelCollapsed(!isPanelCollapsed)}
title={isPanelCollapsed ? _t("Expand") : _t("Collapse")}
tooltip={<div>
<div className="mx_Tooltip_title">
{ isPanelCollapsed ? _t("Expand") : _t("Collapse") }
</div>
<div className="mx_Tooltip_sub">
{ isMac ? "⌘ + ⇧ + D" : "Ctrl + Shift + D" }
</div>
</div>}
/>
</UserMenu>
<Droppable droppableId="top-level-spaces">
{ (provided, snapshot) => (
<IndicatorScrollbar
Expand All @@ -327,14 +352,7 @@ const SpacePanel = () => {
</IndicatorScrollbar>
) }
</Droppable>
<AccessibleTooltipButton
className={classNames("mx_SpacePanel_toggleCollapse", { expanded: !isPanelCollapsed })}
onClick={() => setPanelCollapsed(!isPanelCollapsed)}
title={isPanelCollapsed ? _t("Expand space panel") : _t("Collapse space panel")}
forceHide={!isPanelCollapsed}
>
{ !isPanelCollapsed ? _t("Collapse") : null }
</AccessibleTooltipButton>

{ metaSpacesEnabled && <QuickSettingsButton isPanelCollapsed={isPanelCollapsed} /> }
</ul>
) }
Expand Down
5 changes: 5 additions & 0 deletions src/dispatcher/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,11 @@ export enum Action {
*/
ToggleUserMenu = "toggle_user_menu",

/**
* Toggles the Space panel. No additional payload information required.
*/
ToggleSpacePanel = "toggle_space_panel",

/**
* Sets the apps root font size. Should be used with UpdateFontSizePayload
*/
Expand Down
5 changes: 2 additions & 3 deletions src/i18n/strings/en_EN.json
Original file line number Diff line number Diff line change
Expand Up @@ -1100,8 +1100,7 @@
"Create": "Create",
"Show all rooms": "Show all rooms",
"Options": "Options",
"Expand space panel": "Expand space panel",
"Collapse space panel": "Collapse space panel",
"Expand": "Expand",
"Collapse": "Collapse",
"Click to copy": "Click to copy",
"Copied!": "Copied!",
Expand Down Expand Up @@ -1130,7 +1129,6 @@
"Recommended for public spaces.": "Recommended for public spaces.",
"Jump to first unread room.": "Jump to first unread room.",
"Jump to first invite.": "Jump to first invite.",
"Expand": "Expand",
"Space options": "Space options",
"Remove": "Remove",
"This bridge was provisioned by <user />.": "This bridge was provisioned by <user />.",
Expand Down Expand Up @@ -3321,6 +3319,7 @@
"Toggle the top left menu": "Toggle the top left menu",
"Close dialog or context menu": "Close dialog or context menu",
"Activate selected button": "Activate selected button",
"Toggle space panel": "Toggle space panel",
"Toggle right panel": "Toggle right panel",
"Toggle this dialog": "Toggle this dialog",
"Go to Home View": "Go to Home View",
Expand Down