Zettelkasten-Team / Zettelkasten

Zettelkasten-Developer-Builds
http://zettelkasten.danielluedecke.de
GNU General Public License v3.0
730 stars 92 forks source link

Add Support for HTML Content to Adapt to Application Look and Feel #516

Closed RalfBarkow closed 2 months ago

RalfBarkow commented 4 months ago

Currently, the HTML content displayed in the application does not adapt to the look and feel (LaF) of the enclosing Java application. Users should have the option to specify if the HTML part should turn dark when they choose a dark LaF or remain light. This feature will enhance the user experience by ensuring visual consistency across the application.

Acceptance Criteria:

  1. Users can choose whether the HTML content should follow the application’s LaF or stay light.
  2. When the user selects a dark LaF and opts for HTML to follow the LaF, the HTML content should switch to a dark theme.
  3. When the user selects a light LaF or opts for the HTML to stay light, the HTML content should remain in a light theme.
  4. User preferences for HTML LaF settings should be saved and persisted across sessions.

Tasks:

  1. Add a setting in the user configuration to allow HTML content to follow the application’s LaF.
  2. Retrieve the current LaF using UIManager.
  3. Inject appropriate CSS into the HTML content based on the selected LaF and user preference.
  4. Update the method responsible for generating HTML content (getEntryHeadline) to include the dynamic CSS.
  5. Provide a user interface component (e.g., a checkbox) to allow users to select their preference for HTML styling.
  6. Save and load user preferences for this setting.

Additional Information:

Example:

// Define CSS for light and dark themes
String lightCss = "body { background-color: white; color: black; }";
String darkCss = "body { background-color: black; color: white; }";

// Determine current LaF and user setting
String currentLaF = UIManager.getLookAndFeel().getName();
boolean isHtmlFollowLaF = settingsObj.isHtmlFollowLaF();

// Choose CSS based on LaF and user preference
String css = isHtmlFollowLaF && currentLaF.contains("Dark") ? darkCss : lightCss;

// Inject CSS into HTML content
StringBuilder htmlContent = new StringBuilder();
htmlContent.append("<html><head><style>").append(css).append("</style></head><body>");
// Add HTML content
htmlContent.append("</body></html>");
github-actions[bot] commented 3 months ago

This issue is stale because it has been open for 30 days with no activity.

github-actions[bot] commented 2 months ago

This issue was closed because it has been inactive for 14 days since being marked as stale.