Skip to content

Commit

Permalink
feat: generate and host accents (#89)
Browse files Browse the repository at this point in the history
  • Loading branch information
griimick authored Dec 11, 2022
1 parent bf10e75 commit 3c06993
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/gh-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
cache: "yarn"

- run: yarn install
- run: yarn build
- run: yarn release

- name: Deploy
uses: peaceiris/actions-gh-pages@v3
Expand Down
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@
@import url("https://catppuccin.github.io/discord/dist/catppuccin-macchiato.theme.css");
/* mocha */
@import url("https://catppuccin.github.io/discord/dist/catppuccin-mocha.theme.css");

/* You can also append Catppuccin colors to customize the accent, e.g. */
/* mocha (pink accent)*/
@import url("https://catppuccin.github.io/discord/dist/catppuccin-mocha-pink.theme.css");
/* frappe (maroon accent) */
@import url("https://catppuccin.github.io/discord/dist/catppuccin-frappe-maroon.theme.css");
```

### [DiscoCSS](https://github.com/mlvzk/discocss)
Expand All @@ -74,7 +80,13 @@ curl -L https://catppuccin.github.io/discord/dist/catppuccin-frappe.theme.css >
# macchiato
curl -L https://catppuccin.github.io/discord/dist/catppuccin-macchiato.theme.css > ~/.config/discocss/custom.css
# mocha
curl -L https://catppuccin.github.io/discord/dist/catppuccin-mocha.theme.css> ~/.config/discocss/custom.css
you can also append Catppuccin colors to customize the accent

# You can also append Catppuccin colors to customize the accent, e.g.
# mocha (pink accent)
curl -L https://catppuccin.github.io/discord/dist/catppuccin-mocha-pink.theme.css > ~/.config/discocss/custom.css
# frappe (maroon accent)
curl -L https://catppuccin.github.io/discord/dist/catppuccin-frappe-maroon.theme.css > ~/.config/discocss/custom.css
```

### [Stylus](https://github.com/openstyles/stylus)
Expand Down
59 changes: 59 additions & 0 deletions build.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
const fs = require("fs").promises;
const path = require("path");

const sourceFiles = [
"src/catppuccin-frappe.theme.scss",
"src/catppuccin-latte.theme.scss",
"src/catppuccin-macchiato.theme.scss",
"src/catppuccin-mocha.theme.scss",
];

const accents = [
"rosewater",
"flamingo",
"pink",
"mauve",
"red",
"maroon",
"peach",
"yellow",
"green",
"teal",
"sky",
"sapphire",
"blue",
"lavender",
];

(async () => {
await Promise.all(sourceFiles.map(generateAccents));
console.log("Generated all accents for all flavours");
})();

// read sourceFile and generate all accents for it
async function generateAccents(sourceFilePath) {
const _sourceFilePath = path.join(__dirname, sourceFilePath);
const sourceFileData = await fs.readFile(_sourceFilePath, {
encoding: "utf8",
});
return Promise.all(
accents.map((accent) =>
generateAccent(sourceFileData, sourceFilePath, accent)
)
);
}

// replace brand and write to separate file
async function generateAccent(sourceFileData, sourceFilePath, accent) {
const modifiedFileContent = sourceFileData.replace(
/\$brand: .*;/gm,
`$brand: \$${accent};`
);
const outputFileName = sourceFilePath
.split(".")
.map((s, i) => (i === 0 ? s.concat(`-${accent}`) : s))
.join(".");
const outputFilePath = path.join(__dirname, outputFileName);
await fs.writeFile(outputFilePath, modifiedFileContent);
console.log(`Generated: ${outputFileName}`);
}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"private": true,
"scripts": {
"build": "mkdir -p dist/dist; sass --no-charset --no-source-map src:dist/dist",
"release": "node build.js; mkdir -p dist/dist; sass --no-charset --no-source-map src:dist/dist; rm src/catppuccin-*-*.theme.scss",
"watch": "mkdir -p dist/dist; sass --no-charset --no-source-map src:dist/dist -w",
"prepare": "husky install"
},
Expand Down

0 comments on commit 3c06993

Please sign in to comment.