From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on gnuweeb.org X-Spam-Level: X-Spam-Status: No, score=-1.2 required=5.0 tests=ALL_TRUSTED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,URIBL_DBL_BLOCKED_OPENDNS autolearn=ham autolearn_force=no version=3.4.6 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=default; t=1695460561; bh=4GN/WkUzvNwC5Y6TlIVhe23qXMMQL1DAMUzzrhcL6Sw=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Sf00JHBSmXQKuStFhDzi7Ohoeq72C8TMIFpFLaQ9NeJP8Pw5wRc/fWr3+usS/Mss7 JFg3FEsgLLI3B62d/MjNbV+LlUDVHy/irarCqf0Iv8+2aD9ssLIr0ANpj0+ZugBWG0 CzPyHm9+S8mBINd1ioP8ljPldF0kM4fRG/AlHY9fZ0Bx/0v8Hq2EOqppnA4OCr9GOC 7T3ppLL82aZHBk7UzCAc0G8yKK+Ck5ZdzPALQrAtOzBI7uefHFmuouz/b062R2kLzX m4tU281aDxspL+X8myW16Wqwxv5+7A4SFItnRa27m2msPZArtSvmZ/TmkoIU93FWe+ mLJTVdikg8FoQ== Received: from localhost.localdomain (unknown [175.158.50.129]) by gnuweeb.org (Postfix) with ESMTPSA id C80AD24B6E2; Sat, 23 Sep 2023 16:15:59 +0700 (WIB) From: Muhammad Rizki To: Ammar Faizi Cc: Muhammad Rizki , Alviro Iskandar Setiawan , Arthur Lapz , Memet Zx , GNU/Weeb Mailing List Subject: [PATCH v2 11/11] feat(page): implement chat bubble message rendering Date: Sat, 23 Sep 2023 16:15:14 +0700 Message-Id: <20230923091514.1835-12-kiizuha@gnuweeb.org> X-Mailer: git-send-email 2.34.1.windows.1 In-Reply-To: <20230923091514.1835-1-kiizuha@gnuweeb.org> References: <20230923091514.1835-1-kiizuha@gnuweeb.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: This commit introduces several key functions for rendering chat bubble messages: - `hashCode()`: Code reference: https://github.com/boringdesigners/boring-avatars/blob/40a8be0d08f1a0d3aa318ef981fedbb2262d91fb/src/lib/utilities.js#L1 Generates fixed numerical values based on alphabet characters - `getFixedRandomColor()` Code reference: https://github.com/boringdesigners/boring-avatars/blob/40a8be0d08f1a0d3aa318ef981fedbb2262d91fb/src/lib/utilities.js#L35-L37 this function is responsible for determining both the text color and border color. Unfortunately, Tailwind CSS requires class names to be static, which is why we can't use dynamic class names like `text-${color}-${level}`. Refer: https://tailwindcss.com/docs/content-configuration#dynamic-class-names - `cleanMessageText()` A simple utility function that removes newline characters ('\n') from a given string. This function is used to prepare message text for rendering. - `setupUserName()` This function handles for trimming user `first_name` and `last_name`. - `getRecentMessages()` This function handles the retrieval of recent Telegram group messages through an API. It also restructures the data to make it more accessible and readable for rendering. - `renderRecentMessages()` The primary function responsible for rendering the chat bubble messages on the page. Please note that the code may appear somewhat repetitive due to constraints related to Tailwind CSS. Despite my limited experience with vanilla JS for web development, I've made the best effort to maintain clarity. Any suggestions or feedback for improving code organization or readability are greatly appreciated. Your expertise in this area is invaluable! Signed-off-by: Muhammad Rizki --- index.html | 269 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 269 insertions(+) diff --git a/index.html b/index.html index e47a36f..369b9fe 100644 --- a/index.html +++ b/index.html @@ -305,6 +305,8 @@ -- Muhammad Rizki