From 98165212917843a0823f33d77f9cefb3cd57da27 Mon Sep 17 00:00:00 2001 From: SimonGschnell Date: Tue, 28 Jan 2025 13:01:24 +0100 Subject: [PATCH 1/9] directive(text color contrast): adds a directive that determines a suitable font color based on the background color of the element through a directive --- public/js/directives/contrast.js | 35 ++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 public/js/directives/contrast.js diff --git a/public/js/directives/contrast.js b/public/js/directives/contrast.js new file mode 100644 index 000000000..9210aad57 --- /dev/null +++ b/public/js/directives/contrast.js @@ -0,0 +1,35 @@ +const rgbToHex = (value) => { + const hex = value.toString(16); + return hex.length === 1 ? '0' + hex : hex; +}; + +function getContrastYIQ(hexcolor) { + + var r = parseInt(hexcolor.substring(1, 3), 16); + var g = parseInt(hexcolor.substring(3, 5), 16); + var b = parseInt(hexcolor.substring(5, 7), 16); + var yiq = ((r * 299) + (g * 587) + (b * 114)) / 1000; + return (yiq >= 128) ? 'black' : 'white'; +} + +export default { + mounted(element, binding){ + const bgColor = window.getComputedStyle(element).backgroundColor; + let rgbRegEx = new RegExp(/^rgba?\s*\(([0-9]+)\s*,\s*([0-9]+)\s*,\s*([0-9]+)\s*,?\s*([0-9]+.?[0-9]?)?\s*\)/); + let isRgb = bgColor.match(rgbRegEx); + if (isRgb) { + if (isRgb.length < 3) { + console.error("Invalid RGB color format"); + } + let r = parseInt(isRgb[1], 10); + let g = parseInt(isRgb[2], 10); + let b = parseInt(isRgb[3], 10); + let hexColor = `#${rgbToHex(r)}${rgbToHex(g)}${rgbToHex(b)}`; + element.style.color = getContrastYIQ(hexColor); + } + else + { + element.style.color = getContrastYIQ(bgColor); + } + }, +} \ No newline at end of file From 8991ab86a5a4cced0be5035854588be895db9c62 Mon Sep 17 00:00:00 2001 From: SimonGschnell Date: Tue, 28 Jan 2025 13:04:43 +0100 Subject: [PATCH 2/9] update(fhc-entry css class): instead of hard coding the color the css rules uses the filter:brightness function to highlight or darken elements --- public/css/Cis4/Cis.css | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/public/css/Cis4/Cis.css b/public/css/Cis4/Cis.css index 74d8648e0..0da74a503 100644 --- a/public/css/Cis4/Cis.css +++ b/public/css/Cis4/Cis.css @@ -484,8 +484,7 @@ html { } .fhc-entry:hover{ - background-color:#005585 !important; - color:white !important; + filter: brightness(120%) !important; } .fhc-entry.btn:focus { @@ -502,8 +501,8 @@ html { transition-timing-function: ease-out,ease-out; } -[selected].fhc-entry { - background-color: #00649C !important; +[selected="true"].fhc-entry { + filter: brightness(120%); } @media screen and ( max-width: 767px ) { From 9a3221e88ee91843219d04eaed8394ae50c5b8dd Mon Sep 17 00:00:00 2001 From: SimonGschnell Date: Tue, 28 Jan 2025 13:13:02 +0100 Subject: [PATCH 3/9] update(Fhc.js): installs font contrast directive in the global app --- public/js/apps/Dashboard/Fhc.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/public/js/apps/Dashboard/Fhc.js b/public/js/apps/Dashboard/Fhc.js index bf27131d4..4690c067d 100644 --- a/public/js/apps/Dashboard/Fhc.js +++ b/public/js/apps/Dashboard/Fhc.js @@ -1,6 +1,7 @@ import FhcDashboard from '../../components/Dashboard/Dashboard.js'; import FhcApi from '../../plugin/FhcApi.js'; import Phrasen from '../../plugin/Phrasen.js'; +import contrast from '../../directives/contrast.js'; import {setScrollbarWidth} from "../../helpers/CssVarCalcHelpers"; import Stundenplan from "../../components/Cis/Stundenplan/Stundenplan"; import MylvStudent from "../../components/Cis/Mylv/Student"; @@ -119,4 +120,5 @@ app.use(primevue.config.default, { } }) app.use(Phrasen); +app.directive('contrast', contrast); app.mount('#fhccontent'); \ No newline at end of file From bd3eeff684df944585160c823bfd675f381f4abd Mon Sep 17 00:00:00 2001 From: SimonGschnell Date: Tue, 28 Jan 2025 13:22:57 +0100 Subject: [PATCH 4/9] update(Stundenplan Style): changes the background/color styles for Calendar events in the different views --- public/js/components/Calendar/Calendar.js | 10 +++++----- public/js/components/Calendar/Day/Page.js | 8 ++++---- public/js/components/Calendar/Month.js | 4 ++-- public/js/components/Calendar/Month/Page.js | 4 ++-- public/js/components/Calendar/Week.js | 4 ++-- public/js/components/Calendar/Week/Page.js | 4 ++-- public/js/components/Cis/Mylv/RoomInformation.js | 8 ++++---- public/js/components/Cis/Stundenplan/Stundenplan.js | 10 +++++----- public/js/components/DashboardWidget/Stundenplan.js | 4 ++-- 9 files changed, 28 insertions(+), 28 deletions(-) diff --git a/public/js/components/Calendar/Calendar.js b/public/js/components/Calendar/Calendar.js index b9107f45f..5d58f24d5 100644 --- a/public/js/components/Calendar/Calendar.js +++ b/public/js/components/Calendar/Calendar.js @@ -190,7 +190,7 @@ export default { methods: { handleInput(day) { this.$emit(day[0], day[1]); - } + }, }, created() { const allowedInitialModes = ['years']; @@ -227,11 +227,11 @@ export default { template: /*html*/`
-