Format topic

This commit is contained in:
Ken-Håvard Lieng 2020-06-30 13:28:51 +02:00
parent 307573830a
commit 1fe4c4d17e
4 changed files with 177 additions and 171 deletions

File diff suppressed because one or more lines are too long

View File

@ -8,6 +8,7 @@ import Button from 'components/ui/Button';
import { join } from 'state/channels'; import { join } from 'state/channels';
import { searchChannels } from 'state/channelSearch'; import { searchChannels } from 'state/channelSearch';
import { linkify } from 'utils'; import { linkify } from 'utils';
import colorify from 'utils/colorify';
const Channel = memo(({ network, name, topic, userCount, joined }) => { const Channel = memo(({ network, name, topic, userCount, joined }) => {
const dispatch = useDispatch(); const dispatch = useDispatch();
@ -35,7 +36,7 @@ const Channel = memo(({ network, name, topic, userCount, joined }) => {
)} )}
</div> </div>
<p className="modal-channel-topic"> <p className="modal-channel-topic">
<Text>{linkify(topic)}</Text> <Text>{colorify(linkify(topic))}</Text>
</p> </p>
</div> </div>
); );

View File

@ -7,6 +7,7 @@ import Button from 'components/ui/Button';
import useModal from 'components/modals/useModal'; import useModal from 'components/modals/useModal';
import { getSelectedChannel } from 'state/channels'; import { getSelectedChannel } from 'state/channels';
import { linkify } from 'utils'; import { linkify } from 'utils';
import colorify from 'utils/colorify';
const Topic = () => { const Topic = () => {
const [modal, channel, closeModal] = useModal('topic'); const [modal, channel, closeModal] = useModal('topic');
@ -20,7 +21,7 @@ const Topic = () => {
<Button icon={FiX} className="modal-close" onClick={closeModal} /> <Button icon={FiX} className="modal-close" onClick={closeModal} />
</div> </div>
<p className="modal-content"> <p className="modal-content">
<Text>{linkify(topic)}</Text> <Text>{colorify(linkify(topic))}</Text>
</p> </p>
</Modal> </Modal>
); );

View File

@ -329,6 +329,10 @@ function colorifyString(str, state = {}) {
} }
export default function colorify(blocks) { export default function colorify(blocks) {
if (!blocks) {
return blocks;
}
const result = []; const result = [];
let colored; let colored;
let state; let state;