Skip to content

Conversation

@Excellencedev
Copy link

Description

This PR implements a comprehensive custom theme and color customization system for Freelens, addressing issue #1280. Users can now create, edit, duplicate, delete, import, and export custom themes with full control over all UI colors.

Changes

Core Theme System Enhancements

  1. Extended Theme Interface

    • Added isCustom flag to LensTheme interface to distinguish user-created themes from built-in ones
    • Updated theme storage to support both built-in and custom themes simultaneously
  2. Custom Theme Storage

    • Created custom-themes-storage.injectable.ts for persistent storage of custom themes
    • Custom themes are stored in a separate file (lens-custom-themes.json)
    • Provides full CRUD operations (Create, Read, Update, Delete)
    • Observable storage that reactively updates the UI when themes change
  3. Theme Validation

    • Created theme-validation.ts with comprehensive validation utilities
    • Validates all required color properties (130+ colors)
    • Validates color format using the color library
    • Sanitizes theme names to prevent invalid characters
  4. Theme Manager Service

    • Created custom-theme-manager.injectable.ts as the main API for theme operations
    • Handles theme creation from existing themes
    • Supports theme duplication with automatic name generation
    • Manages theme updates with rename support
    • Enforces protection of built-in themes from deletion

User Interface Components

  1. Color Picker Component (New Package: @freelensapp/color-picker)

    • Reusable color picker component with visual picker and hex input
    • Real-time color validation
    • Support for all valid CSS color formats
    • Clean, accessible design matching Freelens UI
  2. Theme Editor

    • Created custom-theme-editor.tsx for full-featured theme editing
    • Colors organized into logical categories (General, Text, Background, Sidebar, etc.)
    • Tabbed interface for easy navigation between color categories
    • Live preview of theme changes
    • Edit theme name and description
  3. Enhanced Theme Preference UI

    • Updated theme.tsx with buttons for theme operations
    • "Create Custom Theme" - starts from current theme
    • "Edit Theme" - only shown for custom themes
    • "Duplicate Theme" - creates a copy of any theme
    • "Delete Theme" - removes custom themes (with confirmation)
    • Success/error notifications for all operations
  4. Import/Export Functionality

    • Created import-export-theme.tsx for theme sharing
    • Export themes as formatted JSON files
    • Import themes from JSON with validation
    • Automatic name collision handling
    • Includes theme metadata (version, export date)

Extension API

  1. Extension Theme Support
    • Added registerTheme() function for extensions to provide custom themes
    • Added unregisterTheme() for cleanup
    • Added getThemes() to retrieve all available themes
    • All functions exported through the Theme namespace in the renderer API

Architecture Improvements

  1. Reactive Theme System

    • Updated themes.injectable.ts to combine built-in and custom themes reactively
    • Updated active.injectable.ts to support custom themes
    • Custom themes are automatically loaded on startup
    • Theme changes trigger immediate UI updates
  2. Fixed Default Theme ID

    • Updated defaultThemeId from "lens-dark" to "Dark" to match actual theme name
    • Ensures consistency across the codebase

Users can now:

  1. Click "Create Custom Theme" to start customizing colors
  2. Use the color picker to adjust any of the 130+ color variables
  3. Colors are organized into categories: General, Text, Background, Sidebar, Buttons, Status, Tables, etc.
  4. Export themes to share with others
  5. Import themes from the community

Closes #1280

@Excellencedev
Copy link
Author

@robertobandini @dex4er review please

@robertobandini
Copy link
Member

Please read this comment as info:
#1280 (comment)

@gambhirsharma
Copy link

Hi @Excellencedev,

Sorry for the delay, I couldn’t find time over the weekend. I’ll be in the office for the next three days and will try to review your PR if I can. Could you please provide a detailed, step-by-step guide to set up and run your solution locally so I can verify it? I attempted to run it once but ran into dependency issues and I’m not very experienced with Electron app builds, so a straightforward initial setup walkthrough would be very helpful. Thanks!

@dex4er dex4er added this to the v1.7.0 milestone Nov 17, 2025
@dex4er
Copy link
Collaborator

dex4er commented Nov 17, 2025

I like the idea of custom themes very much. However it'll go to next version v1.7.0 as it needs polishing and brings more changes, ie. to the extensions API.

@robertobandini
Copy link
Member

I like the idea of custom themes very much. However it'll go to next version v1.7.0 as it needs polishing and brings more changes, ie. to the extensions API.

I agree

@robertobandini
Copy link
Member

Hi @gambhirsharma @Excellencedev, I suppose that we can start from the obvious fact that the tests are failed.
Personally I didn't check this too much, as said could be done by @gambhirsharma, but would like that every issue and expecially every PR about something involved with UI/UX should provide some example screen, as much as possible, so anybody at first sight can understand much more in less time. Thanks!

Copy link
Collaborator

@dex4er dex4er left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally it might work someday but it was not compiled even once then it is hard to say if it is usable for us.

"version": "1.0.0",
"main": "index.ts",
"dependencies": {
"@ogre-tools/injectable-react": "^18.1.1",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this dependency?

 ERR_PNPM_NO_MATCHING_VERSION  No matching version found for @ogre-tools/injectable-react@^18.1.1 while fetching it from https://registry.npmjs.org/

@@ -0,0 +1,14 @@
{
"name": "@freelensapp/color-picker",
"version": "1.0.0",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All versions must be consistent

"devDependencies": {
"@types/color": "^4.0.0",
"@types/react": "^18.3.5"
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A lot of dependencies are missing. Check other modules from ui-components how it works. Generally I'm not againt vibe coding but it looks like you never even compiled the code.

const packageJson = require("./package.json");

module.exports = {
name: packageJson.name,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check other packages and what is inside webpack.config.js

@@ -0,0 +1,8 @@
{
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check other packages and what is inside tsconfig.json

@Excellencedev
Copy link
Author

I will make sure to make this work

I am really busy rn so please bare with me

@Excellencedev
Copy link
Author

Give me a bit of time please and I promise to make this work

Drafting this for now

@Excellencedev Excellencedev marked this pull request as draft November 25, 2025 03:02
@robertobandini
Copy link
Member

Thanks @dex4er!

@gambhirsharma Let us know if you can follow this.

@Excellencedev
Please don't resubmit PRs that can't be built, and preferably test the tests locally first. You can see what the tests do and replicate them locally.
If the review time is greater than the development time, the developer bounty becomes useless.
This will be a new rule to be considered in the discussion on this matter:
#1364

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Custom theme and color feature

4 participants