dispatch/client/js/components/modals/Topic.js

31 lines
885 B
JavaScript
Raw Normal View History

2019-01-25 02:57:58 +00:00
import React from 'react';
2020-05-03 07:05:16 +00:00
import Modal from 'react-modal';
import { useSelector } from 'react-redux';
2020-04-29 01:10:13 +00:00
import { FiX } from 'react-icons/fi';
2020-06-30 11:24:23 +00:00
import Text from 'components/Text';
2020-04-29 01:10:13 +00:00
import Button from 'components/ui/Button';
2020-05-03 07:05:16 +00:00
import useModal from 'components/modals/useModal';
import { getSelectedChannel } from 'state/channels';
2019-01-25 02:57:58 +00:00
import { linkify } from 'utils';
2020-06-30 11:28:51 +00:00
import colorify from 'utils/colorify';
2019-01-25 02:57:58 +00:00
2020-05-03 07:05:16 +00:00
const Topic = () => {
const [modal, channel, closeModal] = useModal('topic');
const topic = useSelector(state => getSelectedChannel(state)?.topic);
2019-01-25 02:57:58 +00:00
return (
2020-05-03 07:05:16 +00:00
<Modal {...modal}>
2019-01-25 02:57:58 +00:00
<div className="modal-header">
<h2>Topic in {channel}</h2>
2020-05-03 07:05:16 +00:00
<Button icon={FiX} className="modal-close" onClick={closeModal} />
2019-01-25 02:57:58 +00:00
</div>
2020-06-30 11:24:23 +00:00
<p className="modal-content">
2020-06-30 11:28:51 +00:00
<Text>{colorify(linkify(topic))}</Text>
2020-06-30 11:24:23 +00:00
</p>
2020-05-03 07:05:16 +00:00
</Modal>
2019-01-25 02:57:58 +00:00
);
};
2020-05-03 07:05:16 +00:00
export default Topic;