React channel title

This commit is contained in:
Michael Peters 2021-12-24 18:49:50 -06:00
parent 6f715ccc87
commit a47804d980
5 changed files with 31 additions and 19 deletions

View File

@ -5,6 +5,7 @@ import Q from "../q-module";
import ElementsUtil from "./require/elements-util";
import MemberList from "./lists/member-list";
import MessageList from './lists/message-list';
import ChannelTitle from './sections/channel-title';
export function mountBaseComponents() {
// guild-list
@ -21,8 +22,9 @@ export function mountGuildComponents(q: Q, guild: CombinedGuild) {
}
export function mountGuildChannelComponents(q: Q, guild: CombinedGuild, channel: Channel) {
// channel-content pieces
// TODO
// channel-title pieces
ElementsUtil.unmountReactComponent(q.$('.channel-title-anchor'));
ElementsUtil.mountReactComponent(q.$('.channel-title-anchor'), <ChannelTitle channel={channel} />)
// message-list
// Up Next: Figure out why this is empty

View File

@ -0,0 +1,26 @@
import React, { FC } from 'react';
import { Channel } from '../../data-types';
export interface ChannelTitleProps {
channel: Channel;
}
const ChannelTitle: FC<ChannelTitleProps> = (props: ChannelTitleProps) => {
const { channel } = props;
return (
<div className="channel-title">
<div className="channel-icon">
<svg width="24" height="24" viewBox="0 0 24 24">
<path fill="currentColor" fillRule="evenodd" clipRule="evenodd"
d="M5.88657 21C5.57547 21 5.3399 20.7189 5.39427 20.4126L6.00001 17H2.59511C2.28449 17 2.04905 16.7198 2.10259 16.4138L2.27759 15.4138C2.31946 15.1746 2.52722 15 2.77011 15H6.35001L7.41001 9H4.00511C3.69449 9 3.45905 8.71977 3.51259 8.41381L3.68759 7.41381C3.72946 7.17456 3.93722 7 4.18011 7H7.76001L8.39677 3.41262C8.43914 3.17391 8.64664 3 8.88907 3H9.87344C10.1845 3 10.4201 3.28107 10.3657 3.58738L9.76001 7H15.76L16.3968 3.41262C16.4391 3.17391 16.6466 3 16.8891 3H17.8734C18.1845 3 18.4201 3.28107 18.3657 3.58738L17.76 7H21.1649C21.4755 7 21.711 7.28023 21.6574 7.58619L21.4824 8.58619C21.4406 8.82544 21.2328 9 20.9899 9H17.41L16.35 15H19.7549C20.0655 15 20.301 15.2802 20.2474 15.5862L20.0724 16.5862C20.0306 16.8254 19.8228 17 19.5799 17H16L15.3632 20.5874C15.3209 20.8261 15.1134 21 14.8709 21H13.8866C13.5755 21 13.3399 20.7189 13.3943 20.4126L14 17H8.00001L7.36325 20.5874C7.32088 20.8261 7.11337 21 6.87094 21H5.88657ZM9.41045 9L8.35045 15H14.3504L15.4104 9H9.41045Z"></path>
</svg>
</div>
<div className="channel-name">{channel.name}</div>
<div className="channel-flavor-divider" style={{ visibility: channel.flavorText ? 'visible' : 'hidden' }}></div>
<div className="channel-flavor-text">{channel.flavorText}</div>
</div>
);
}
export default ChannelTitle;

View File

@ -58,15 +58,7 @@
</div>
</div>
<div id="channel">
<div id="channel-title" class="channel-title">
<!-- Yoinked Directly from Discord -->
<div id="channel-icon" class="channel-icon">
<svg width="24" height="24" viewBox="0 0 24 24"><path fill="currentColor" fill-rule="evenodd" clip-rule="evenodd" d="M5.88657 21C5.57547 21 5.3399 20.7189 5.39427 20.4126L6.00001 17H2.59511C2.28449 17 2.04905 16.7198 2.10259 16.4138L2.27759 15.4138C2.31946 15.1746 2.52722 15 2.77011 15H6.35001L7.41001 9H4.00511C3.69449 9 3.45905 8.71977 3.51259 8.41381L3.68759 7.41381C3.72946 7.17456 3.93722 7 4.18011 7H7.76001L8.39677 3.41262C8.43914 3.17391 8.64664 3 8.88907 3H9.87344C10.1845 3 10.4201 3.28107 10.3657 3.58738L9.76001 7H15.76L16.3968 3.41262C16.4391 3.17391 16.6466 3 16.8891 3H17.8734C18.1845 3 18.4201 3.28107 18.3657 3.58738L17.76 7H21.1649C21.4755 7 21.711 7.28023 21.6574 7.58619L21.4824 8.58619C21.4406 8.82544 21.2328 9 20.9899 9H17.41L16.35 15H19.7549C20.0655 15 20.301 15.2802 20.2474 15.5862L20.0724 16.5862C20.0306 16.8254 19.8228 17 19.5799 17H16L15.3632 20.5874C15.3209 20.8261 15.1134 21 14.8709 21H13.8866C13.5755 21 13.3399 20.7189 13.3943 20.4126L14 17H8.00001L7.36325 20.5874C7.32088 20.8261 7.11337 21 6.87094 21H5.88657ZM9.41045 9L8.35045 15H14.3504L15.4104 9H9.41045Z"></path></svg>
</div>
<div id="channel-name" class="channel-name"></div>
<div id="channel-flavor-divider" class="channel-flavor-divider"></div>
<div id="channel-flavor-text" class="channel-flavor-text"></div>
</div>
<div class="channel-title-anchor"></div>
<div id="channel-content">
<div id="channel-feed-wrapper">
<div class="message-list-anchor"></div>
@ -85,7 +77,6 @@
</div>
</div>
</div>
<div id="guild-members"></div><!-- TODO: guild-members-react -->
<div class="member-list-anchor"></div>
</div>
</div>

View File

@ -26,7 +26,6 @@
/* General custom scrollbar (much thinner than channel feed) */
/* Note: Using this hack... https://stackoverflow.com/questions/29866759/how-do-i-add-a-margin-to-a-css-webkit-scrollbar */
:not(.message-list .infinite-scroll-scroll-base):not(:hover)::-webkit-scrollbar-thumb {
visibility: hidden;
}

View File

@ -125,9 +125,6 @@ export default class UI {
next.classList.add('active');
// Channel Name + Flavor Text Header + Text Input Placeholder
this.q.$('#channel-name').innerText = channel.name;
this.q.$('#channel-flavor-text').innerText = channel.flavorText || '';
this.q.$('#channel-flavor-divider').style.visibility = channel.flavorText ? 'visible' : 'hidden';
this.q.$('#text-input').setAttribute('data-placeholder', 'Message #' + channel.name);
mountGuildChannelComponents(this.q, guild, channel);
@ -279,9 +276,6 @@ export default class UI {
newElement.classList.add('active');
// See also setActiveChannel
this.q.$('#channel-name').innerText = channel.name;
this.q.$('#channel-flavor-text').innerText = channel.flavorText ?? '';
this.q.$('#channel-flavor-divider').style.visibility = channel.flavorText ? 'visible' : 'hidden';
this.q.$('#text-input').setAttribute('placeholder', 'Message #' + channel.name);
}
}