mirror of
https://github.com/SableClient/Sable.git
synced 2026-11-26 03:46:25 -08:00
added more styling in regard to the room sidebar, more to come
This commit is contained in:
1 parent
1e2351d069
commit
55cae95f6e
7 files changed
+291
-170
No files matched your search
@@ -1,26 +1,46 @@
|
||||
import { as, Chip, Icon, Icons, Text } from 'folds';
|
||||
import { as, Chip, Icon, IconButton, Icons, Text } from 'folds';
|
||||
import classNames from 'classnames';
|
||||
import * as css from './styles.css';
|
||||
|
||||
export const RoomNavCategoryButton = as<'button', { closed?: boolean }>(
|
||||
({ className, closed, children, ...props }, ref) => (
|
||||
<Chip
|
||||
className={classNames(css.CategoryButton, className)}
|
||||
variant="Background"
|
||||
radii="400"
|
||||
after={
|
||||
({ className, closed, children, ...props }, ref) => {
|
||||
if (children)
|
||||
return (
|
||||
<Chip
|
||||
className={classNames(css.CategoryButton, className)}
|
||||
variant="Background"
|
||||
radii="400"
|
||||
before={
|
||||
<Icon
|
||||
className={css.CategoryButtonIcon}
|
||||
size="50"
|
||||
src={closed ? Icons.ChevronRight : Icons.ChevronBottom}
|
||||
/>
|
||||
}
|
||||
{...props}
|
||||
ref={ref}
|
||||
>
|
||||
{children && (
|
||||
<Text size="B400" priority="300" truncate>
|
||||
{children}
|
||||
</Text>
|
||||
)}
|
||||
</Chip>
|
||||
);
|
||||
return (
|
||||
<IconButton
|
||||
className={classNames(css.CategoryButton, className)}
|
||||
variant="Background"
|
||||
radii="400"
|
||||
{...props}
|
||||
ref={ref}
|
||||
>
|
||||
<Icon
|
||||
className={css.CategoryButtonIcon}
|
||||
size="50"
|
||||
src={closed ? Icons.ChevronRight : Icons.ChevronBottom}
|
||||
/>
|
||||
}
|
||||
{...props}
|
||||
ref={ref}
|
||||
>
|
||||
<Text size="B400" priority="300" truncate>
|
||||
{children}
|
||||
</Text>
|
||||
</Chip>
|
||||
)
|
||||
</IconButton>
|
||||
);
|
||||
}
|
||||
);
|
||||
@@ -252,6 +252,9 @@ const RoomNavItemMenu = forwardRef<HTMLDivElement, RoomNavItemMenuProps>(
|
||||
}
|
||||
);
|
||||
|
||||
export const hideTextStyling = (isHidden: boolean | undefined) =>
|
||||
isHidden ? { width: '100%', height: '100%', padding: '0', paddingTop: '0px' } : {};
|
||||
|
||||
type RoomNavItemProps = {
|
||||
room: Room;
|
||||
selected: boolean;
|
||||
@@ -260,6 +263,7 @@ type RoomNavItemProps = {
|
||||
showAvatar?: boolean;
|
||||
direct?: boolean;
|
||||
customDMCards?: boolean;
|
||||
hideText?: boolean;
|
||||
};
|
||||
|
||||
export function RoomNavItem({
|
||||
@@ -270,6 +274,7 @@ export function RoomNavItem({
|
||||
customDMCards,
|
||||
notificationMode,
|
||||
linkPath,
|
||||
hideText,
|
||||
}: RoomNavItemProps) {
|
||||
const mx = useMatrixClient();
|
||||
const useAuthentication = useMediaAuthentication();
|
||||
@@ -374,9 +379,12 @@ export function RoomNavItem({
|
||||
.flat()
|
||||
.filter(Boolean)
|
||||
.join(', ');
|
||||
|
||||
return (
|
||||
<Box direction="Column" grow="Yes">
|
||||
<Box
|
||||
direction="Column"
|
||||
grow="Yes"
|
||||
style={{ ...hideTextStyling(hideText), marginTop: hideText ? toRem(5) : '0' }}
|
||||
>
|
||||
<NavItem
|
||||
variant="Background"
|
||||
radii="400"
|
||||
@@ -386,111 +394,145 @@ export function RoomNavItem({
|
||||
onContextMenu={handleContextMenu}
|
||||
{...hoverProps}
|
||||
{...focusWithinProps}
|
||||
style={hideTextStyling(hideText)}
|
||||
>
|
||||
<NavButton onClick={handleNavItemClick} aria-label={ariaLabel}>
|
||||
<NavItemContent>
|
||||
<Box as="span" grow="Yes" alignItems="Center" gap="200">
|
||||
<AvatarPresence
|
||||
badge={
|
||||
presence &&
|
||||
presence.presence !== Presence.Offline && (
|
||||
<PresenceBadge presence={presence.presence} size="200" />
|
||||
)
|
||||
}
|
||||
>
|
||||
<Avatar size="200" radii="400">
|
||||
{showAvatar ? (
|
||||
<RoomAvatar
|
||||
roomId={room.roomId}
|
||||
src={
|
||||
((!direct || customDMCards) &&
|
||||
getRoomAvatarUrl(mx, room, 96, useAuthentication)) ||
|
||||
getDirectRoomAvatarUrl(mx, room, 96, useAuthentication)
|
||||
}
|
||||
uniformIcons
|
||||
alt={roomName}
|
||||
renderFallback={() => (
|
||||
<Text as="span" size="H6">
|
||||
{nameInitials(roomName)}
|
||||
</Text>
|
||||
)}
|
||||
/>
|
||||
) : (
|
||||
<RoomIcon
|
||||
style={{
|
||||
opacity:
|
||||
unread || hasRoomUnread || isActiveCall
|
||||
? config.opacity.P500
|
||||
: config.opacity.P300,
|
||||
}}
|
||||
filled={selected || isActiveCall}
|
||||
size="100"
|
||||
joinRule={room.getJoinRule()}
|
||||
roomType={room.getType()}
|
||||
/>
|
||||
)}
|
||||
</Avatar>
|
||||
</AvatarPresence>
|
||||
<Box as="span" grow="Yes" direction="Column">
|
||||
<Text
|
||||
priority={unread || hasRoomUnread || isActiveCall ? '500' : '400'}
|
||||
as="span"
|
||||
size="Inherit"
|
||||
truncate
|
||||
>
|
||||
{roomName}
|
||||
</Text>
|
||||
{roomTopic && (
|
||||
<Text
|
||||
truncate
|
||||
size="T200"
|
||||
priority="300"
|
||||
style={{
|
||||
opacity: config.opacity.P300,
|
||||
marginTop: '-2px',
|
||||
}}
|
||||
<TooltipProvider
|
||||
position="Right"
|
||||
offset={4}
|
||||
tooltip={
|
||||
hideText && (
|
||||
<Tooltip>
|
||||
<Text>{roomName}</Text>
|
||||
</Tooltip>
|
||||
)
|
||||
}
|
||||
>
|
||||
{(triggerRef) => (
|
||||
<NavButton
|
||||
onClick={handleNavItemClick}
|
||||
aria-label={ariaLabel}
|
||||
ref={triggerRef}
|
||||
style={hideTextStyling(hideText)}
|
||||
>
|
||||
<NavItemContent style={hideTextStyling(hideText)}>
|
||||
<Box as="span" grow="Yes" alignItems="Center" style={hideTextStyling(hideText)}>
|
||||
<AvatarPresence
|
||||
badge={
|
||||
presence &&
|
||||
presence.presence !== Presence.Offline && (
|
||||
<PresenceBadge
|
||||
presence={presence.presence}
|
||||
size={hideText ? undefined : '200'}
|
||||
/>
|
||||
)
|
||||
}
|
||||
style={hideTextStyling(hideText)}
|
||||
>
|
||||
{roomTopic}
|
||||
</Text>
|
||||
)}
|
||||
</Box>
|
||||
{!optionsVisible && !unread && !selected && typingMember.length > 0 && (
|
||||
<Badge size="300" variant="Secondary" fill="Soft" radii="Pill" outlined>
|
||||
<TypingIndicator size="300" disableAnimation />
|
||||
</Badge>
|
||||
)}
|
||||
{!optionsVisible && shouldShowUnreadIndicator && (
|
||||
<UnreadBadgeCenter>
|
||||
<UnreadBadge
|
||||
highlight={!!unread && unread.highlight > 0}
|
||||
count={unreadCount}
|
||||
dm={direct}
|
||||
/>
|
||||
</UnreadBadgeCenter>
|
||||
)}
|
||||
{!optionsVisible && notificationMode !== RoomNotificationMode.Unset && (
|
||||
<Icon
|
||||
size="50"
|
||||
src={getRoomNotificationModeIcon(notificationMode)}
|
||||
aria-label={notificationMode}
|
||||
/>
|
||||
)}
|
||||
{(room.isCallRoom() || direct) && callMembers.length > 0 && !optionsVisible && (
|
||||
<Badge variant="Critical" fill="Solid" size="400">
|
||||
<Box alignItems="Center" gap="100">
|
||||
<Icon size="50" src={Icons.Phone} color="Inherit" />
|
||||
<Text as="span" size="L400" truncate>
|
||||
{direct ? 'Calling' : `${callMembers.length} Live`}
|
||||
</Text>
|
||||
</Box>
|
||||
</Badge>
|
||||
)}
|
||||
</Box>
|
||||
</NavItemContent>
|
||||
</NavButton>
|
||||
<Avatar
|
||||
size={hideText ? undefined : '200'}
|
||||
radii="400"
|
||||
style={hideTextStyling(hideText)}
|
||||
>
|
||||
{showAvatar ? (
|
||||
<RoomAvatar
|
||||
roomId={room.roomId}
|
||||
src={
|
||||
((!direct || customDMCards) &&
|
||||
getRoomAvatarUrl(mx, room, 96, useAuthentication)) ||
|
||||
getDirectRoomAvatarUrl(mx, room, 96, useAuthentication)
|
||||
}
|
||||
uniformIcons
|
||||
alt={roomName}
|
||||
renderFallback={() => (
|
||||
<Text as="span" size="H6">
|
||||
{nameInitials(roomName)}
|
||||
</Text>
|
||||
)}
|
||||
/>
|
||||
) : (
|
||||
<RoomIcon
|
||||
style={{
|
||||
opacity:
|
||||
unread || hasRoomUnread || isActiveCall
|
||||
? config.opacity.P500
|
||||
: config.opacity.P300,
|
||||
}}
|
||||
filled={selected || isActiveCall}
|
||||
size="100"
|
||||
joinRule={room.getJoinRule()}
|
||||
roomType={room.getType()}
|
||||
/>
|
||||
)}
|
||||
</Avatar>
|
||||
</AvatarPresence>
|
||||
{!hideText && (
|
||||
<>
|
||||
<Box as="span" grow="Yes" direction="Column">
|
||||
<Text
|
||||
priority={unread || hasRoomUnread || isActiveCall ? '500' : '400'}
|
||||
as="span"
|
||||
size="Inherit"
|
||||
truncate
|
||||
>
|
||||
{roomName}
|
||||
</Text>
|
||||
{roomTopic && (
|
||||
<Text
|
||||
truncate
|
||||
size="T200"
|
||||
priority="300"
|
||||
style={{
|
||||
opacity: config.opacity.P300,
|
||||
marginTop: '-2px',
|
||||
}}
|
||||
>
|
||||
{roomTopic}
|
||||
</Text>
|
||||
)}
|
||||
</Box>
|
||||
{!optionsVisible && !unread && !selected && typingMember.length > 0 && (
|
||||
<Badge size="300" variant="Secondary" fill="Soft" radii="Pill" outlined>
|
||||
<TypingIndicator size="300" disableAnimation />
|
||||
</Badge>
|
||||
)}
|
||||
{!optionsVisible && shouldShowUnreadIndicator && (
|
||||
<UnreadBadgeCenter>
|
||||
<UnreadBadge
|
||||
highlight={!!unread && unread.highlight > 0}
|
||||
count={unreadCount}
|
||||
dm={direct}
|
||||
/>
|
||||
</UnreadBadgeCenter>
|
||||
)}
|
||||
{!optionsVisible && notificationMode !== RoomNotificationMode.Unset && (
|
||||
<Icon
|
||||
size="50"
|
||||
src={getRoomNotificationModeIcon(notificationMode)}
|
||||
aria-label={notificationMode}
|
||||
/>
|
||||
)}
|
||||
{(room.isCallRoom() || direct) &&
|
||||
callMembers.length > 0 &&
|
||||
!optionsVisible && (
|
||||
<Badge variant="Critical" fill="Solid" size="400">
|
||||
<Box alignItems="Center" gap="100">
|
||||
<Icon size="50" src={Icons.Phone} color="Inherit" />
|
||||
<Text as="span" size="L400" truncate>
|
||||
{direct ? 'Calling' : `${callMembers.length} Live`}
|
||||
</Text>
|
||||
</Box>
|
||||
</Badge>
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
</Box>
|
||||
</NavItemContent>
|
||||
</NavButton>
|
||||
)}
|
||||
</TooltipProvider>
|
||||
{optionsVisible && (
|
||||
<NavItemOptions>
|
||||
{(room.isCallRoom() || (direct && callMembers.length > 0)) && (
|
||||
{(room.isCallRoom() || (direct && callMembers.length > 0)) && !hideText && (
|
||||
<TooltipProvider
|
||||
position="Bottom"
|
||||
offset={4}
|
||||
@@ -545,18 +587,20 @@ export function RoomNavItem({
|
||||
</FocusTrap>
|
||||
}
|
||||
>
|
||||
<IconButton
|
||||
onClick={handleOpenMenu}
|
||||
aria-pressed={!!menuAnchor}
|
||||
aria-controls={`menu-${room.roomId}`}
|
||||
aria-label="More Options"
|
||||
variant="Background"
|
||||
fill="None"
|
||||
size="300"
|
||||
radii="300"
|
||||
>
|
||||
<Icon size="50" src={Icons.VerticalDots} />
|
||||
</IconButton>
|
||||
{!hideText && (
|
||||
<IconButton
|
||||
onClick={handleOpenMenu}
|
||||
aria-pressed={!!menuAnchor}
|
||||
aria-controls={`menu-${room.roomId}`}
|
||||
aria-label="More Options"
|
||||
variant="Background"
|
||||
fill="None"
|
||||
size="300"
|
||||
radii="300"
|
||||
>
|
||||
<Icon size="50" src={Icons.VerticalDots} />
|
||||
</IconButton>
|
||||
)}
|
||||
</PopOut>
|
||||
</NavItemOptions>
|
||||
)}
|
||||
|
||||
@@ -11,9 +11,10 @@ type SpaceNavItemProps = {
|
||||
room: Room;
|
||||
selected: boolean;
|
||||
linkPath: string;
|
||||
hideText?: boolean;
|
||||
};
|
||||
|
||||
export function SpaceNavItem({ room, selected, linkPath }: SpaceNavItemProps) {
|
||||
export function SpaceNavItem({ room, selected, linkPath, hideText }: SpaceNavItemProps) {
|
||||
const [menuAnchor, setMenuAnchor] = useState<RectCords>();
|
||||
|
||||
const matrixRoomName = useRoomName(room);
|
||||
@@ -58,11 +59,13 @@ export function SpaceNavItem({ room, selected, linkPath }: SpaceNavItemProps) {
|
||||
size="100"
|
||||
/>
|
||||
</Avatar>
|
||||
<Box as="span" grow="Yes">
|
||||
<Text priority="300" as="span" size="Inherit" truncate>
|
||||
{roomName}
|
||||
</Text>
|
||||
</Box>
|
||||
{!hideText && (
|
||||
<Box as="span" grow="Yes">
|
||||
<Text priority="300" as="span" size="Inherit" truncate>
|
||||
{roomName}
|
||||
</Text>
|
||||
</Box>
|
||||
)}
|
||||
</Box>
|
||||
</NavItemContent>
|
||||
</NavButton>
|
||||
|
||||
@@ -247,6 +247,7 @@ export function Direct() {
|
||||
);
|
||||
|
||||
const screenSize = useScreenSizeContext();
|
||||
const isMobile = mobileOrTablet() || screenSize === ScreenSize.Mobile;
|
||||
|
||||
return (
|
||||
<>
|
||||
@@ -309,18 +310,32 @@ export function Direct() {
|
||||
key={vItem.index}
|
||||
ref={virtualizer.measureElement}
|
||||
>
|
||||
<RoomNavItem
|
||||
room={room}
|
||||
selected={selected}
|
||||
showAvatar
|
||||
direct
|
||||
customDMCards={customDMCards}
|
||||
linkPath={getDirectRoomPath(getCanonicalAliasOrRoomId(mx, roomId))}
|
||||
notificationMode={getRoomNotificationMode(
|
||||
notificationPreferences,
|
||||
room.roomId
|
||||
)}
|
||||
/>
|
||||
<div
|
||||
style={
|
||||
curWidth < 96 && !isMobile
|
||||
? {
|
||||
padding: '0',
|
||||
width: '100%',
|
||||
aspectRatio: 1,
|
||||
display: 'flex,',
|
||||
}
|
||||
: {}
|
||||
}
|
||||
>
|
||||
<RoomNavItem
|
||||
room={room}
|
||||
selected={selected}
|
||||
showAvatar
|
||||
direct
|
||||
customDMCards={customDMCards}
|
||||
hideText={curWidth < 96 && !isMobile}
|
||||
linkPath={getDirectRoomPath(getCanonicalAliasOrRoomId(mx, roomId))}
|
||||
notificationMode={getRoomNotificationMode(
|
||||
notificationPreferences,
|
||||
room.roomId
|
||||
)}
|
||||
/>
|
||||
</div>
|
||||
</VirtualTile>
|
||||
);
|
||||
})}
|
||||
|
||||
@@ -10,7 +10,6 @@ export const SidebarResizer = style({
|
||||
export const SidebarResizerHover = style({
|
||||
height: '100%',
|
||||
zIndex: '100',
|
||||
boxShadow: `0px 0px 32px 8px ${color.Primary.Main}`,
|
||||
});
|
||||
export const SideBarResizerAnimation = style({
|
||||
width: '100%',
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
import { style } from '@vanilla-extract/css';
|
||||
|
||||
export const SmartIcon = style({
|
||||
selectors: {
|
||||
[`& > *`]: {
|
||||
width: '100%',
|
||||
aspectRatio: '1',
|
||||
},
|
||||
},
|
||||
width: '100%',
|
||||
aspectRatio: '1',
|
||||
});
|
||||
@@ -398,7 +398,7 @@ export function Space() {
|
||||
const showIcons = () => {
|
||||
if (showRoomIcon === ShowRoomIcon.Always) return true;
|
||||
if (showRoomIcon === ShowRoomIcon.Never) return false;
|
||||
return curWidth < 96;
|
||||
return curWidth < 144;
|
||||
};
|
||||
useEffect(() => {
|
||||
setCurWidth(roomSidebarWidth);
|
||||
@@ -726,12 +726,13 @@ export function Space() {
|
||||
}, [lastRoomId, spaceIdOrAlias, mx, navigate]);
|
||||
|
||||
const screenSize = useScreenSizeContext();
|
||||
|
||||
const isMobile = mobileOrTablet() || screenSize === ScreenSize.Mobile;
|
||||
const hideText = curWidth < 96 && !isMobile;
|
||||
return (
|
||||
<>
|
||||
<Box
|
||||
style={{
|
||||
width: mobileOrTablet() || screenSize === ScreenSize.Mobile ? '100%' : toRem(curWidth),
|
||||
width: isMobile ? '100%' : toRem(curWidth),
|
||||
}}
|
||||
>
|
||||
<PageNav>
|
||||
@@ -750,14 +751,19 @@ export function Space() {
|
||||
<NavLink to={getSpaceLobbyPath(getCanonicalAliasOrRoomId(mx, space.roomId))}>
|
||||
<NavItemContent>
|
||||
<Box as="span" grow="Yes" alignItems="Center" gap="200">
|
||||
<Avatar size="200" radii="400">
|
||||
<Avatar
|
||||
radii="400"
|
||||
style={hideText ? { width: '100%' } : { height: '100%' }}
|
||||
>
|
||||
<Icon src={Icons.Flag} size="100" filled={lobbySelected} />
|
||||
</Avatar>
|
||||
<Box as="span" grow="Yes">
|
||||
<Text as="span" size="Inherit" truncate>
|
||||
Lobby
|
||||
</Text>
|
||||
</Box>
|
||||
{!hideText && (
|
||||
<Box as="span" grow="Yes">
|
||||
<Text as="span" size="Inherit" truncate>
|
||||
Lobby
|
||||
</Text>
|
||||
</Box>
|
||||
)}
|
||||
</Box>
|
||||
</NavItemContent>
|
||||
</NavLink>
|
||||
@@ -766,13 +772,18 @@ export function Space() {
|
||||
<NavLink to={getSpaceSearchPath(getCanonicalAliasOrRoomId(mx, space.roomId))}>
|
||||
<NavItemContent>
|
||||
<Box as="span" grow="Yes" alignItems="Center" gap="200">
|
||||
<Avatar size="200" radii="400">
|
||||
<Avatar
|
||||
radii="400"
|
||||
style={hideText ? { width: '100%' } : { height: '100%' }}
|
||||
>
|
||||
<Icon src={Icons.Search} size="100" filled={searchSelected} />
|
||||
</Avatar>
|
||||
<Box as="span" grow="Yes">
|
||||
<Text as="span" size="Inherit" truncate>
|
||||
Message Search
|
||||
</Text>
|
||||
{!hideText && (
|
||||
<Text as="span" size="Inherit" truncate>
|
||||
Message Search
|
||||
</Text>
|
||||
)}
|
||||
</Box>
|
||||
</Box>
|
||||
</NavItemContent>
|
||||
@@ -801,14 +812,19 @@ export function Space() {
|
||||
ref={virtualizer.measureElement}
|
||||
>
|
||||
<div
|
||||
style={{
|
||||
paddingLeft: `calc(${renderDepth} * ${config.space.S400})`,
|
||||
}}
|
||||
style={
|
||||
hideText
|
||||
? {}
|
||||
: {
|
||||
paddingLeft: `calc(${renderDepth} * ${config.space.S400})`,
|
||||
}
|
||||
}
|
||||
>
|
||||
<SpaceNavItem
|
||||
room={room}
|
||||
selected={selectedRoomId === roomId}
|
||||
linkPath={getSpaceLobbyPath(getCanonicalAliasOrRoomId(mx, roomId))}
|
||||
hideText={hideText}
|
||||
/>
|
||||
</div>
|
||||
</VirtualTile>
|
||||
@@ -828,14 +844,14 @@ export function Space() {
|
||||
key={vItem.index}
|
||||
ref={virtualizer.measureElement}
|
||||
>
|
||||
<div style={{ paddingTop, paddingLeft }}>
|
||||
<NavCategoryHeader>
|
||||
<div style={hideText ? {} : { paddingTop, paddingLeft }}>
|
||||
<NavCategoryHeader style={hideText ? { justifyContent: 'Center' } : {}}>
|
||||
<RoomNavCategoryButton
|
||||
data-category-id={categoryId}
|
||||
onClick={handleCategoryClick}
|
||||
closed={closedCategories.has(categoryId) || closedViaCategory}
|
||||
>
|
||||
{roomId === space.roomId ? 'Rooms' : room?.name}
|
||||
{!hideText && (roomId === space.roomId ? 'Rooms' : room?.name)}
|
||||
</RoomNavCategoryButton>
|
||||
</NavCategoryHeader>
|
||||
</div>
|
||||
@@ -849,13 +865,25 @@ export function Space() {
|
||||
key={vItem.index}
|
||||
ref={virtualizer.measureElement}
|
||||
>
|
||||
<div style={{ paddingLeft }}>
|
||||
<div
|
||||
style={
|
||||
hideText
|
||||
? {
|
||||
padding: '0',
|
||||
width: '100%',
|
||||
aspectRatio: 1,
|
||||
display: 'flex,',
|
||||
}
|
||||
: { paddingLeft }
|
||||
}
|
||||
>
|
||||
<RoomNavItem
|
||||
room={room}
|
||||
selected={selectedRoomId === roomId}
|
||||
showAvatar={mDirects.has(roomId) || showIcons()}
|
||||
direct={mDirects.has(roomId)}
|
||||
linkPath={getToLink(roomId)}
|
||||
hideText={hideText}
|
||||
notificationMode={getRoomNotificationMode(
|
||||
notificationPreferences,
|
||||
room.roomId
|
||||
|
||||
Reference in new issue
Block a user