Skip to content
This repository has been archived by the owner on May 24, 2024. It is now read-only.

[terra-avatar] Changed Shared user variant to Generic Avatar variant #2620

Merged
merged 25 commits into from
Mar 28, 2020
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
aac0063
Changed Shared user to Generic Avatar Varaint
supreethmr Aug 29, 2019
c7d376e
Added upgrade Guide for Breaking Changes
supreethmr Aug 30, 2019
5f17135
Upgrade Guide Corrections
supreethmr Aug 30, 2019
4a470cf
export added for constants
supreethmr Sep 3, 2019
07b365e
mergeconflicts
supreethmr Sep 5, 2019
71741fd
Changed Examples for Generic Icon
supreethmr Sep 5, 2019
b30d6b9
Merge branch 'master' into Avatar-Provider-Variant
supreethmr Sep 9, 2019
881586c
Updating documentation for Generic variant
supreethmr Sep 10, 2019
8a3b15f
Merge branch 'master' into Avatar-Provider-Variant
supreethmr Sep 16, 2019
8c90d71
Merge branch 'master' into Avatar-Provider-Variant
supreethmr Sep 19, 2019
c4a3798
Merge branch 'master' into Avatar-Provider-Variant
supreethmr Sep 23, 2019
f944aab
Merge branch 'master' into Avatar-Provider-Variant
supreethmr Oct 4, 2019
4efa018
Merge branch 'master' into Avatar-Provider-Variant
mjhenkes Oct 8, 2019
10260c7
Update packages/terra-avatar/CHANGELOG.md
supreethmr Oct 10, 2019
bee5afb
Merge branch 'master' into Avatar-Provider-Variant
supreethmr Oct 16, 2019
c03aa55
removed theme variables update from upgrade guide
supreethmr Oct 16, 2019
5d5682b
Added user Icon example in upgrade guide
supreethmr Oct 16, 2019
128dd37
updated changelogs and upgrade guide
supreethmr Oct 25, 2019
8b523a7
corrections to changelog and upgradeguide
supreethmr Oct 25, 2019
e921aca
Merge branch 'master' into Avatar-Provider-Variant
ryanthemanuel Oct 28, 2019
5c4d57f
Merge branch 'master' into Avatar-Provider-Variant
supreethmr Nov 4, 2019
4da2553
Update CONTRIBUTORS.md
jeremyfuksa Nov 4, 2019
0990768
Merge remote-tracking branch 'origin/master' into Avatar-Provider-Var…
rm012685 Mar 27, 2020
c5d1843
Merge branch 'master' into Avatar-Provider-Variant
ryanthemanuel Mar 27, 2020
46c15fe
Update screenshots
rm012685 Mar 28, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions packages/terra-avatar/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ ChangeLog

Unreleased
----------
### Breaking Changes
* `generic` subcomponent replaces the `sharedUser` subcomponent
* `generic` subcomponent contains a `variant` prop that toggles between `single-user`, `shared-user`, and `provider`.

2.29.0 - (October 3, 2019)
------------------
Expand Down
8 changes: 4 additions & 4 deletions packages/terra-avatar/docs/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# About terra-avatar

The `terra-avatar` package contains three components: `Avatar`, `Facility`, and `SharedUser`. View their respective documentation tabs for information on accepted props and examples.
The `terra-avatar` package contains three components: `Avatar`, `Facility`, and `Generic`. View their respective documentation tabs for information on accepted props and examples.

## Getting Started

Expand All @@ -25,7 +25,7 @@ This component requires the following peer dependencies be installed in your app

```jsx
import React from 'react';
import Avatar, { Facility, SharedUser } from 'terra-avatar';
import Avatar, { Facility, Generic } from 'terra-avatar';

<Avatar
alt="User"
Expand All @@ -37,8 +37,8 @@ import Avatar, { Facility, SharedUser } from 'terra-avatar';
image="https://path/to/image.jpg"
/>

<SharedUser
alt="Shared-User"
<Generic
alt="Generic"
/>
```

Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
# Shared User
# Generic

The `SharedUser` variant represents multiple users - it displays a shared user icon in a circular frame.
The `Generic` variant toggles between different, generic persons - `single-user`, `shared-user`, or `provider`.

## Getting Started

- Install with [npmjs](https://www.npmjs.com):
- `npm install terra-avatar`

## Usage

```jsx
import React from 'react';
import { SharedUser } from 'terra-avatar';
import { Generic } from 'terra-avatar';

<SharedUser
alt="shared users"
<Generic
alt="Generic Users"
/>
```

Expand Down
33 changes: 33 additions & 0 deletions packages/terra-avatar/docs/upgrade-guide.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,36 @@
# terra-avatar Upgrade Guide
## Changes from version 2 to version 3

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ryanthemanuel, do we want to add a 'Reason for change' section? If so, what should it say?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1. We should add that in the upgrade guide as well as the change log.

### Removed
* `Shared User` subcomponent From Avatar

### Added
* the `generic` subcomponent that replaces the `sharedUser` subcomponent with a new `variant` prop that can be `single-user`, `shared-user`, or `provider`.
* `variant` prop this will take values for sub-variants `single-user`, `shared-user` and `provider`.

### Changes to CSS Custom Properties
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do not include changes to css custom properties in the upgrade guide. This is an implementation detail now.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we add this to README.md..?


#### Added
* --terra-avatar-icon-provider-background-image

### Steps to uplift to V3
1. Use a named export for Generic variant.
2. Use variant prop of Generic to set sub-variant icons like `single-user`, `shared-user` and `provider` for Avatar.

#### V2 Code
```javascript
import { SharedUser} from 'terra-avatar';

<SharedUser alt="Patient 1" />
```

#### V3 Code
```javascript
import { Generic } from 'terra-avatar'

<Generic variant="shared-user" alt="Patient 1" />
```

## Changes from version 1 to version 2

### Props
Expand Down Expand Up @@ -84,3 +116,4 @@ import Avatar, { Facility } from 'terra-avatar'
<Avatar alt="Patient 1" initials="AA" />
<Facility alt="Location 1" />
```

2 changes: 1 addition & 1 deletion packages/terra-avatar/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "terra-avatar",
"main": "lib/index.js",
"version": "2.29.0",
"description": "Contains components that represent a person, location or entity. Variants include Avatar, Facility, and SharedUser.",
"description": "Contains components that represent a person, location or entity. Variants include Avatar, Facility, and Generic.",
"repository": {
"type": "git",
"url": "git+https://github.com/cerner/terra-core.git"
Expand Down
6 changes: 6 additions & 0 deletions packages/terra-avatar/src/common/Avatar.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@
height: 100%;
width: 100%;
}

&.provider {
background-image: var(--terra-avatar-icon-provider-background-image, inline-svg("<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 48 48'><path fill='#fff' d='M24 28.9c4.7 0 8.5-3.8 8.5-8.5s-3.8-8.5-8.5-8.5-8.5 3.8-8.5 8.5 3.8 8.5 8.5 8.5zm6 2.9v4.4c0 .3.2.9.9 1.6.6.5.6 1.3.6 1.3v4.5c0 .4-.3.8-.8.8-.4 0-.8-.3-.8-.8v-5.2h-1.5v5.2c0 .4-.3.8-.8.8-.4 0-.8-.3-.8-.8V39s0-.8.6-1.3c.8-.6.9-1.2.9-1.6v-4.7c-.8-.2-1.6-.2-2.4-.2h-4.1c-.8 0-1.6.1-2.4.2v6.9c1.3.3 2.2 1.5 2.2 2.9 0 1.7-1.3 3-3 3s-3-1.3-3-3c0-1.4 1-2.6 2.2-2.9v-6.5c-5 1.7-8.6 6.4-8.6 11.9V48h29.3v-4.3c.1-5.5-3.5-10.2-8.5-11.9zm-12.8 9.4c0 .8.7 1.5 1.5 1.5s1.5-.7 1.5-1.5-.7-1.5-1.5-1.5-1.5.7-1.5 1.5z'/></svg>"));
height: 100%;
width: 100%;
}
/* stylelint-enable string-quotes */
}

Expand Down
2 changes: 1 addition & 1 deletion packages/terra-avatar/src/common/AvatarUtils.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const cx = classNames.bind(styles);
const AVATAR_VARIANTS = {
USER: 'user',
FACILITY: 'facility',
SHARED_USER: 'shared-user',
GENERIC: 'generic',
};

const COLOR_VARIANTS = [
Expand Down
4 changes: 2 additions & 2 deletions packages/terra-avatar/src/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Avatar from './variants/Avatar';
import Facility from './variants/Facility';
import SharedUser from './variants/SharedUser';
import Generic from './variants/Generic';

export default Avatar;
export { Facility, SharedUser };
export { Facility, Generic };
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import React from 'react';
import DocTemplate from 'terra-doc-template';
import ReadMe from '../../../../docs/generic.md';
import { name, version } from '../../../../package.json';

// Component Source
import GenericSrc from '!raw-loader!../../../../src/variants/Generic.jsx';
import GenericAvatarVariants from '../example/generic/GenericAvatarVariants';
import GenericAvatarVariantsSrc from '!raw-loader!../../../../src/terra-dev-site/doc/example/generic/GenericAvatarVariants';

const DocPage = () => (
<DocTemplate
packageName={name}
packageVersion={version}
readme={ReadMe}
srcPath={`https://github.com/cerner/terra-core/tree/master/packages/${name}`}
examples={[
{
title: 'Generic Avatar - Icons',
example: <GenericAvatarVariants />,
source: GenericAvatarVariantsSrc,
},
]}
propsTables={[
{
componentName: 'Generic',
componentSrc: GenericSrc,
},
]}
/>
);

export default DocPage;

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import React from 'react';
import PropTypes from 'prop-types';
import { Generic } from 'terra-avatar';
import GenericAvatarVariantsWrapper from 'terra-avatar/lib/terra-dev-site/doc/example/generic/GenericAvatarVariantsWrapper';

const propTypes = { color: PropTypes.string, size: PropTypes.string, variant: PropTypes.string };

const GenericAvatarVariants = ({
...props
}) => (
<Generic variant={props.variant} alt={props.variant} color={props.color} size={props.size} />
);

GenericAvatarVariants.propTypes = propTypes;
export default GenericAvatarVariantsWrapper(GenericAvatarVariants);
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import React from 'react';

function GenericAvatarVariantsWrapper(WrappedComponent) {
return class GenericVariants extends React.Component {
constructor(props) {
super(props);
this.handleOnSelect = this.handleOnSelect.bind(this);
this.state = { colorVariant: 'auto', size: undefined, variant: 'single-user' };
}

handleOnSelect(event) {
this.setState({ [event.target.name]: event.target.value });
}

render() {
return (
<div>
<WrappedComponent color={this.state.colorVariant} variant={this.state.variant} size={this.state.size} {...this.props} />
<p><label htmlFor="variant">Select a generic variant type:</label></p>
<select id="variant" name="variant" value={this.state.variant} onChange={this.handleOnSelect}>
<option value="single-user">Single-User</option>
<option value="shared-user">Shared-User</option>
<option value="provider">Provider</option>
</select>
<p><label htmlFor="colorVariant">Select a color variant:</label></p>
<select id="colorVariant" name="colorVariant" value={this.state.colorVariant} onChange={this.handleOnSelect}>
<option value="auto">Auto</option>
<option value="neutral">Neutral</option>
<option value="one">One</option>
<option value="two">Two</option>
<option value="three">Three</option>
<option value="four">Four</option>
<option value="five">Five</option>
<option value="six">Six</option>
<option value="seven">Seven</option>
<option value="eight">Eight</option>
<option value="nine">Nine</option>
<option value="ten">Ten</option>
</select>
<p><label htmlFor="size">Select a size:</label></p>
<select id="size" name="size" value={this.state.size} onChange={this.handleOnSelect}>
<option value="1em">Default</option>
<option value="2em">2em</option>
<option value="3em">3em</option>
</select>
</div>
);
}
};
}

export default GenericAvatarVariantsWrapper;

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import React from 'react';
import { Generic } from '../../../../index';

export default () => <Generic variant="provider" id="provider" alt="provider" color="seven" />;
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import React from 'react';
import { Generic } from '../../../../index';

export default () => <Generic id="shared-user" variant="shared-user" alt="shared user" color="eight" />;
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import React from 'react';
import { Generic } from '../../../../index';

export default () => <Generic id="single-user" alt="single user" color="four" />;

This file was deleted.

Loading