Skip to content
Snippets Groups Projects
Unverified Commit 960de4fb authored by Samuel Couillard's avatar Samuel Couillard Committed by GitHub
Browse files

Add size class for Avatar and RoundPlaceholder (#4539)

parent d506e5ef
No related branches found
No related tags found
No related merge requests found
Showing
with 43 additions and 41 deletions
...@@ -553,7 +553,6 @@ input[type="range"]:focus::-moz-range-thumb { ...@@ -553,7 +553,6 @@ input[type="range"]:focus::-moz-range-thumb {
} }
} }
// Table Placeholders length // Table Placeholders length
.sm-td-placeholder { .sm-td-placeholder {
min-width: 100px; min-width: 100px;
...@@ -570,3 +569,19 @@ input[type="range"]:focus::-moz-range-thumb { ...@@ -570,3 +569,19 @@ input[type="range"]:focus::-moz-range-thumb {
.xl-td-placeholder { .xl-td-placeholder {
min-width: 300px; min-width: 300px;
} }
// Circles & Avatars
.small-circle {
width: 40px;
height: 40px;
}
.medium-circle {
width: 100px;
height: 100px;
}
.large-circle {
width: 150px;
height: 150px;
}
...@@ -22,7 +22,7 @@ export default function BannedPendingRow({ user, pendingTable }) { ...@@ -22,7 +22,7 @@ export default function BannedPendingRow({ user, pendingTable }) {
<td className="border-end-0"> <td className="border-end-0">
<Stack direction="horizontal"> <Stack direction="horizontal">
<div className="me-2"> <div className="me-2">
<Avatar avatar={user.avatar} radius={40} /> <Avatar avatar={user.avatar} size="small" />
</div> </div>
<Stack> <Stack>
<span className="text-dark fw-bold"> {user.name} </span> <span className="text-dark fw-bold"> {user.name} </span>
......
...@@ -27,7 +27,7 @@ export default function ManageUserRow({ user }) { ...@@ -27,7 +27,7 @@ export default function ManageUserRow({ user }) {
<td className="border-end-0"> <td className="border-end-0">
<Stack direction="horizontal"> <Stack direction="horizontal">
<div className="me-2"> <div className="me-2">
<Avatar avatar={user.avatar} radius={40} /> <Avatar avatar={user.avatar} size="small" />
</div> </div>
<Stack> <Stack>
<span className="text-dark fw-bold"> {user.name} </span> <span className="text-dark fw-bold"> {user.name} </span>
......
...@@ -155,7 +155,7 @@ export default function RoomJoin() { ...@@ -155,7 +155,7 @@ export default function RoomJoin() {
</Col> </Col>
<Col> <Col>
<Stack direction="vertical" gap={3}> <Stack direction="vertical" gap={3}>
<Avatar className="d-block ms-auto me-auto" avatar={publicRoom?.data.owner_avatar} radius={100} /> <Avatar className="d-block ms-auto me-auto" avatar={publicRoom?.data.owner_avatar} size="medium" />
<h5 className="text-center">{publicRoom?.data.owner_name}</h5> <h5 className="text-center">{publicRoom?.data.owner_name}</h5>
</Stack> </Stack>
</Col> </Col>
......
...@@ -51,7 +51,7 @@ export default function SharedAccess() { ...@@ -51,7 +51,7 @@ export default function SharedAccess() {
<tr key={user.id} className="align-middle"> <tr key={user.id} className="align-middle">
<td> <td>
<Stack direction="horizontal" className="py-2"> <Stack direction="horizontal" className="py-2">
<Avatar avatar={user.avatar} radius={40} /> <Avatar avatar={user.avatar} size="small" />
<h6 className="text-brand mb-0 ps-3"> {user.name} </h6> <h6 className="text-brand mb-0 ps-3"> {user.name} </h6>
</Stack> </Stack>
</td> </td>
......
...@@ -55,7 +55,7 @@ export default function SharedAccessList({ users }) { ...@@ -55,7 +55,7 @@ export default function SharedAccessList({ users }) {
<Row className="border-bottom py-3" key={user.id}> <Row className="border-bottom py-3" key={user.id}>
<Col> <Col>
<Stack direction="horizontal"> <Stack direction="horizontal">
<Avatar avatar={user.avatar} radius={40} /> <Avatar avatar={user.avatar} size="small" />
<h6 className="text-brand mb-0 ps-3"> {user.name} </h6> <h6 className="text-brand mb-0 ps-3"> {user.name} </h6>
</Stack> </Stack>
</Col> </Col>
......
...@@ -48,7 +48,7 @@ export default function SharedAccessForm({ handleClose }) { ...@@ -48,7 +48,7 @@ export default function SharedAccessForm({ handleClose }) {
className="pe-3" className="pe-3"
{...register('shared_users')} {...register('shared_users')}
/> />
<Avatar avatar={user.avatar} radius={40} /> <Avatar avatar={user.avatar} size="small" />
<h6 className="text-brand mb-0 ps-3"> {user.name} </h6> <h6 className="text-brand mb-0 ps-3"> {user.name} </h6>
</Stack> </Stack>
</td> </td>
......
...@@ -47,7 +47,7 @@ export default function Header() { ...@@ -47,7 +47,7 @@ export default function Header() {
</Navbar.Brand> </Navbar.Brand>
<Navbar.Toggle aria-controls="responsive-navbar-nav" className="border-0"> <Navbar.Toggle aria-controls="responsive-navbar-nav" className="border-0">
<Avatar avatar={currentUser?.avatar} radius={40} /> <Avatar avatar={currentUser?.avatar} size="small" />
</Navbar.Toggle> </Navbar.Toggle>
{/* /!* Visible only on mobile *!/ */} {/* /!* Visible only on mobile *!/ */}
...@@ -78,7 +78,7 @@ export default function Header() { ...@@ -78,7 +78,7 @@ export default function Header() {
{/* Not visible on mobile */} {/* Not visible on mobile */}
<div className="justify-content-end d-none d-sm-block"> <div className="justify-content-end d-none d-sm-block">
<div className="d-inline-block"> <div className="d-inline-block">
<Avatar avatar={currentUser?.avatar} radius={40} /> <Avatar avatar={currentUser?.avatar} size="small" />
</div> </div>
<NavDropdown title={currentUser?.name} id="nav-user-dropdown" className="d-inline-block" align="end"> <NavDropdown title={currentUser?.name} id="nav-user-dropdown" className="d-inline-block" align="end">
<NavDropdown.Item as={Link} to="/profile"> <NavDropdown.Item as={Link} to="/profile">
......
/* eslint-disable react/jsx-props-no-spreading */
import React from 'react'; import React from 'react';
import { Placeholder as BootstrapPlaceholder } from 'react-bootstrap'; import { Placeholder as BootstrapPlaceholder } from 'react-bootstrap';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
export default function Placeholder({ width, size, className }) { export default function Placeholder({ width, size, ...props }) {
return ( return (
<BootstrapPlaceholder className="ps-0" animation="glow"> <BootstrapPlaceholder className="ps-0" animation="glow">
<BootstrapPlaceholder xs={width} size={size} className={className} bg="secondary" /> <BootstrapPlaceholder xs={width} size={size} bg="secondary" {...props} />
</BootstrapPlaceholder> </BootstrapPlaceholder>
); );
} }
...@@ -13,9 +14,4 @@ export default function Placeholder({ width, size, className }) { ...@@ -13,9 +14,4 @@ export default function Placeholder({ width, size, className }) {
Placeholder.propTypes = { Placeholder.propTypes = {
width: PropTypes.number.isRequired, width: PropTypes.number.isRequired,
size: PropTypes.string.isRequired, size: PropTypes.string.isRequired,
className: PropTypes.string,
};
Placeholder.defaultProps = {
className: '',
}; };
/* eslint-disable react/jsx-props-no-spreading */
import React from 'react'; import React from 'react';
import { Placeholder } from 'react-bootstrap'; import { Placeholder } from 'react-bootstrap';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
export default function RoundPlaceholder({ radius, className }) { export default function RoundPlaceholder({ size, ...props }) {
const circleClass = `rounded-circle ${size}-circle`;
return ( return (
<Placeholder animation="glow"> <Placeholder animation="glow">
<Placeholder style={{ height: radius, width: radius, borderRadius: '50%' }} className={className} bg="secondary" /> <Placeholder className={circleClass} bg="secondary" {...props} />
</Placeholder> </Placeholder>
); );
} }
RoundPlaceholder.propTypes = { RoundPlaceholder.propTypes = {
radius: PropTypes.number.isRequired, size: PropTypes.string.isRequired,
className: PropTypes.string,
};
RoundPlaceholder.defaultProps = {
className: '',
}; };
/* eslint-disable react/jsx-props-no-spreading */
/* eslint-disable react/jsx-no-bind */ /* eslint-disable react/jsx-no-bind */
import React, { useState } from 'react'; import React, { useState } from 'react';
import Image from 'react-bootstrap/Image'; import Image from 'react-bootstrap/Image';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import { Placeholder } from 'react-bootstrap'; import RoundPlaceholder from '../../shared_components/utilities/RoundPlaceholder';
export default function Avatar({ avatar, radius, className }) { export default function Avatar({ avatar, size, ...props }) {
const [isLoaded, setIsLoaded] = useState(false); const [isLoaded, setIsLoaded] = useState(false);
const avatarSizeClass = `${size}-circle`;
function onLoad() { function onLoad() {
setIsLoaded(true); setIsLoaded(true);
} }
return ( return (
<> <div {...props}>
<Image <Image
src={avatar} src={avatar}
roundedCircle="true" roundedCircle="true"
width={radius} className={avatarSizeClass}
height={radius}
className={className}
style={{ display: isLoaded ? '' : 'none' }} style={{ display: isLoaded ? '' : 'none' }}
onLoad={onLoad} onLoad={onLoad}
/> />
{!isLoaded && ( {!isLoaded && (
<Placeholder animation="glow" className="mb-3"> <RoundPlaceholder size={size} />
<Placeholder style={{ height: radius, width: radius, borderRadius: '50%' }} />
</Placeholder>
)} )}
</> </div>
); );
} }
Avatar.propTypes = { Avatar.propTypes = {
avatar: PropTypes.string.isRequired, avatar: PropTypes.string.isRequired,
radius: PropTypes.number.isRequired, size: PropTypes.string.isRequired,
className: PropTypes.string,
};
Avatar.defaultProps = {
className: '',
}; };
...@@ -48,7 +48,7 @@ export default function SetAvatar({ user }) { ...@@ -48,7 +48,7 @@ export default function SetAvatar({ user }) {
<div className="avatar-icon-circle float-end position-absolute rounded-circle"> <div className="avatar-icon-circle float-end position-absolute rounded-circle">
<FolderPlusIcon className="hi-s" /> <FolderPlusIcon className="hi-s" />
</div> </div>
<Avatar avatar={user?.avatar} radius={150} /> <Avatar avatar={user?.avatar} size="large" />
</div> </div>
<input <input
id="avatarUpload" id="avatarUpload"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment