From 1ee4dfe84e498155b15defa448e2520a0f2fb3d8 Mon Sep 17 00:00:00 2001 From: austinkelsay Date: Mon, 2 Sep 2024 09:49:17 -0500 Subject: [PATCH] styling improvements to sidebar and the pages it affects --- src/components/profile/UserContent.js | 4 ++-- src/components/sidebar/Sidebar.js | 34 ++++++++++++++------------- src/pages/api/discord-messages.js | 14 ++++++----- src/pages/create.js | 2 +- src/pages/feed.js | 10 ++++---- src/pages/profile.js | 4 ++-- 6 files changed, 37 insertions(+), 31 deletions(-) diff --git a/src/components/profile/UserContent.js b/src/components/profile/UserContent.js index fdf8b7d..7b38b87 100644 --- a/src/components/profile/UserContent.js +++ b/src/components/profile/UserContent.js @@ -113,7 +113,7 @@ const UserContent = () => { const isError = coursesError || resourcesError || workshopsError || draftsError || contentIdsError || courseDraftsError; return ( -
+

Your Content

@@ -132,7 +132,7 @@ const UserContent = () => { />
-
+
{isLoading ? (

Loading...

) : isError ? ( diff --git a/src/components/sidebar/Sidebar.js b/src/components/sidebar/Sidebar.js index a09ec25..7507d23 100644 --- a/src/components/sidebar/Sidebar.js +++ b/src/components/sidebar/Sidebar.js @@ -12,14 +12,16 @@ const Sidebar = () => { }; return ( -
-
router.push('/')} className={`w-full cursor-pointer hover:bg-gray-700 rounded-lg ${isActive('/') ? 'bg-gray-700' : ''}`}> -

Home

+
+
router.push('/')} className={`w-full cursor-pointer py-2 my-2 hover:bg-gray-700 rounded-lg ${isActive('/') ? 'bg-gray-700' : ''}`}> +

Home

-
router.push('/content')} className={`w-full cursor-pointer hover:bg-gray-700 rounded-lg ${isActive('/content') ? 'bg-gray-700' : ''}`}> -

Content

+
router.push('/content')} className={`w-full cursor-pointer py-2 my-2 hover:bg-gray-700 rounded-lg ${isActive('/content') ? 'bg-gray-700' : ''}`}> +

Content

+
+
router.push('/create')} className={`w-full cursor-pointer py-2 my-2 hover:bg-gray-700 rounded-lg ${isActive('/create') ? 'bg-gray-700' : ''}`}> +

Create

- { headerAction: ({ context }) => ({ className: 'border-none bg-transparent py-3 my-2', }), - content: { className: 'border-none bg-transparent pt-0' } + content: { className: 'border-none bg-transparent pt-0 pl-0 ml-0' } } }} className="unstyled border-none bg-transparent"> - -
router.push('/feed')} className={`w-full cursor-pointer hover:bg-gray-700 rounded-lg ${isActive('/feed') ? 'bg-gray-700' : ''}`}> -

global

+ +
router.push('/feed')} className={`w-full cursor-pointer py-2 my-2 hover:bg-gray-700 rounded-lg ${isActive('/feed') ? 'bg-gray-700' : ''}`}> +

global

-
router.push('/chat/nostr')} className={`w-full cursor-pointer hover:bg-gray-700 rounded-lg ${isActive('/chat/nostr') ? 'bg-gray-700' : ''}`}> -

nostr

+
router.push('/chat/nostr')} className={`w-full cursor-pointer py-2 my-2 hover:bg-gray-700 rounded-lg ${isActive('/chat/nostr') ? 'bg-gray-700' : ''}`}> +

nostr

-
router.push('/chat/discord')} className={`w-full cursor-pointer hover:bg-gray-700 rounded-lg ${isActive('/chat/discord') ? 'bg-gray-700' : ''}`}> -

discord

+
router.push('/chat/discord')} className={`w-full cursor-pointer py-2 my-2 hover:bg-gray-700 rounded-lg ${isActive('/chat/discord') ? 'bg-gray-700' : ''}`}> +

discord

-
router.push('/chat/stackernews')} className={`w-full cursor-pointer hover:bg-gray-700 rounded-lg ${isActive('/chat/stackernews') ? 'bg-gray-700' : ''}`}> -

stackernews

+
router.push('/chat/stackernews')} className={`w-full cursor-pointer py-2 my-2 hover:bg-gray-700 rounded-lg ${isActive('/chat/stackernews') ? 'bg-gray-700' : ''}`}> +

stackernews

diff --git a/src/pages/api/discord-messages.js b/src/pages/api/discord-messages.js index a0a670a..0c8c736 100644 --- a/src/pages/api/discord-messages.js +++ b/src/pages/api/discord-messages.js @@ -23,13 +23,11 @@ export default async function handler(req, res) { const client = await initializeClient(); const channels = ['🤝general', '🌀random', '❓help', '🛠project-ideas', '🙌show-it-off', '🤡memes', '🧠learning']; - const messages = []; - - for (const channelName of channels) { + const messagesPromises = channels.map(async (channelName) => { const channel = client.channels.cache.find(ch => ch.name === channelName); if (channel) { const channelMessages = await channel.messages.fetch({ limit: 5 }); - messages.push(...channelMessages.map(msg => ({ + return channelMessages.map(msg => ({ id: msg.id, content: msg.content, author: msg.author.username, @@ -37,9 +35,13 @@ export default async function handler(req, res) { channel: msg.channel.name, channelId: msg.channel.id, timestamp: msg.createdAt - }))); + })); } - } + return []; + }); + + const messagesArray = await Promise.all(messagesPromises); + const messages = messagesArray.flat(); const filteredMessages = messages.filter(msg => msg.content.length > 0); filteredMessages.sort((a, b) => b.timestamp - a.timestamp); diff --git a/src/pages/create.js b/src/pages/create.js index 94d3170..e673cca 100644 --- a/src/pages/create.js +++ b/src/pages/create.js @@ -28,7 +28,7 @@ const Create = () => { }; return ( -
+

Create a {homeItems[activeIndex].label}

{renderForm()} diff --git a/src/pages/feed.js b/src/pages/feed.js index 0a5f02a..a652baf 100644 --- a/src/pages/feed.js +++ b/src/pages/feed.js @@ -132,16 +132,18 @@ const Feed = () => { className="max-w-[90%] mx-auto" />
+
{data && data.map(message => ( header(message)} - footer={() => footer(message)} - className="w-full bg-gray-700 shadow-lg hover:shadow-xl transition-shadow duration-300 mb-4" + key={message.id} + header={() => header(message)} + footer={() => footer(message)} + className="w-full bg-gray-700 shadow-lg hover:shadow-xl transition-shadow duration-300 mb-4" >

{message.content}

))} +
); }; diff --git a/src/pages/profile.js b/src/pages/profile.js index e5a0cf2..3bc70cd 100644 --- a/src/pages/profile.js +++ b/src/pages/profile.js @@ -69,8 +69,8 @@ const Profile = () => { return ( user && ( -
-
+
+