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 4 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
* Removed Shared User subcomponent
* Added Generic subcomponent with a new variant prop that can be `single-user`, `shared-user`, or `provider`.

2.25.0 - (August 21, 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 Down Expand Up @@ -28,7 +28,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 @@ -40,8 +40,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 represents multiple variants like `single-user`, `shared-user`, `provider` - it displays a specified variant user icon in a circular frame.

## 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`.
Copy link
Contributor

Choose a reason for hiding this comment

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

This is confusing to me as I understand that you are probably talking about the variant prop of Generic sub-component but at first glance, I felt this is in contradiction to what was mentioned earlier.

I'd remove this line altogether.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Replaced line with suggested line below..!


### 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="Location 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.25.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 @@ -58,6 +58,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,91 @@
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 SingleUser from '../example/generic/single-user/GenericSingleUser';
import SingleUserSrc from '!raw-loader!../../../../src/terra-dev-site/doc/example/generic/single-user/GenericSingleUser';
import SingleUserSize from '../example/generic/single-user/GenericSingleUserSize';
import SingleUserSizeSrc from '!raw-loader!../../../../src/terra-dev-site/doc/example/generic/single-user/GenericSingleUserSize';
import SingleUserColorVariants from '../example/generic/single-user/GenericSingleUserColorVariants';
import SingleUserColorVariantsSrc from '!raw-loader!../../../../src/terra-dev-site/doc/example/generic/single-user/GenericSingleUserColorVariants';

import SharedUser from '../example/generic/shared-user/GenericSharedUser';
import SharedUserSrc from '!raw-loader!../../../../src/terra-dev-site/doc/example/generic/shared-user/GenericSharedUser';
import SharedUserSize from '../example/generic/shared-user/GenericSharedUserSize';
import SharedUserSizeSrc from '!raw-loader!../../../../src/terra-dev-site/doc/example/generic/shared-user/GenericSharedUserSize';
import SharedUserColorVariants from '../example/generic/shared-user/GenericSharedUserColorVariants';
import SharedUserColorVariantsSrc from '!raw-loader!../../../../src/terra-dev-site/doc/example/generic/shared-user/GenericSharedUserColorVariants';

import Provider from '../example/generic/provider/Provider';
import ProviderSrc from '!raw-loader!../../../../src/terra-dev-site/doc/example/generic/provider/Provider';
import ProviderSize from '../example/generic/provider/ProviderSize';
import ProviderSizeSrc from '!raw-loader!../../../../src/terra-dev-site/doc/example/generic/provider/ProviderSize';
import ProviderColorVariants from '../example/generic/provider/ProviderColorVariants';
import ProviderColorVariantsSrc from '!raw-loader!../../../../src/terra-dev-site/doc/example/generic/provider/ProviderColorVariants';

const DocPage = () => (
<DocTemplate
packageName={name}
packageVersion={version}
readme={ReadMe}
srcPath={`https://github.com/cerner/terra-core/tree/master/packages/${name}`}
examples={[
{
title: 'Single User - Default',
example: <SingleUser />,
source: SingleUserSrc,
},
{
title: 'Single User - Override Size',
example: <SingleUserSize />,
source: SingleUserSizeSrc,
},
{
title: 'Single User - Toggle Color Variants - Theme Specific',
example: <SingleUserColorVariants />,
source: SingleUserColorVariantsSrc,
},
{
title: 'Shared User - Default',
example: <SharedUser />,
source: SharedUserSrc,
},
{
title: 'Shared User - Override Size',
example: <SharedUserSize />,
source: SharedUserSizeSrc,
},
{
title: 'Shared User - Toggle Color Variants - Theme Specific',
example: <SharedUserColorVariants />,
source: SharedUserColorVariantsSrc,
},
{
title: 'Provider - Default',
example: <Provider />,
source: ProviderSrc,
},
{
title: 'Provider - Override Size',
example: <ProviderSize />,
source: ProviderSizeSrc,
},
{
title: 'Provider - Toggle Color Variants - Theme Specific',
example: <ProviderColorVariants />,
source: ProviderColorVariantsSrc,
},
]}
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,8 @@
import React from 'react';
import { Generic } from 'terra-avatar';

const AvatarProvider = () => (
<Generic variant="provider" alt="Provider" />
);

export default AvatarProvider;
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 ColorVariantsWrapper from 'terra-avatar/lib/terra-dev-site/doc/example/common/ColorVariantsWrapper';

const propTypes = { color: PropTypes.string };

const GenericUserColorVariants = ({
...props
}) => (
<Generic variant="provider" alt="Provider" color={props.color} />
);

GenericUserColorVariants.propTypes = propTypes;
export default ColorVariantsWrapper(GenericUserColorVariants);
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import React from 'react';
import { Generic } from 'terra-avatar';

const AvatarSize = () => (
<Generic variant="provider" alt="Provider" size="2em" />
);

export default AvatarSize;
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React from 'react';
import { SharedUser } from 'terra-avatar';
import { Generic } from 'terra-avatar';

const AvatarSharedUser = () => (
<SharedUser alt="Shared User" />
<Generic variant="shared-user" alt="Shared User" />
);

export default AvatarSharedUser;
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 ColorVariantsWrapper from 'terra-avatar/lib/terra-dev-site/doc/example/common/ColorVariantsWrapper';

const propTypes = { color: PropTypes.string };

const GenericUserColorVariants = ({
...props
}) => (
<Generic variant="shared-user" alt="Shared User" color={props.color} />
);

GenericUserColorVariants.propTypes = propTypes;
export default ColorVariantsWrapper(GenericUserColorVariants);
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import React from 'react';
import { Generic } from 'terra-avatar';

const AvatarSize = () => (
<Generic variant="shared-user" alt="Shared User" size="2em" />
);

export default AvatarSize;
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import React from 'react';
import { Generic } from 'terra-avatar';

const AvatarSingleUser = () => (
<Generic variant="single-user" alt="Single User" />
);

export default AvatarSingleUser;
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 ColorVariantsWrapper from 'terra-avatar/lib/terra-dev-site/doc/example/common/ColorVariantsWrapper';

const propTypes = { color: PropTypes.string };

const GenericUserColorVariants = ({
...props
}) => (
<Generic variant="single-user" alt="Single User" color={props.color} />
);

GenericUserColorVariants.propTypes = propTypes;
export default ColorVariantsWrapper(GenericUserColorVariants);
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import React from 'react';
import { Generic } from 'terra-avatar';

const AvatarSize = () => (
<Generic variant="single-user" alt="Single User" size="2em" />
);

export default AvatarSize;
Loading