element-web/src/components/views/elements/Spoiler.js

31 lines
838 B
JavaScript
Raw Normal View History

2019-05-22 21:41:27 +03:00
'use strict';
import React from 'react';
module.exports = React.createClass({
displayName: 'Spoiler',
getInitialState() {
return {
visible: false,
};
},
toggleVisible() {
this.setState({ visible: !this.state.visible });
},
render: function() {
const reason = this.props.reason ? (
<span className="mx_EventTile_spoiler_reason">{"(" + this.props.reason + ")"}</span>
) : null;
return (
<span className={"mx_EventTile_spoiler" + (this.state.visible ? " visible" : "")} onClick={this.toggleVisible.bind(this)}>
{ reason }
&nbsp;
2019-06-11 22:08:45 +03:00
<span className="mx_EventTile_spoiler_content" dangerouslySetInnerHTML={{ __html: this.props.contentHtml }} />
2019-05-22 21:41:27 +03:00
</span>
);
}
})