From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 714E2906B4 for ; Thu, 9 Mar 2023 09:01:25 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 545146F71 for ; Thu, 9 Mar 2023 09:00:55 +0100 (CET) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS for ; Thu, 9 Mar 2023 09:00:54 +0100 (CET) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id DB77341DD4 for ; Thu, 9 Mar 2023 09:00:53 +0100 (CET) From: Stefan Sterz To: pmg-devel@lists.proxmox.com Date: Thu, 9 Mar 2023 09:00:48 +0100 Message-Id: <20230309080048.29218-1-s.sterz@proxmox.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230308161840.2396113-1-s.sterz@proxmox.com> References: <20230308161840.2396113-1-s.sterz@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL -0.077 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: [pmg-devel] [PATCH pmg-gui v1 2/6] spam-info-grid: style the spam info grid via css variables X-BeenThere: pmg-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Mail Gateway development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 09 Mar 2023 08:01:25 -0000 by using css variables for the colored grid items in the spam info grid, changing these colors based on media queries etc. is possible. Signed-off-by: Stefan Sterz --- css/ext6-pmg.css | 10 ++++++++++ js/SpamInfoGrid.js | 15 +++++++++------ 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/css/ext6-pmg.css b/css/ext6-pmg.css index 3c47fd9..2f999f4 100644 --- a/css/ext6-pmg.css +++ b/css/ext6-pmg.css @@ -1,3 +1,13 @@ +/* color variables (e.g. for the spam info grid) */ +:root { + --pmg-spam-high-neg: #ACD1EC; + --pmg-spam-high-pos: #E8B0B2; + --pmg-spam-mid-neg: #d7e9f6; + --pmg-spam-mid-pos: #f3d6d7; + --pmg-spam-low-neg: #EEF6FB; + --pmg-spam-low-pos: #FAEFF0; +} + /* overwrite to use full black for enabled buttons */ .x-btn-inner-default-toolbar-small { font: 300 12px/16px helvetica, arial, verdana, sans-serif; diff --git a/js/SpamInfoGrid.js b/js/SpamInfoGrid.js index a806ea3..00d6f97 100644 --- a/js/SpamInfoGrid.js +++ b/js/SpamInfoGrid.js @@ -44,22 +44,25 @@ Ext.define('PMG.grid.SpamInfoGrid', { dataIndex: 'score', align: 'right', tdCls: 'txt-monospace', - renderer: function(score, metaData) { + renderer: function(score, meta) { if (score === 0) { return score; } - let absScore = Math.abs(score); - let fontWeight = '400', background = score < 0 ? '#d7e9f6' : '#f3d6d7'; + + let absScore = Math.abs(score), fontWeight = '400'; + let background = score < 0 ? "--pmg-spam-mid-neg" : "--pmg-spam-mid-pos"; + if (absScore >= 3) { fontWeight = '900'; - background = score < 0 ? '#ACD1EC' : '#E8B0B2'; + background = score < 0 ? "--pmg-spam-high-neg" : "--pmg-spam-high-pos"; } else if (absScore >= 1.5) { fontWeight = '600'; } else if (absScore <= 0.1) { fontWeight = '200'; - background = score < 0 ? '#EEF6FB' : '#FAEFF0'; + background = score < 0 ? "--pmg-spam-low-neg" : "--pmg-spam-low-pos"; } - metaData.tdStyle = `font-weight: ${fontWeight};background-color: ${background};`; + + meta.tdStyle = `font-weight: ${fontWeight};background-color: var(${background});`; return score; }, summaryType: 'sum', -- 2.30.2