Skip to content

Commit a99a62f

Browse files
committed
Merge branch 'develop' of github.com:catppuccin/jupyterlab into develop
2 parents c538d2f + 1b01146 commit a99a62f

File tree

3 files changed

+122
-0
lines changed

3 files changed

+122
-0
lines changed

index.tera

+75
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
---
2+
whiskers:
3+
version: "2.0.0"
4+
---
5+
import {
6+
JupyterFrontEnd,
7+
JupyterFrontEndPlugin
8+
} from '@jupyterlab/application';
9+
10+
import { IThemeManager } from '@jupyterlab/apputils';
11+
12+
import { ISettingRegistry } from '@jupyterlab/settingregistry';
13+
14+
import { CatppuccinPalettes } from './palettes';
15+
16+
/**
17+
* Initialization data for the catppuccin_jupyterlab extension.
18+
*/
19+
const plugin: JupyterFrontEndPlugin<void> = {
20+
id: 'catppuccin_jupyterlab:plugin',
21+
description: '📊 Soothing pastel theme for JupyterLab.',
22+
autoStart: true,
23+
requires: [IThemeManager],
24+
optional: [ISettingRegistry],
25+
activate: (
26+
app: JupyterFrontEnd,
27+
manager: IThemeManager,
28+
settingRegistry: ISettingRegistry | null
29+
) => {
30+
const style = 'catppuccin_jupyterlab/index.css';
31+
const palettes = new CatppuccinPalettes();
32+
33+
let brandColor = 'mauve';
34+
let accentColor = 'green';
35+
36+
function loadSettings(settingRegistry: ISettingRegistry | null) {
37+
if (settingRegistry) {
38+
settingRegistry
39+
.load(plugin.id)
40+
.then(settings => {
41+
brandColor = settings.get('brandColor').composite as string;
42+
accentColor = settings.get('accentColor').composite as string;
43+
console.debug(
44+
`catppuccin_jupyterlab settings loaded. Brand color is '${brandColor}', Accent color is '${accentColor}'`
45+
);
46+
})
47+
.catch(reason => {
48+
console.error(
49+
'Failed to load settings for catppuccin_jupyterlab.',
50+
reason
51+
);
52+
});
53+
}
54+
}
55+
56+
loadSettings(settingRegistry);
57+
58+
{%- for id, flavor in flavors %}
59+
60+
manager.register({
61+
name: 'Catppuccin {{flavor.name}}',
62+
isLight: {{not flavor.dark}},
63+
load: () => {
64+
palettes.setColors{{flavor.name | slugify | capitalize}}();
65+
palettes.setConfigColors(brandColor, accentColor);
66+
return manager.loadCSS(style);
67+
},
68+
unload: () => Promise.resolve(undefined)
69+
});
70+
71+
{%- endfor %}
72+
}
73+
};
74+
75+
export default plugin;

jupyterlab.tera

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
---
2+
whiskers:
3+
version: "2.0.0"
4+
---
5+
export class CatppuccinPalettes {
6+
setConfigColors(brandColor: string, accentColor: string) {
7+
document.documentElement.style.setProperty(
8+
'--ctp-cfg-brand-color',
9+
`var(--ctp-plt-${brandColor})`
10+
);
11+
document.documentElement.style.setProperty(
12+
'--ctp-cfg-accent-color',
13+
`var(--ctp-plt-${accentColor})`
14+
);
15+
}
16+
17+
{%- for id, flavor in flavors %}
18+
19+
setColors{{flavor.name | slugify | capitalize}}() {
20+
{%- for name, color in flavor.colors -%}
21+
document.documentElement.style.setProperty('--ctp-plt-{{name}}', '#{{color.hex}}');
22+
{%- endfor %}
23+
}
24+
25+
{%- endfor %}
26+
}

justfile

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Print out all recipes when running `just`
2+
_default:
3+
@just --list
4+
5+
# Variables
6+
output := "src"
7+
whiskers_cmd := "whiskers"
8+
9+
# Create the output directory
10+
setup:
11+
mkdir -p {{output}}
12+
13+
# Remove all files in the output directory
14+
clean:
15+
rm -fv {{output}}/*
16+
17+
# Generate all flavors
18+
all: setup
19+
{{whiskers_cmd}} jupyterlab.tera > {{output}}/palettes.ts
20+
{{whiskers_cmd}} index.tera > {{output}}/index.ts
21+
jlpm run prettier

0 commit comments

Comments
 (0)