This repository has been archived by the owner on Aug 21, 2023. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
165 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<meta | ||
name="viewport" | ||
content="width=device-width, initial-scale=1, shrink-to-fit=no" | ||
/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import * as React from 'react' | ||
import { classNames } from '../../utilities/classNames' | ||
import { CropUI } from './Avatar.css' | ||
|
||
export const AvatarCrop = props => { | ||
const { className, children, hasImage, isImageLoaded, withShadow } = props | ||
|
||
const componentClassName = classNames( | ||
'c-Avatar__crop', | ||
isImageLoaded && 'is-imageLoaded', | ||
withShadow && 'is-withShadow', | ||
className | ||
) | ||
|
||
const styles = { | ||
backgroundColor: hasImage ? 'currentColor' : null, | ||
} | ||
|
||
return ( | ||
<CropUI className={componentClassName} style={styles}> | ||
{children} | ||
</CropUI> | ||
) | ||
} | ||
|
||
AvatarCrop.defaultProps = { | ||
hasImage: false, | ||
isImageLoaded: false, | ||
withShadow: false, | ||
} | ||
|
||
export default AvatarCrop |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import * as React from 'react' | ||
import VisuallyHidden from '../VisuallyHidden' | ||
import { classNames } from '../../utilities/classNames' | ||
import { getEasingTiming } from '../../utilities/easing' | ||
import { noop } from '../../utilities/other' | ||
import { ImageWrapperUI, ImageUI } from './Avatar.css' | ||
|
||
export const AvatarImage = props => { | ||
const { | ||
animationDuration, | ||
animationEasing, | ||
className, | ||
hasImage, | ||
image, | ||
isImageLoaded, | ||
onError, | ||
onLoad, | ||
name, | ||
title, | ||
} = props | ||
|
||
const componentClassName = classNames( | ||
'c-Avatar__imageWrapper', | ||
isImageLoaded && 'is-herbieFullyLoaded', | ||
className | ||
) | ||
|
||
const backgroundImage = isImageLoaded ? `url('${image}')` : null | ||
|
||
const imageStyle = { | ||
transition: `opacity ${animationDuration}ms ${getEasingTiming( | ||
animationEasing | ||
)}`, | ||
} | ||
|
||
const contentMarkup = ( | ||
<ImageWrapperUI className={componentClassName} style={imageStyle}> | ||
<ImageUI className="c-Avatar__image" style={{ backgroundImage }}> | ||
<div className="c-Avatar__name"> | ||
<VisuallyHidden>{name}</VisuallyHidden> | ||
<img | ||
alt={name} | ||
onError={onError} | ||
onLoad={onLoad} | ||
src={image} | ||
style={{ display: 'none' }} | ||
/> | ||
</div> | ||
</ImageUI> | ||
</ImageWrapperUI> | ||
) | ||
|
||
return hasImage ? contentMarkup : title | ||
} | ||
|
||
AvatarImage.defaultProps = { | ||
animationDuration: 160, | ||
animationEasing: 'ease', | ||
hasImage: false, | ||
image: null, | ||
isImageLoaded: false, | ||
onError: noop, | ||
onLoad: noop, | ||
name: null, | ||
title: null, | ||
} | ||
|
||
export default AvatarImage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters