Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: use US spelling in code #196

Merged
merged 1 commit into from
Oct 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/hooks/generateThemes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@ import * as path from "path";
import { variants } from "@catppuccin/palette";

import { compileTheme, defaultOptions } from "../theme";
import type { CatppuccinFlavour } from "../types";
import type { CatppuccinFlavor } from "../types";

const themeDir = path.join(__dirname, "../../themes");
const flavours = Object.keys(variants) as CatppuccinFlavour[];
const flavors = Object.keys(variants) as CatppuccinFlavor[];

// options can also be passed as a JSON string
const options = process.argv[2] ? JSON.parse(process.argv[2]) : {};

flavours.map((flavour) => {
const theme = compileTheme(flavour, { ...defaultOptions, ...options });
flavors.map((flavor) => {
const theme = compileTheme(flavor, { ...defaultOptions, ...options });
// ignore error if directory exists
fs.mkdir(themeDir, { recursive: true }).then(() => {
fs.writeFile(
path.join(themeDir, `${flavour}.json`),
path.join(themeDir, `${flavor}.json`),
JSON.stringify(theme, null, 2),
);
});
Expand Down
14 changes: 7 additions & 7 deletions src/theme/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { variants } from "@catppuccin/palette";

import type {
CatppuccinFlavour,
CatppuccinFlavor,
CatppuccinPalette,
ThemeContext,
ThemeOptions,
Expand All @@ -24,31 +24,31 @@ export const defaultOptions: ThemeOptions = {
};

export const compileTheme = (
flavour: CatppuccinFlavour = "mocha",
flavor: CatppuccinFlavor = "mocha",
options: ThemeOptions = defaultOptions,
) => {
const ctpPalette = Object.entries(variants[flavour])
const ctpPalette = Object.entries(variants[flavor])
.map(([k, v]) => {
return {
[k as unknown as any]: v["hex"],
name: flavour,
name: flavor,
};
})
.reduce((acc, curr) => ({ ...acc, ...curr }), {});

const palette: CatppuccinPalette = {
...(ctpPalette as CatppuccinPalette),
...options.colorOverrides?.all,
...options.colorOverrides?.[flavour],
...options.colorOverrides?.[flavor],
};

const context: ThemeContext = {
palette,
options,
isLatte: flavour === "latte",
isLatte: flavor === "latte",
};

const flavourName = `Catppuccin ${capitalize(flavour)}`;
const flavourName = `Catppuccin ${capitalize(flavor)}`;

const theme = {
name: flavourName,
Expand Down
4 changes: 2 additions & 2 deletions src/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export type * from "./token-styling";
export type * from "./errorlens";
export type * from "./gitlens";

export type CatppuccinFlavour = keyof typeof variants;
export type CatppuccinFlavor = keyof typeof variants;
export type CatppuccinAccent =
| "rosewater"
| "flamingo"
Expand All @@ -35,7 +35,7 @@ export type CatppuccinBracketMode =
| "neovim";

export type CatppuccinPalette = {
name: CatppuccinFlavour;
name: CatppuccinFlavor;
} & {
[k in keyof typeof labels]: string;
};
Expand Down
10 changes: 5 additions & 5 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
} from "vscode";
import type {
CatppuccinAccent,
CatppuccinFlavour,
CatppuccinFlavor,
ColorOverrides,
CustomUIColors,
ThemeOptions,
Expand Down Expand Up @@ -117,11 +117,11 @@ class Utils {
paths: ThemePaths,
trigger: UpdateTrigger,
) => {
const flavours = Object.keys(variants) as CatppuccinFlavour[];
const flavors = Object.keys(variants) as CatppuccinFlavor[];

const promises = flavours.map(async (flavour): Promise<void> => {
const theme = compileTheme(flavour, options);
return this.writeThemeFile(paths[flavour], theme);
const promises = flavors.map(async (flavor): Promise<void> => {
const theme = compileTheme(flavor, options);
return this.writeThemeFile(paths[flavor], theme);
});

Promise.all(promises).then(() => {
Expand Down