diff --git a/packages/core-components/src/components/Avatar/Avatar.stories.tsx b/packages/core-components/src/components/Avatar/Avatar.stories.tsx
index 59f2fb6cfa..dc0f7c00e7 100644
--- a/packages/core-components/src/components/Avatar/Avatar.stories.tsx
+++ b/packages/core-components/src/components/Avatar/Avatar.stories.tsx
@@ -16,6 +16,15 @@
import React from 'react';
import { Avatar } from './Avatar';
+import { makeStyles } from '@material-ui/core/styles';
+
+const useStyles = makeStyles({
+ avatar: {
+ width: '24px',
+ height: '24px',
+ fontSize: '8px',
+ },
+});
export default {
title: 'Data Display/Avatar',
@@ -34,9 +43,7 @@ export const NameFallback = () => ;
export const Empty = () => ;
-export const CustomStyling = () => (
-
-);
+export const CustomStyling = () => {
+ const classes = useStyles();
+ return ;
+};
diff --git a/packages/core-components/src/components/Avatar/Avatar.tsx b/packages/core-components/src/components/Avatar/Avatar.tsx
index 148d455312..7f33caba1f 100644
--- a/packages/core-components/src/components/Avatar/Avatar.tsx
+++ b/packages/core-components/src/components/Avatar/Avatar.tsx
@@ -21,32 +21,23 @@ import React, { CSSProperties } from 'react';
import { extractInitials, stringToColor } from './utils';
/** @public */
-export type AvatarClassKey = 'avatar';
+export type AvatarClassKey = 'avatar' | 'avatarText';
-const useStyles = ({
- styles,
- fontStyles,
-}: {
- styles: CSSProperties;
- fontStyles: CSSProperties;
-}) =>
- makeStyles(
- (theme: Theme) => ({
- avatar: {
- width: '4rem',
- height: '4rem',
- color: theme.palette.common.white,
- ...styles,
- },
- avatarText: {
- fontWeight: theme.typography.fontWeightBold,
- letterSpacing: '1px',
- textTransform: 'uppercase',
- ...fontStyles,
- },
- }),
- { name: 'BackstageAvatar' },
- )();
+const useStyles = makeStyles(
+ (theme: Theme) => ({
+ avatar: {
+ width: '4rem',
+ height: '4rem',
+ color: theme.palette.common.white,
+ },
+ avatarText: {
+ fontWeight: theme.typography.fontWeightBold,
+ letterSpacing: '1px',
+ textTransform: 'uppercase',
+ },
+ }),
+ { name: 'BackstageAvatar' },
+);
/**
* Properties for {@link Avatar}.
@@ -64,8 +55,14 @@ export interface AvatarProps {
picture?: string;
/**
* Custom styles applied to avatar
+ * @deprecated - use the classes property instead
*/
customStyles?: CSSProperties;
+
+ /**
+ * Custom styles applied to avatar
+ */
+ classes?: { [key in AvatarClassKey]?: string };
}
/**
@@ -78,32 +75,36 @@ export interface AvatarProps {
*/
export function Avatar(props: AvatarProps) {
const { displayName, picture, customStyles } = props;
- let styles = { ...customStyles };
- // We only calculate the background color if there's not an avatar
- // picture. If there is a picture, it might have a transparent
- // background and we don't know whether the calculated background
- // color will clash.
- if (!picture) {
- styles = {
- backgroundColor: stringToColor(displayName || ''),
- ...customStyles,
- };
- }
+ const styles = { ...customStyles };
+
+ // TODO: Remove this with the customStyles deprecation
const fontStyles = {
fontFamily: styles.fontFamily,
fontSize: styles.fontSize,
fontWeight: styles.fontWeight,
};
- const classes = useStyles({ styles, fontStyles });
+ // We only calculate the background color if there's not an avatar
+ // picture. If there is a picture, it might have a transparent
+ // background and we don't know whether the calculated background
+ // color will clash.
+ const classes = useStyles(
+ !picture ? { backgroundColor: stringToColor(displayName || '') } : {},
+ );
return (
-
+
{displayName && (
{extractInitials(displayName)}
diff --git a/plugins/azure-devops/src/components/PullRequestsPage/lib/PullRequestCard/PullRequestCard.tsx b/plugins/azure-devops/src/components/PullRequestsPage/lib/PullRequestCard/PullRequestCard.tsx
index dd9fff86b5..fb5d9acd99 100644
--- a/plugins/azure-devops/src/components/PullRequestsPage/lib/PullRequestCard/PullRequestCard.tsx
+++ b/plugins/azure-devops/src/components/PullRequestsPage/lib/PullRequestCard/PullRequestCard.tsx
@@ -51,6 +51,8 @@ const useStyles = makeStyles(
policies: {
flex: 1,
},
+ avatar: { width: '2.5rem', height: '2.5rem' },
+ avatarText: { fontSize: '1rem' },
}),
{ name: 'PullRequestCard' },
);
@@ -64,6 +66,8 @@ export const PullRequestCard = ({
pullRequest,
simplified,
}: PullRequestCardProps) => {
+ const classes = useStyles();
+
const title = (
{pullRequest.title}
@@ -90,12 +94,10 @@ export const PullRequestCard = ({
);
- const classes = useStyles();
-
return (
(
-
+ },
+ avatarText: {
+ fontSize: '1rem',
+ },
+ },
+ { name: 'PullRequestCardReviewer' },
);
+
+export const PullRequestCardReviewer = ({
+ reviewer,
+}: PullRequestCardReviewerProps) => {
+ const classes = useStyles();
+
+ return (
+
+ );
+};
diff --git a/plugins/bazaar/src/components/CardContentFields/CardContentFields.tsx b/plugins/bazaar/src/components/CardContentFields/CardContentFields.tsx
index 247a1f6011..40f8a51044 100644
--- a/plugins/bazaar/src/components/CardContentFields/CardContentFields.tsx
+++ b/plugins/bazaar/src/components/CardContentFields/CardContentFields.tsx
@@ -19,6 +19,8 @@ import Grid from '@material-ui/core/Grid';
import Card from '@material-ui/core/Card';
import CardContent from '@material-ui/core/CardContent';
import Typography from '@material-ui/core/Typography';
+import makeStyles from '@material-ui/core/styles/makeStyles';
+
import { GridSize } from '@material-ui/core/Grid';
import { parseEntityRef } from '@backstage/catalog-model';
import { Avatar, Link } from '@backstage/core-components';
@@ -35,6 +37,25 @@ type Props = {
membersSize: GridSize;
};
+const useStyles = makeStyles(
+ {
+ avatar: {
+ width: '19px',
+ height: '19px',
+ float: 'left',
+ marginRight: '0.3rem',
+ marginTop: '0rem',
+ marginBottom: '0rem',
+ alignItems: 'left',
+ },
+ avatarText: {
+ fontSize: '8px',
+ textAlign: 'left',
+ },
+ },
+ { name: 'CardContentFields' },
+);
+
export const CardContentFields = ({
bazaarProject,
members,
@@ -42,7 +63,7 @@ export const CardContentFields = ({
membersSize,
}: Props) => {
const catalogEntityRoute = useRouteRef(entityRouteRef);
-
+ const classes = useStyles();
return (
@@ -84,17 +105,7 @@ export const CardContentFields = ({
>
- createStyles({
- card: {
- border: `1px solid ${theme.palette.divider}`,
- boxShadow: theme.shadows[2],
- borderRadius: '4px',
- overflow: 'visible',
- position: 'relative',
- margin: theme.spacing(4, 1, 1),
- flex: '1',
- minWidth: '0px',
- },
- }),
+const useStyles = makeStyles(
+ (theme: Theme) =>
+ createStyles({
+ card: {
+ border: `1px solid ${theme.palette.divider}`,
+ boxShadow: theme.shadows[2],
+ borderRadius: '4px',
+ overflow: 'visible',
+ position: 'relative',
+ margin: theme.spacing(4, 1, 1),
+ flex: '1',
+ minWidth: '0px',
+ },
+ avatar: {
+ position: 'absolute',
+ top: '-2rem',
+ },
+ }),
+ { name: 'MembersListCardComponent' },
);
const MemberComponent = (props: { member: UserEntity }) => {
@@ -84,10 +90,7 @@ const MemberComponent = (props: { member: UserEntity }) => {