apps.websight-package-manager.web-resources.components.CloseableSectionMessage.js Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of websight-package-manager-view Show documentation
Show all versions of websight-package-manager-view Show documentation
Package Manager View module is responsible for view part of Package Manager.
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")))));
}
}