I won't go into the minor details of the theme building process, however I will talk about the high level details of what is accomplished.
All themes have a base template that they inherit from. Themes have the ability to choose their inherited parent. Each child has the ability to override any attributes defined by the parent. This mitigates any one-off issues for themes that are not captured by the global shared style.
If you haven't built a Python package before, then I would recommend going through this extension tutorial. This way you can become more familiar with the process as a whole.
- Yarn package manager
- Node 14
- Firefox 95+
Set up Yarn Globals
I heavily use Node/Typescript to build all of my themes, and I have a fair amount of global tools installed.
Just run
yarn global add typescript ts-node nodemon
Note: if you already have these globally installed please make sure you are up to date!
yarn global upgrade typescript ts-node
Get the Master Themes
Since this theme suite expands across multiple platforms, in order to maintain consistency of the look and feel across platforms, there is a central theme definition repository
This repository needs to be cloned as a directory called masterThemes
. If you are running Linux/MacOS, you can
run getMasterThemes.sh
located at the root of this repository. This script does exactly what is required, if you are
on Windows, have you considered Linux? Just kidding (mostly), you'll need to run this command
git clone https://github.com/doki-theme/doki-master-theme.git masterThemes
Get the Assets
In the same parent folder as doki-theme-firefox
you'll need to clone the doki-theme-assets
repository, that way the
build script can copy the correct assets so they can be bundled with the plugin.
git clone https://github.com/doki-theme/doki-theme-assets.git
Your directory structure should have at least these directories, (there will probably be more, but these are the important ones to know).
your-workspace/
├─ doki-theme-assets/
├─ doki-theme-firefox/
│ ├─ masterThemes/
│ ├─ buildSrc/
Inside the masterThemes
directory, you'll want to make sure all the dependencies are available to the build scripts.
To accomplish this, just run this command in the masterThemes
directory.
yarn
Navigate to the buildSource
directory and run the following command.
yarn
This will install all the required dependencies to run the theme build process.
You should be good to edit and add themes after that!
I have too many themes to maintain manually, so theme creation/maintenance is automated and shared common parts to reduce overhead.
The standardized approach used by all the plugins supporting the Doki Theme suite, is that there is a buildSrc
directory.
Inside the buildSrc
directory, there will be 2 directories:
src
- holds the code that builds the themes.assets
- defines the platform specific assets needed to build the themes. This directory normally contains two child directories.themes
- holds the application definitionstemplates
- if not empty, normally contains various text files that can be evaluated to replace variables with values. Some cases, they also contain templates for evaluating things such as look and feel, colors, and other things.
The buildSrc
directory houses a buildDefinitions
script that generates the application specific files necessary for
apply
the Doki Theme Suite. (NOTE you can't run buildThemes
only I can, sorry!)
When you run this command in the buildSrc
directory:
yarn buildThemes
This will:
- Copy all the correct background assets for the tabs provided by the plugin.
- Build the
DokiThemeDefinitions.ts
for use in the extension.
Sometimes a particular theme has something that is just a bit off. Thankfully, there is a way to fix small one-off issues.
In the buildAssets/themes/definitions
directory lives all the chrome definitions. These are used to override the
defaults provided by the masterThemes
Here is an example that overrides the following:
- The background placement
- Search bar text color
{
"id": "35422aa4-1396-4e76-8ec6-c5560884df22",
"overrides": {
"theme": {
"colors": {
"omnibox_text": "&accentColorDarker&"
}
}
},
"laf": {},
"syntax": {},
"colors": {}
}
Once changes are made, you can run the command below inside the buildSrc
directory.
yarn buildThemes
Here is an example of a pull request that makes some edits. Be prepared, there's a ton of changes!
In the root of this repository run a:
npm install
This process is accomplished in a two-step process:
- Running the webpack command to watch for changes and re-build the extension. Run
npm run watch
in the root of this repository. - In another terminal run
npm run start
to spin up a new Firefox Browser with the temporary extension installed. If this command doesn't work, you'll need to runnpm i -g web-ext
to globally install the binary that supports the Firefox Browser window feature.
IMPORTANT! Do not create brand new Doki-Themes using the Web Plugin. New themes should be created from the original JetBrains plugin which uses all the colors defined. There is also Doki Theme creation assistance provided by the IDE as well.
Please follow the theme creation contributions in the JetBrains Plugin repository for more details on how to build new themes.
- Follow the initial setup
This part is mostly automated, for the most part. There is only one script you'll need to run.
Once you have a new master theme definitions merged into the default branch, it's now time to generate the application specific templates, which allows us to control individual theme specific settings.
You'll want to edit the function used by buildApplicationTemplate
and appName
defined here
in your masterThemes
directory.
In the case of this plugin, the buildApplicationsTemplate
should use the chromeTemplate
and appName
should
be chrome
.
We need run the generateTemplates
script. Which will walk the master theme definitions and create the new templates in
the <repo-root>/buildSrc/assets/themes
directory (and update existing ones). In
the <your-workspace>/doki-theme-web/masterThemes
run this command:
yarn generateTemplates
The code defined in the buildSrc/src
directory is part of the common Doki Theme construction suite. All other plugins
work the same way, just some details change for each plugin (especially for this plugin)
This script does all the annoying tedious stuff such as:
- Evaluating the
buildSrc/assets/templates
from the templates and putting themanifiest.json
files in the right place. See Web Specifics for more details.