All Downloads are FREE. Search and download functionalities are using the official Maven repository.

apps.websight-package-manager.web-resources.components.CloseableSectionMessage.js Maven / Gradle / Ivy

The newest version!
import React from "/apps/websight-atlaskit-esm/web-resources/react.js";
import SectionMessage from "/apps/websight-atlaskit-esm/web-resources/@atlaskit/section-message.js";
import Tooltip from "/apps/websight-atlaskit-esm/web-resources/@atlaskit/tooltip.js";
import styled from "/apps/websight-atlaskit-esm/web-resources/styled-components.js";
const Icon = styled.i`
    font-size: 18px;
    padding-left: 16px;
    cursor: pointer;
`;
const MessageContainer = styled.div`
    display: flex;
    justify-content: space-between;
`;
export default class CloseableSectionMessage extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      isClosed: false
    };
    this.onClose = this.onClose.bind(this);
  }

  componentDidMount() {
    const localStorageClosedValue = localStorage.getItem(this.props.id + '-closed');

    if (localStorageClosedValue === 'true') {
      this.setState({
        isClosed: true
      });
    }
  }

  onClose() {
    this.setState({
      isClosed: true
    }, () => {
      localStorage.setItem(this.props.id + '-closed', true);
    });
  }

  render() {
    const {
      isClosed
    } = this.state;
    return /*#__PURE__*/React.createElement(React.Fragment, null, !isClosed && /*#__PURE__*/React.createElement(SectionMessage, this.props, /*#__PURE__*/React.createElement(MessageContainer, null, this.props.children, /*#__PURE__*/React.createElement(Tooltip, {
      content: "Close",
      delay: 0
    }, /*#__PURE__*/React.createElement(Icon, {
      className: "material-icons",
      onClick: this.onClose
    }, "close")))));
  }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy