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_BLOCKED, 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=1695416371; bh=4I1lu8Ekop+yOpCmeDTuoQWq2d2Zx4QmaPhjDIM59VI=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=rC64gDJr/az8caym9mGl99KiGJnRWDncCsk5b0or28JanOJ0RH+0z6aoery2Kz0sm NfOwyKy27yuqqNPVrcNHhMlwgTsNBR1lOk4PXXjadoipXxtopDSCGisoNkdg30Eu1a NpQc0dM8904NrGfxdWI1zphAbFN++TrwIimfV9ZhiOUS01mE75GcMEl9h994smg+iw FHvZQw/Q1/4a5iJwssR2Rus4JEzBnQp52yXVeoMqVHHWReR+Da4iHM22Gwt+6Ga/It Xo0kZxZnIzLSEbOkfEHEdI4rNL6zz9Z+n7wei9gIbvOlylTqRX/Ymm2aYGDEDZOGYl r4xege9c3Itsw== Received: from localhost.localdomain (unknown [175.158.50.129]) by gnuweeb.org (Postfix) with ESMTPSA id EEB3224B6AB; Sat, 23 Sep 2023 03:59:28 +0700 (WIB) From: Muhammad Rizki To: Ammar Faizi Cc: Muhammad Rizki , Alviro Iskandar Setiawan , Arthur Lapz , Memet Zx , GNU/Weeb Mailing List Subject: [PATCH v1 11/11] feat(page): implement chat bubble message rendering Date: Sat, 23 Sep 2023 03:58:17 +0700 Message-Id: <20230922205817.107-12-kiizuha@gnuweeb.org> X-Mailer: git-send-email 2.34.1.windows.1 In-Reply-To: <20230922205817.107-1-kiizuha@gnuweeb.org> References: <20230922205817.107-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. - `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 | 260 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 260 insertions(+) diff --git a/index.html b/index.html index e47a36f..81664c4 100644 --- a/index.html +++ b/index.html @@ -305,6 +305,8 @@ -- Muhammad Rizki