add basic spoiler support

This commit is contained in:
Sorunome 2019-05-22 20:41:27 +02:00
parent 8844706e5f
commit d8f4512439
No known key found for this signature in database
GPG key ID: 63E31F7B5993A9C4
4 changed files with 90 additions and 1 deletions

View file

@ -0,0 +1,32 @@
'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;
<span className="mx_EventTile_spoiler_content">
<span dangerouslySetInnerHTML={{ __html: this.props.contentHtml }} />
</span>
</span>
);
}
})