mirror of
https://github.com/vector-im/element-web.git
synced 2026-05-05 20:26:19 +02:00
Different interface to add space panel items
A bit less flexible but probably simpler and will help keep things actually consistent rather than just allowing modules to stick any JSX into the space panel (which means they also have to worry about styling if they *do* want it to be consistent).
This commit is contained in:
parent
a02a5ac849
commit
9ae447f14f
@ -211,6 +211,10 @@ Please see LICENSE files in the repository root for full details.
|
||||
}
|
||||
}
|
||||
|
||||
&.mx_SpaceButton_withIcon .mx_SpaceButton_icon {
|
||||
background-color: $panel-actions;
|
||||
}
|
||||
|
||||
&.mx_SpaceButton_home .mx_SpaceButton_icon::before {
|
||||
mask-image: url("@vector-im/compound-design-tokens/icons/home-solid.svg");
|
||||
}
|
||||
|
||||
@ -341,7 +341,18 @@ const InnerSpacePanel = React.memo<IInnerSpacePanelProps>(
|
||||
</Draggable>
|
||||
))}
|
||||
{children}
|
||||
{ModuleApi.extras.spacePanelItems.map((renderer) => renderer({ isPanelCollapsed }))}
|
||||
{ModuleApi.extras.spacePanelItems.map((itemProps) => (
|
||||
<li
|
||||
key={itemProps.spaceKey}
|
||||
className={classNames("mx_SpaceItem", {
|
||||
collapsed: isPanelCollapsed,
|
||||
})}
|
||||
role="treeitem"
|
||||
aria-selected={false} // TODO
|
||||
>
|
||||
<SpaceButton {...itemProps} isNarrow={isPanelCollapsed} size="32px" />
|
||||
</li>
|
||||
))}
|
||||
{shouldShowComponent(UIComponent.CreateSpaces) && (
|
||||
<CreateSpaceButton isPanelCollapsed={isPanelCollapsed} setPanelCollapsed={setPanelCollapsed} />
|
||||
)}
|
||||
|
||||
@ -52,6 +52,7 @@ type ButtonProps<T extends keyof HTMLElementTagNameMap> = Omit<
|
||||
className?: string;
|
||||
selected?: boolean;
|
||||
label: string;
|
||||
icon?: JSX.Element;
|
||||
contextMenuTooltip?: string;
|
||||
notificationState?: NotificationState;
|
||||
isNarrow?: boolean;
|
||||
@ -65,6 +66,7 @@ export const SpaceButton = <T extends keyof HTMLElementTagNameMap>({
|
||||
space,
|
||||
spaceKey: _spaceKey,
|
||||
className,
|
||||
icon,
|
||||
selected,
|
||||
label,
|
||||
contextMenuTooltip,
|
||||
@ -84,7 +86,7 @@ export const SpaceButton = <T extends keyof HTMLElementTagNameMap>({
|
||||
|
||||
let avatar = (
|
||||
<div className="mx_SpaceButton_avatarPlaceholder">
|
||||
<div className="mx_SpaceButton_icon" />
|
||||
<div className="mx_SpaceButton_icon">{icon}</div>
|
||||
</div>
|
||||
);
|
||||
if (space) {
|
||||
@ -143,6 +145,7 @@ export const SpaceButton = <T extends keyof HTMLElementTagNameMap>({
|
||||
mx_SpaceButton_active: selected,
|
||||
mx_SpaceButton_hasMenuOpen: menuDisplayed,
|
||||
mx_SpaceButton_narrow: isNarrow,
|
||||
mx_SpaceButton_withIcon: Boolean(icon),
|
||||
})}
|
||||
aria-label={label}
|
||||
title={!isNarrow || menuDisplayed ? undefined : label}
|
||||
|
||||
@ -5,12 +5,12 @@ SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Com
|
||||
Please see LICENSE files in the repository root for full details.
|
||||
*/
|
||||
|
||||
import { type SpacePanelItemRenderFunction, type ExtrasApi } from "@element-hq/element-web-module-api";
|
||||
import { type SpacePanelItemProps, type ExtrasApi } from "@element-hq/element-web-module-api";
|
||||
|
||||
export class ElementWebExtrasApi implements ExtrasApi {
|
||||
public spacePanelItems: SpacePanelItemRenderFunction[] = [];
|
||||
public spacePanelItems: SpacePanelItemProps[] = [];
|
||||
|
||||
public addSpacePanelItem(renderer: SpacePanelItemRenderFunction): void {
|
||||
this.spacePanelItems.push(renderer);
|
||||
public addSpacePanelItem(item: SpacePanelItemProps): void {
|
||||
this.spacePanelItems.push(item);
|
||||
}
|
||||
}
|
||||
|
||||
@ -6,7 +6,7 @@ SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Com
|
||||
Please see LICENSE files in the repository root for full details.
|
||||
*/
|
||||
|
||||
import { type Room, type HierarchyRoom } from "matrix-js-sdk/src/matrix";
|
||||
import { type HierarchyRoom } from "matrix-js-sdk/src/matrix";
|
||||
|
||||
import { _t } from "../../languageHandler";
|
||||
|
||||
@ -42,7 +42,7 @@ export const getMetaSpaceName = (spaceKey: MetaSpace, allRoomsInHome = false): s
|
||||
}
|
||||
};
|
||||
|
||||
export type SpaceKey = MetaSpace | Room["roomId"];
|
||||
export type SpaceKey = string;
|
||||
|
||||
export interface ISuggestedRoom extends HierarchyRoom {
|
||||
viaServers: string[];
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user