UNPKG

@makeen.io/material-ui-kit

Version:
27 lines (25 loc) 2.07 kB
import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";function _templateObject() {var data = _taggedTemplateLiteral([""]);_templateObject = function _templateObject() {return data;};return data;}import React, { useRef } from "react"; import { Avatar, ImageEditable } from "../../atoms"; import constants from "../../config/constants"; import styled from "styled-components"; import BasePhotoPicker from "./index"; var handleRemoveImage = function handleRemoveImage(childRef) { childRef.current.removeCurrentImage(); }; var handleUploadNewImage = function handleUploadNewImage(childRef) { childRef.current.openFileWindow(); }; var avatarstyle = "\nfont-size: 21px\n"; var ImagePlaceholder = styled(function (_ref) {var title = _ref.title,palette = _ref.palette,className = _ref.className;return /*#__PURE__*/React.createElement(Avatar, { className: className, width: 96, height: 96, title: title, palette: palette, type: "user", avatarStyle: avatarstyle });})(_templateObject()); var EditablePhotoPicker = function EditablePhotoPicker(_ref2) {var initImage = _ref2.initImage,title = _ref2.title,color = _ref2.color,editableStyle = _ref2.editableStyle,handleFileChange = _ref2.handleFileChange,theme = _ref2.theme,uploadProgress = _ref2.uploadProgress; var childRef = useRef(); // Has to be handled after discussion with Cristian var palette = color ? constants.avatarPalette.light.green : constants.avatarPalette.light.green; return /*#__PURE__*/React.createElement(ImageEditable, { removeImage: function removeImage() {return handleRemoveImage(childRef);}, uploadNewImage: function uploadNewImage() {return handleUploadNewImage(childRef);}, editableStyle: editableStyle }, /*#__PURE__*/ React.createElement(BasePhotoPicker, { ref: childRef, initImage: initImage, onFileChange: handleFileChange, uploadProgress: uploadProgress, theme: theme }, /*#__PURE__*/ React.createElement(ImagePlaceholder, { title: title, palette: palette }))); }; export default EditablePhotoPicker; //# sourceMappingURL=EditablePhotoPicker.js.map