Browse Source

fixed several styling issues

pull/586/head
Dan Ditomaso 1 year ago
parent
commit
2536d9cc10
  1. 25
      src/components/PageComponents/Messages/ChannelChat.tsx
  2. 4
      src/components/PageLayout.tsx
  3. 8
      src/components/Sidebar.tsx
  4. 2
      src/components/UI/Sidebar/SidebarSection.tsx
  5. 12
      src/pages/Messages.tsx
  6. 13
      src/pages/Nodes.tsx

25
src/components/PageComponents/Messages/ChannelChat.tsx

@ -9,7 +9,7 @@ export interface ChannelChatProps {
const EmptyState = () => ( const EmptyState = () => (
<div className="flex flex-1 flex-col place-content-center place-items-center p-8 text-gray-500 dark:text-gray-400"> <div className="flex flex-1 flex-col place-content-center place-items-center p-8 text-gray-500 dark:text-gray-400">
<InboxIcon className="h-8 w-8 mb-2" /> <InboxIcon className="mb-2 h-8 w-8" />
<span className="text-sm">No Messages</span> <span className="text-sm">No Messages</span>
</div> </div>
); );
@ -24,10 +24,7 @@ export const ChannelChat = ({
const scrollContainer = scrollContainerRef.current; const scrollContainer = scrollContainerRef.current;
if (!scrollContainer) return; if (!scrollContainer) return;
const isNearBottom = const isNearBottom = scrollContainer.scrollTop < 100;
scrollContainer.scrollHeight -
scrollContainer.scrollTop -
scrollContainer.clientHeight < 100; // Threshold in pixels
if (isNearBottom || behavior === 'instant') { if (isNearBottom || behavior === 'instant') {
messagesEndRef.current?.scrollIntoView({ behavior }); messagesEndRef.current?.scrollIntoView({ behavior });
@ -35,17 +32,21 @@ export const ChannelChat = ({
}, []); }, []);
useEffect(() => { useEffect(() => {
scrollToBottom('smooth'); if (messages.length > 0) {
scrollToBottom('smooth');
}
}, [messages, scrollToBottom]); }, [messages, scrollToBottom]);
useEffect(() => { useEffect(() => {
scrollToBottom('instant'); if (messages.length > 0) {
}, [scrollToBottom]); scrollToBottom('instant');
}
}, [scrollToBottom, messages.length]);
if (!messages?.length) { if (!messages?.length) {
return ( return (
<ul ref={scrollContainerRef} className="flex-1 flex flex-col items-center justify-center"> <ul ref={scrollContainerRef} className="flex flex-1 flex-col items-center justify-center">
<EmptyState /> <EmptyState />
</ul> </ul>
); );
@ -54,8 +55,9 @@ export const ChannelChat = ({
return ( return (
<ul <ul
ref={scrollContainerRef} ref={scrollContainerRef}
className="flex-1 overflow-y-auto px-3 py-2" className="flex flex-1 flex-col-reverse overflow-y-auto px-3 py-2"
> >
<div ref={messagesEndRef} className="h-px" />
{messages?.map((message) => { {messages?.map((message) => {
return ( return (
<MessageItem <MessageItem
@ -64,7 +66,6 @@ export const ChannelChat = ({
/> />
); );
})} })}
<div ref={messagesEndRef} className="h-px" />
</ul> </ul>
); );
}; };

4
src/components/PageLayout.tsx

@ -48,7 +48,7 @@ export const PageLayout = ({
{leftBar && ( {leftBar && (
<aside <aside
className={cn( className={cn(
"p-2 shrink-0 border-r-[0.5px] border-slate-300 dark:border-slate-700", "p-2 shrink-0 border-r-[0.5px] border-slate-300 dark:border-slate-700 ",
leftBarClassName leftBarClassName
)} )}
> >
@ -112,7 +112,7 @@ export const PageLayout = ({
{rightBar && ( {rightBar && (
<aside <aside
className={cn( className={cn(
"w-[281px] shrink-0 border-l border-slate-300 dark:border-slate-700 p-2", "w-[281px] shrink-0 border-l border-slate-300 dark:border-slate-700 p-2 overflow-hidden",
rightBarClassName rightBarClassName
)} )}
> >

8
src/components/Sidebar.tsx

@ -47,7 +47,7 @@ const CollapseToggleButton = () => {
onClick={toggleSidebar} onClick={toggleSidebar}
className={cn( className={cn(
'absolute top-21 -right-2 z-10 p-0.5 rounded-full transform translate-x-1/2', 'absolute top-21 -right-2 z-10 p-0.5 rounded-full transform translate-x-1/2',
'bg-background-primary border border-slate-300 dark:border-slate-700', 'border border-slate-300 dark:border-slate-700',
'text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-100', 'text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-100',
'focus:outline-none focus:ring-2 focus:ring-accent transition-transform' 'focus:outline-none focus:ring-2 focus:ring-accent transition-transform'
)} )}
@ -92,7 +92,7 @@ export const Sidebar = ({ children }: SidebarProps) => {
return ( return (
<div <div
className={cn( className={cn(
'relative bg-background-primary border-slate-300 dark:border-slate-700', 'relative border-slate-300 dark:border-slate-700',
'transition-all duration-300 ease-in-out flex-shrink-0', 'transition-all duration-300 ease-in-out flex-shrink-0',
isCollapsed ? 'w-24' : 'w-46 lg:w-64' isCollapsed ? 'w-24' : 'w-46 lg:w-64'
)} )}
@ -151,7 +151,7 @@ export const Sidebar = ({ children }: SidebarProps) => {
{children} {children}
</div> </div>
<div className="border-t-[0.5px] bg-background-primary border-slate-300 dark:border-slate-700 p-2 flex-shrink-0"> <div className="pt-4 border-t-[0.5px] bg-background-primary border-slate-300 dark:border-slate-700 p-2 flex-shrink-0">
{myNode === undefined ? ( {myNode === undefined ? (
<div className="flex flex-col items-center justify-center py-6"> <div className="flex flex-col items-center justify-center py-6">
<Spinner /> <Spinner />
@ -221,7 +221,7 @@ export const Sidebar = ({ children }: SidebarProps) => {
</div> </div>
<div <div
className={cn( className={cn(
'flex items-center flex-shrink-0 ml-14', 'flex items-center flex-shrink-0 ml-2',
'transition-all duration-300 ease-in-out', 'transition-all duration-300 ease-in-out',
isCollapsed isCollapsed
? 'opacity-0 max-w-0 invisible pointer-events-none' ? 'opacity-0 max-w-0 invisible pointer-events-none'

2
src/components/UI/Sidebar/SidebarSection.tsx

@ -34,7 +34,7 @@ export const SidebarSection = ({
{label} {label}
</Heading> </Heading>
<div className="space-y-1 h-full"> <div className="space-y-0.5">
{children} {children}
</div> </div>
</div> </div>

12
src/pages/Messages.tsx

@ -54,6 +54,11 @@ export const MessagesPage = () => {
const currentChat = { type: chatType, id: activeChat }; const currentChat = { type: chatType, id: activeChat };
console.log(getMessages(MessageType.Broadcast, {
myNodeNum: getNodeNum(),
channel: currentChannel?.index
}));
const renderChatContent = () => { const renderChatContent = () => {
switch (chatType) { switch (chatType) {
case MessageType.Broadcast: case MessageType.Broadcast:
@ -103,8 +108,8 @@ export const MessagesPage = () => {
), [filteredChannels, unreadCounts, activeChat, chatType, isCollapsed, setActiveChat, setChatType, resetUnread]); ), [filteredChannels, unreadCounts, activeChat, chatType, isCollapsed, setActiveChat, setChatType, resetUnread]);
const rightSidebar = useMemo(() => ( const rightSidebar = useMemo(() => (
<SidebarSection label="" className="px-0 relative"> <SidebarSection label="" className="px-0 flex flex-col h-full overflow-y-auto">
<label className=""> <label className="px-4 pt-4">
<Input <Input
type="text" type="text"
placeholder="Search nodes..." placeholder="Search nodes..."
@ -114,7 +119,7 @@ export const MessagesPage = () => {
/> />
</label> </label>
<div className={cn( <div className={cn(
"flex flex-col gap-3 pt-4", "flex flex-col h-full flex-1 overflow-y-auto gap-2.5 pt-1",
)}> )}>
{filteredNodes?.map((node) => ( {filteredNodes?.map((node) => (
<SidebarButton <SidebarButton
@ -138,7 +143,6 @@ export const MessagesPage = () => {
</div> </div>
</SidebarSection> </SidebarSection>
), [filteredNodes, searchTerm, activeChat, chatType, setActiveChat, setChatType, resetUnread, hasNodeError]); ), [filteredNodes, searchTerm, activeChat, chatType, setActiveChat, setChatType, resetUnread, hasNodeError]);
return ( return (
<PageLayout <PageLayout
label={`Messages: ${isBroadcast && currentChannel label={`Messages: ${isBroadcast && currentChannel

13
src/pages/Nodes.tsx

@ -21,19 +21,6 @@ export interface DeleteNoteDialogProps {
onOpenChange: (open: boolean) => void; onOpenChange: (open: boolean) => void;
} }
// function shortNameFromNode(
// node: ReturnType<useDevice>["nodes"][number],
// ): string {
// const shortNameOfNode = node.user?.shortName ??
// (node.user?.macaddr
// ? `${base16
// .stringify(node.user?.macaddr.subarray(4, 6) ?? [])
// .toLowerCase()
// }`
// : `${numberToHexUnpadded(node.num).slice(-4)}`);
// return String(shortNameOfNode);
// }
const NodesPage = (): JSX.Element => { const NodesPage = (): JSX.Element => {
const { getNodes, hardware, connection } = useDevice(); const { getNodes, hardware, connection } = useDevice();
const [selectedNode, setSelectedNode] = useState< const [selectedNode, setSelectedNode] = useState<

Loading…
Cancel
Save