Merge branch 'ajbura:dev' into profile-editor

This commit is contained in:
James Julich 2021-09-12 22:41:42 -05:00 committed by GitHub
commit 95bb0ac6d4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
39 changed files with 813 additions and 186 deletions

View file

@ -10,10 +10,12 @@ import NotificationBadge from '../../atoms/badge/NotificationBadge';
import { blurOnBubbling } from '../../atoms/button/script';
function RoomSelectorWrapper({
isSelected, onClick, content, options,
isSelected, isUnread, onClick, content, options,
}) {
let myClass = isUnread ? ' room-selector--unread' : '';
myClass += isSelected ? ' room-selector--selected' : '';
return (
<div className={`room-selector${isSelected ? ' room-selector--selected' : ''}`}>
<div className={`room-selector${myClass}`}>
<button
className="room-selector__content"
type="button"
@ -31,6 +33,7 @@ RoomSelectorWrapper.defaultProps = {
};
RoomSelectorWrapper.propTypes = {
isSelected: PropTypes.bool.isRequired,
isUnread: PropTypes.bool.isRequired,
onClick: PropTypes.func.isRequired,
content: PropTypes.node.isRequired,
options: PropTypes.node,
@ -44,6 +47,7 @@ function RoomSelector({
return (
<RoomSelectorWrapper
isSelected={isSelected}
isUnread={isUnread}
content={(
<>
<Avatar
@ -68,6 +72,7 @@ function RoomSelector({
);
}
RoomSelector.defaultProps = {
isSelected: false,
imageSrc: null,
iconSrc: null,
options: null,
@ -77,9 +82,12 @@ RoomSelector.propTypes = {
roomId: PropTypes.string.isRequired,
imageSrc: PropTypes.string,
iconSrc: PropTypes.string,
isSelected: PropTypes.bool.isRequired,
isSelected: PropTypes.bool,
isUnread: PropTypes.bool.isRequired,
notificationCount: PropTypes.number.isRequired,
notificationCount: PropTypes.oneOfType([
PropTypes.string,
PropTypes.number,
]).isRequired,
isAlert: PropTypes.bool.isRequired,
options: PropTypes.node,
onClick: PropTypes.func.isRequired,

View file

@ -14,6 +14,13 @@
border: 1px solid transparent;
border-radius: var(--bo-radius);
cursor: pointer;
&--unread {
.room-selector__content > .text {
font-weight: 500;
color: var(--tc-surface-high);
}
}
&--selected {
background-color: var(--bg-surface);

View file

@ -2,29 +2,22 @@ import React from 'react';
import PropTypes from 'prop-types';
import './SidebarAvatar.scss';
import Tippy from '@tippyjs/react';
import Avatar from '../../atoms/avatar/Avatar';
import Text from '../../atoms/text/Text';
import Tooltip from '../../atoms/tooltip/Tooltip';
import NotificationBadge from '../../atoms/badge/NotificationBadge';
import { blurOnBubbling } from '../../atoms/button/script';
const SidebarAvatar = React.forwardRef(({
tooltip, text, bgColor, imageSrc,
iconSrc, active, onClick, notifyCount,
iconSrc, active, onClick, isUnread, notificationCount, isAlert,
}, ref) => {
let activeClass = '';
if (active) activeClass = ' sidebar-avatar--active';
return (
<Tippy
<Tooltip
content={<Text variant="b1">{tooltip}</Text>}
className="sidebar-avatar-tippy"
touch="hold"
arrow={false}
placement="right"
maxWidth={200}
delay={[0, 0]}
duration={[100, 0]}
offset={[0, 0]}
>
<button
ref={ref}
@ -40,9 +33,14 @@ const SidebarAvatar = React.forwardRef(({
iconSrc={iconSrc}
size="normal"
/>
{ notifyCount !== null && <NotificationBadge alert content={notifyCount} /> }
{ isUnread && (
<NotificationBadge
alert={isAlert}
content={notificationCount !== 0 ? notificationCount : null}
/>
)}
</button>
</Tippy>
</Tooltip>
);
});
SidebarAvatar.defaultProps = {
@ -52,7 +50,9 @@ SidebarAvatar.defaultProps = {
imageSrc: null,
active: false,
onClick: null,
notifyCount: null,
isUnread: false,
notificationCount: 0,
isAlert: false,
};
SidebarAvatar.propTypes = {
@ -63,10 +63,12 @@ SidebarAvatar.propTypes = {
iconSrc: PropTypes.string,
active: PropTypes.bool,
onClick: PropTypes.func,
notifyCount: PropTypes.oneOfType([
isUnread: PropTypes.bool,
notificationCount: PropTypes.oneOfType([
PropTypes.string,
PropTypes.number,
]),
isAlert: PropTypes.bool,
};
export default SidebarAvatar;

View file

@ -1,28 +1,18 @@
.sidebar-avatar-tippy {
padding: var(--sp-extra-tight) var(--sp-normal);
background-color: var(--bg-tooltip);
border-radius: var(--bo-radius);
box-shadow: var(--bs-popup);
.text {
color: var(--tc-tooltip);
}
}
.sidebar-avatar {
position: relative;
display: flex;
justify-content: center;
align-items: center;
width: 100%;
cursor: pointer;
& .notification-badge {
position: absolute;
right: var(--sp-extra-tight);
top: calc(-1 * var(--sp-ultra-tight));
right: 0;
top: 0;
box-shadow: 0 0 0 2px var(--bg-surface-low);
transform: translate(20%, -20%);
margin: 0 !important;
}
&:focus {
outline: none;
@ -37,7 +27,7 @@
content: "";
display: block;
position: absolute;
left: 0;
left: -11px;
top: 50%;
transform: translateY(-50%);
@ -48,7 +38,8 @@
transition: height 200ms linear;
[dir=rtl] & {
right: 0;
left: unset;
right: -11px;
border-radius: 4px 0 0 4px;
}
}