Skip to content

Commit

Permalink
fix: page title id and user list picker demo
Browse files Browse the repository at this point in the history
  • Loading branch information
devharris7 committed Apr 12, 2021
1 parent d38a77f commit f042937
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 4 deletions.
7 changes: 6 additions & 1 deletion src/components/Avatar/index.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import _ from 'lodash';
import classnames from 'classnames';
import React from 'react';
import PropTypes from 'prop-types';
import './styles.scss';
Expand All @@ -7,7 +8,11 @@ const baseClass = 'avatar-component';
const Avatar = ({ color, givenName, tooltip, image, surname }) => (
<div
data-testid="avatar-wrapper"
className={color ? `${baseClass} ${baseClass}-${color}` : baseClass}
className={classnames([
baseClass,
{ [`${baseClass}-${color}`]: color && !image },
{ [`${baseClass}-image-placeholder`]: image },
])}
title={tooltip !== undefined ? tooltip : `${givenName || ''} ${surname || ''}`}
>
{image ? <img data-testid="avatar-image" className={`${baseClass}-image`} src={image} alt="presentation" /> : null}
Expand Down
5 changes: 5 additions & 0 deletions src/components/Avatar/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,14 @@ $diameter: 35px;
vertical-align: middle;
width: $diameter;

&-image-placeholder {
background-color: transparent;
}

&-image {
border-radius: $border-radius-circle;
height: 100%;
width: 100%;
left: 0;
position: absolute;
top: 0;
Expand Down
2 changes: 1 addition & 1 deletion src/components/PageTitle/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const baseClass = 'pagetitle-component';
const PageTitle = ({ children, isFooter, title }) => {
const className = classnames(baseClass, { [`${baseClass}-is-footer`]: isFooter });
return (
<div data-testid="page-title-wrapper" className={className} id={_.kebabCase(title)}>
<div data-testid="page-title-wrapper" className={className} id={_.isString(title) ? _.kebabCase(title) : 'title'}>
{children ? (
<span data-testid="page-title-inline" className="flexible-wrapper-inline">
{title}
Expand Down
Binary file added www/assets/user-avatar.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions www/examples/UserListPicker.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import DesignNotes from '../containers/DesignNotes.jsx';
## User List Picker

```jsx live=true
const avatarColor = () => 'cyan';
const avatarColor = user => (user.avatar ? '' : 'cyan');
const emptySvgSymbol = <SvgSymbol href="./assets/svg-symbols.svg#checklist-incomplete" />;
const teamMember1 = {
avatar: '//lorempixel.com/35/35/people/7',
avatar: '../assets/user-avatar.jpeg',
givenName: 'John',
id: 1,
surname: 'Smith',
Expand Down

0 comments on commit f042937

Please sign in to comment.