UNPKG

@retailmenot/anchor

Version:

A React UI Library by RetailMeNot

66 lines (64 loc) 2.68 kB
var __rest = (this && this.__rest) || function (s, e) { var t = {}; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p]; if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]]; } return t; }; // REACT import * as React from 'react'; // VENDOR import { space as spaceStyles } from '@xstyled/system'; import classNames from 'classnames'; import styled from '@xstyled/styled-components'; /* eslint-disable max-len */ const DefaultAvatar = () => (React.createElement("svg", { width: "36", height: "36", viewBox: "0 0 22 22", xmlns: "http://www.w3.org/2000/svg" }, React.createElement("path", { d: "M22 20.427c0 .869-.704 1.573-1.571 1.573H1.57A1.572 1.572 0 0 1 0 20.427V18.95c0-3.527 2.805-6.392 6.254-6.392h.038v-.001c1.315.993 2.934 1.604 4.708 1.604s3.393-.611 4.708-1.604v.001h.038c3.449 0 6.254 2.865 6.254 6.392v1.476zM11 0a6.29 6.29 0 0 1 6.286 6.294A6.29 6.29 0 0 1 11 12.59a6.29 6.29 0 0 1-6.286-6.295A6.29 6.29 0 0 1 11 0z", fill: "#A6A6A6" }))); /* eslint-enable max-len */ const StyledAvatar = styled('div') ` border: solid 0.1875rem rgba(255, 255, 255, 0.4); display: flex; justify-content: center; align-items: center; height: 2rem; width: 2rem; border-radius: circular; svg { justify-self: baseline; height: 1.5rem; margin-bottom: -0.375rem; } ${spaceStyles} `; const InnerBorder = styled('div') ` flex: 0 0 1.625rem; width: 1.625rem; height: 1.625rem; font-family: base; font-size: 0.75rem; font-weight: bold; color: text.base; background-color: background.base; display: flex; justify-content: center; align-items: center; border-radius: circular; overflow: hidden; img { flex: 0 0 100%; max-width: 100%; } `; export const Avatar = (_a) => { var { className, src, label, alt } = _a, props = __rest(_a, ["className", "src", "label", "alt"]); return (React.createElement(StyledAvatar, Object.assign({ className: classNames('anchor-avatar', className) }, props), React.createElement(InnerBorder, { className: "anchor-avatar-container" }, label && label.substr(0, 2).toUpperCase(), src && React.createElement("img", { src: src, alt: alt ? alt : 'Anchor Avatar' }), !label && !src && React.createElement(DefaultAvatar, null)))); }; //# sourceMappingURL=Avatar.component.js.map