{"size": 1055, "ext": "js", "max_stars_repo_path": "src/lib/Toast/Toast.js", "max_stars_repo_name": "LockinChina/lockin-mobile-design-lib", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/lib/Toast/Toast.js", "max_issues_repo_name": "LockinChina/lockin-mobile-design-lib", "max_issues_repo_issues_event_min_datetime": "2021-11-11T05:44:42.000Z", "max_issues_repo_issues_event_max_datetime": "2021-11-11T05:44:42.000Z", "max_forks_repo_path": "src/lib/Toast/Toast.js", "max_forks_repo_name": "LockinChina/lockin-mobile-design-lib", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": 1, "max_forks_count": null, "avg_line_length": 21.1, "max_line_length": 45, "alphanum_fraction": 0.6075829384}
/* eslint-disable no-unused-expressions */
/* eslint-disable no-underscore-dangle */
import React from 'react';
import ReactDOM from 'react-dom';
// import './toast.css';
import styled from 'styled-components';

const ToastContainer = styled.div`
  position: fixed;
  z-index: 10000;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  p {
    background: rgba(0, 0, 0, 0.6);
    padding: 10px 20px;
    color: #fff;
    line-height: 30px;
    min-width: 100px;
    text-align: center;
    border-radius: 5px;
    display: inline-block;
    max-width: 80%;
    font-size: 14px;
  }
`;

export default {
  dom: null,
  info(msg, count = 1) {
    this.dom = document.createElement('div');
    const JSXdom = (
      <ToastContainer>
        <p>{msg}</p>
      </ToastContainer>
    );
    // JSX代码
    ReactDOM.render(JSXdom, this.dom);
    document.body.appendChild(this.dom);
    const _this = this;
    setTimeout(() => {
      _this.dom && _this.dom.remove();
    }, count * 1000);
  },
};
