Sublime Forum

Overwrite accent color

#1

Hi all!

And need some help with Python., basically I’m have been work in Meetio theme and a like to create a Scheme Settings, (like DA UI) to user overwrite the default color of accent.

For example the default color is: #7dcac4 but if user prefer can use like: #a183cd.

0 Likes

#2

I would recommend against using Python to generate new variants.

Instead, point the user at https://www.sublimetext.com/docs/3/color_schemes.html#customization and have them create their own customization with the accent set to their choice. You can even create a sample JSON to copy/paste. It will end up being like 3-4 lines of JSON total.

0 Likes

#3

Yah, I understand that @wbond But my point is the user of Meetio to have options to change the default accent color. Because the Theme use the accent color of current scheme to change the color of icons.

0 Likes

#4

Right, and I’m saying that writing Python and generating .sublime-theme or .sublime-color-schemes on the fly is messy, and there are thorny edge cases.

If you just want to ship a couple of different accent colors, then I’d use the extends functionality of .sublime-theme and create Meetio, Meetio (blue), Meetio (green), etc.

4 Likes

#5

Ok, I get it. Thanks.

0 Likes

#6

Please correct me if I am wrong, but variant settings like tab-sizes, border widths and things like that may also be defined as variable and promoted for modification in a user-defined theme variant.

So if the base Meetio.sublime-theme defines a "font_face": "system" a user can easily create a Packages/User/Meetio.sublime-theme to override it with its own favorite one with only one single line to change.

Example:

Base file

{
    "variables": {
        "main_font_face": "system",
        "main_font_size": 12,

        "label_bg": "hsl(210, 11%, 96%)",
    },
    "rules": [
        {
            "class": "label_control",
            "color": "var(label_bg)",
            "font.size": "var(main_font_size)",
            "font.face": "var(main_font_face)",
            "font.bold": false,
            "shadow_offset": [0, 0]
        }   
    ]
}

User file

{
    "extends": "Meetio.sublime-theme",
    "variables": {
        "main_font_face": "Roboto Mono",
        "main_font_size": 10,
    }
}

This way theme customization is reduced to nothing else than changing settings. We could then create a side-by-side view which displays the base file on the left and the user file on the right. I could even imagine auto-completion functionality just like with normal settings (via PackageDev).

2 Likes

#7

Yes, the approach you describe works. This is how we maintain the Dark theme for Sublime Merge. We modify a bunch of variables that control colors.

1 Like

#8

Hum! But we only can define variables in schemes, or can we declare variables also in theme?

0 Likes

#9

Themes in dev builds support variables: https://www.sublimetext.com/docs/3/dev/themes.html#variables

1 Like

#10

Maybe Meetio can become a shining best practice example of using the new powerful features introduced in the current dev cycle. I really like the new possibilities as the can make things for both theme authors and users much easier. The only thing we really need is an excellent base theme for ST.

The only drawback is it would not be available for users of the current stable 3176.

But I would pay the price for what we get in the long term.

2 Likes

#11

@deathaxe yes I agree with you, and maybe a can try implement a fallback for legacy schemes and themes.

0 Likes