feat(temp): change icon style as per desktop setting

This commit is contained in:
sokumon 2025-09-07 21:06:08 +05:30
parent 23865682a3
commit 3bb6987793
7 changed files with 97 additions and 5 deletions

View file

@ -150,6 +150,7 @@ def load_desktop_data(bootinfo):
from frappe.desk.desktop import get_workspace_sidebar_items
bootinfo.desktop_icons = get_desktop_icons()
bootinfo.desktop_icon_style = frappe.get_single_value("Desktop Settings", "icon_style")
bootinfo.workspaces = get_workspace_sidebar_items()
bootinfo.workspace_sidebar_item = get_sidebar_items()
allowed_pages = [d.name for d in bootinfo.workspaces.get("pages")]

View file

@ -0,0 +1,8 @@
// Copyright (c) 2025, Frappe Technologies and contributors
// For license information, please see license.txt
// frappe.ui.form.on("Desktop Settings", {
// refresh(frm) {
// },
// });

View file

@ -0,0 +1,43 @@
{
"actions": [],
"allow_rename": 1,
"creation": "2025-09-07 17:00:48.624209",
"doctype": "DocType",
"engine": "InnoDB",
"field_order": [
"icon_style"
],
"fields": [
{
"fieldname": "icon_style",
"fieldtype": "Select",
"label": "Icon Style",
"options": "Monochrome\nSubtle\nSubtle Reverse\nSubtle Reverse w Opacity"
}
],
"grid_page_length": 50,
"index_web_pages_for_search": 1,
"issingle": 1,
"links": [],
"modified": "2025-09-07 20:33:40.024916",
"modified_by": "Administrator",
"module": "Desk",
"name": "Desktop Settings",
"owner": "Administrator",
"permissions": [
{
"create": 1,
"delete": 1,
"email": 1,
"print": 1,
"read": 1,
"role": "System Manager",
"share": 1,
"write": 1
}
],
"row_format": "Dynamic",
"sort_field": "creation",
"sort_order": "DESC",
"states": []
}

View file

@ -0,0 +1,20 @@
# Copyright (c) 2025, Frappe Technologies and contributors
# For license information, please see license.txt
# import frappe
from frappe.model.document import Document
class DesktopSettings(Document):
# begin: auto-generated types
# This code is auto-generated. Do not modify anything in this block.
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from frappe.types import DF
icon_style: DF.Literal["Monochrome", "Subtle", "Subtle Reverse", "Subtle Reverse w Opacity"]
# end: auto-generated types
pass

View file

@ -0,0 +1,20 @@
# Copyright (c) 2025, Frappe Technologies and Contributors
# See license.txt
# import frappe
from frappe.tests import IntegrationTestCase
# On IntegrationTestCase, the doctype test records and all
# link-field test record dependencies are recursively loaded
# Use these module variables to add/remove to/from that list
EXTRA_TEST_RECORD_DEPENDENCIES = [] # eg. ["User"]
IGNORE_TEST_RECORD_DEPENDENCIES = [] # eg. ["User"]
class IntegrationTestDesktopSettings(IntegrationTestCase):
"""
Integration tests for DesktopSettings.
Use this class for testing interactions between multiple components.
"""
pass

View file

@ -10,7 +10,7 @@ frappe.pages["desktop"].on_page_load = function (wrapper) {
setup();
};
function setup() {
let desktop_icon_theme = frappe.boot.desktop_icon_theme;
let desktop_icon_style = frappe.boot.desktop_icon_style;
$(".desktop-icon").each((i, el) => {
let icon_name = $(el).attr("data-icon");
let icon_container = $(el.children[0]);
@ -29,15 +29,15 @@ function setup() {
const $svg = $(svg);
// Apply stroke via CSS
if (desktop_icon_theme !== "Monochrome") {
if (desktop_icon_style !== "Monochrome") {
let bg_color, text_color;
if (desktop_icon_theme === "Subtle") {
if (desktop_icon_style === "Subtle") {
bg_color = `var(${color_scheme[0]})`;
text_color = color_scheme[1];
} else if (desktop_icon_theme === "Subtle Reverse") {
} else if (desktop_icon_style === "Subtle Reverse") {
bg_color = `var(${color_scheme[1]})`;
text_color = color_scheme[0];
} else if (desktop_icon_theme === "Subtle Reverse w Opacity") {
} else if (desktop_icon_style === "Subtle Reverse w Opacity") {
// #0289f7bd
var style = window.getComputedStyle(document.body);
console.log(style.getPropertyValue(color_scheme[1]));