UNPKG

@makeen.io/material-ui-kit

Version:
82 lines (55 loc) 4.23 kB
import _extends from "@babel/runtime/helpers/extends";import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";import _slicedToArray from "@babel/runtime/helpers/slicedToArray";import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";function _templateObject2() {var data = _taggedTemplateLiteral(["\n .MuiSnackbar-root {\n border-radius: 4px;\n }\n\n .MuiSnackbarContent-root {\n background-color: ", ";\n box-shadow: none;\n position: relative;\n padding-bottom: ", ";\n }\n\n .MuiAlert-root {\n background-color: ", ";\n color: ", ";\n\n .MuiAlert-icon {\n color: ", ";\n }\n }\n\n .MuiSnackbarContent-message {\n font-size: ", ";\n }\n"]);_templateObject2 = function _templateObject2() {return data;};return data;}function _templateObject() {var data = _taggedTemplateLiteral(["\n position: absolute;\n bottom: 10px;\n left: 16px;\n right: 16px;\n\n .MuiLinearProgress-colorPrimary {\n background-color: rgb(143, 155, 179, 0.24);\n }\n"]);_templateObject = function _templateObject() {return data;};return data;}import React, { useEffect, useState } from "react"; import Fade from "@material-ui/core/Fade"; import Grow from "@material-ui/core/Grow"; import IconButton from "@material-ui/core/IconButton"; import LinearProgress from "@material-ui/core/LinearProgress"; import { default as MuiSlide } from "@material-ui/core/Slide"; import Snackbar from "@material-ui/core/Snackbar"; import CloseIcon from "@material-ui/icons/Close"; import styled from "styled-components"; import { default as theme } from "../../themes/default"; export var transitions = { fade: Fade, grow: Grow, slide: MuiSlide }; var defaultPosition = { horizontal: "right", vertical: "bottom" }; var LineProgress = styled(function (_ref) {var autoHideDuration = _ref.autoHideDuration,className = _ref.className;var _useState = useState(0),_useState2 = _slicedToArray(_useState, 2),progress = _useState2[0],setProgress = _useState2[1]; useEffect(function () { var tick = function tick() { setProgress(function (oldProgress) {return oldProgress >= 100 ? 100 : oldProgress + 1;}); }; var interval = autoHideDuration ? autoHideDuration / 100 : 20; var timer = setInterval(tick, interval); return function () {return clearInterval(timer);}; }, []); return /*#__PURE__*/React.createElement("div", { className: className }, /*#__PURE__*/ React.createElement(LinearProgress, { variant: "determinate", value: progress })); })(_templateObject()); export default styled(function (_ref2) {var position = _ref2.position,className = _ref2.className,_ref2$transition = _ref2.transition,transition = _ref2$transition === void 0 ? "fade" : _ref2$transition,_ref2$showCloseButton = _ref2.showCloseButton,showCloseButton = _ref2$showCloseButton === void 0 ? false : _ref2$showCloseButton,action = _ref2.action,withLineProgress = _ref2.withLineProgress,rest = _objectWithoutProperties(_ref2, ["position", "className", "transition", "showCloseButton", "action", "withLineProgress"]); var snackbar = position || defaultPosition; var handleClose = React.useCallback(function (event) { if (!rest.onClose) { return; } rest.onClose(event); }, []); var actionsBlock = /*#__PURE__*/React.createElement(React.Fragment, null, action, showCloseButton && /*#__PURE__*/React.createElement(IconButton, { "aria-label": "close", color: "inherit", onClick: handleClose }, /*#__PURE__*/ React.createElement(CloseIcon, null)), withLineProgress && /*#__PURE__*/React.createElement(LineProgress, { autoHideDuration: rest.autoHideDuration })); return /*#__PURE__*/React.createElement("div", { className: className }, /*#__PURE__*/ React.createElement(Snackbar, _extends({ anchorOrigin: snackbar, TransitionComponent: transitions[transition], action: actionsBlock }, rest))); })(_templateObject2(), theme.palette.snackbar.backgroundColor, function (props) {return props.withLineProgress ? "20px" : "6px";}, theme.palette.snackbar.backgroundColor, theme.palette.snackbar.textColor, theme.palette.snackbar.textColor, theme.sizes.snackbar.fontSize); //# sourceMappingURL=index.js.map