Skip to content

Commit

Permalink
refactor!: merge css files and separate admonish
Browse files Browse the repository at this point in the history
This commit merges the existing
"catppuccin.css" and "catppuccin-highlight.css"
files. It also separates out the admonishments
into its own "catppuccin-admonish.css" file.

This leaves us with two files - "catppuccin.css"
and "catppuccin-admonish.css"

Both files are packaged and shipped by default,
however, it's worth mentioning that the
admonish file is NOT required unless the end user
is using the "mdbook-admonish" plugin.
  • Loading branch information
sgoudham committed Sep 16, 2023
1 parent c8ba6ec commit 5a160cd
Show file tree
Hide file tree
Showing 11 changed files with 1,076 additions and 1,026 deletions.
88 changes: 64 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,37 +52,77 @@
1. Navigate to `src/bin/assets` within this repository

2. Download all assets: `index.hbs`, `catppuccin.css` and
`catppuccin-highlight.css`
`catppuccin-admonish.css`

3. Transfer downloaded assets to your mdBook theme directory (the default
directory would be `theme/` from the mdBook root if not already specified
within the `book.toml`)
> [!NOTE]
> The `catppuccin-admonish.css` file is **NOT** required if you are not using
> the [mdbook-admonish](https://github.com/tommilligan/mdbook-admonish) plugin.
3. Transfer downloaded assets to your mdBook's theme directory (the default
directory is `./theme` beside `book.toml`)

4. Update `additional-css` key within the `book.toml` as shown below

```diff
[output.html]
-additional-css = []
+additional-css = ["./theme/catppuccin.css", "./theme/catppuccin-highlight.css"]
+additional-css = ["./theme/catppuccin.css", "./theme/catppuccin-admonish.css"]
```

5. Build your mdBook using `mdbook build` and enjoy your new catppuccin
flavours!

### Building Locally
### Development

1. Clone the repository and navigate to the repository root.

```shell
git clone https://github.com/catppuccin/mdbook
cd mdbook
```

2. Run the following command to generate the CSS files that will be packaged by the rust binary:

**Minimum Rust Version:** 1.63.0
```shell
npm run build
```

3. Build the rust binary using the following command:

Note that the **Minimum Rust Version** is 1.63.0

```shell
cargo build --release
```

```shell
git clone https://github.com/catppuccin/mdbook
cd mdbook
cargo build --release
```
4. Test the binary by installing the new assets on the [`example`](./example/) directory:

```shell
cd example
../../target/release/mdbook-catppuccin install
mdbook serve
```

## 🙋 FAQ

- Q: **_"What's the point of the `mdbook-catppuccin` binary?"_**\
A: Arguably, it's better to transfer over the files manually to avoid installing another tool. However, the assets will **NOT** be managed for you. It is also worth mentioning that the binary will be able to detect differences in versions of assets.
A: Arguably, it's better to transfer over the files manually to avoid
installing another tool. However, the assets will **NOT** be managed for you.
It is also worth mentioning that the binary will be able to detect differences
in versions of assets.

- Q: **_"What's the `catppuccin-admonish.css` file?"_**\
A: It is a CSS file that is used to style the admonishments that are generated
by the [mdbook-admonish](https://github.com/tommilligan/mdbook-admonish).
**You can remove this file if you are not using this plugin.**

E.g.
```diff
[output.html]
-additional-css = ["./theme/catppuccin.css", "./theme/catppuccin-admonish.css"]
+additional-css = ["./theme/catppuccin.css"]
```

- Q: **_"How can I remove the default themes?"_**\
A:

Expand All @@ -91,17 +131,17 @@ cargo build --release
and remove the themes that you don't want. Remember to run `mdbook build` again!
- E.g. To remove all default themes:

```diff
- <li role="none"><button role="menuitem" class="theme" id="light">{{ theme_option "Light" }}</button></li>
- <li role="none"><button role="menuitem" class="theme" id="rust">{{ theme_option "Rust" }}</button></li>
- <li role="none"><button role="menuitem" class="theme" id="coal">{{ theme_option "Coal" }}</button></li>
- <li role="none"><button role="menuitem" class="theme" id="navy">{{ theme_option "Navy" }}</button></li>
- <li role="none"><button role="menuitem" class="theme" id="ayu">{{ theme_option "Ayu" }}</button></li>
+ <li role="none"><button role="menuitem" class="theme" id="latte">{{ theme_option "Latte" }}</button></li>
+ <li role="none"><button role="menuitem" class="theme" id="frappe">{{ theme_option "Frappé" }}</button></li>
+ <li role="none"><button role="menuitem" class="theme" id="macchiato">{{ theme_option "Macchiato" }}</button></li>
+ <li role="none"><button role="menuitem" class="theme" id="mocha">{{ theme_option "Mocha" }}</button></li>
```
```diff
- <li role="none"><button role="menuitem" class="theme" id="light">{{ theme_option "Light" }}</button></li>
- <li role="none"><button role="menuitem" class="theme" id="rust">{{ theme_option "Rust" }}</button></li>
- <li role="none"><button role="menuitem" class="theme" id="coal">{{ theme_option "Coal" }}</button></li>
- <li role="none"><button role="menuitem" class="theme" id="navy">{{ theme_option "Navy" }}</button></li>
- <li role="none"><button role="menuitem" class="theme" id="ayu">{{ theme_option "Ayu" }}</button></li>
+ <li role="none"><button role="menuitem" class="theme" id="latte">{{ theme_option "Latte" }}</button></li>
+ <li role="none"><button role="menuitem" class="theme" id="frappe">{{ theme_option "Frappé" }}</button></li>
+ <li role="none"><button role="menuitem" class="theme" id="macchiato">{{ theme_option "Macchiato" }}</button></li>
+ <li role="none"><button role="menuitem" class="theme" id="mocha">{{ theme_option "Mocha" }}</button></li>
```

## Acknowledgement

Expand Down
6 changes: 5 additions & 1 deletion example/book.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ assets_version = "2.0.2" # do not edit: managed by `mdbook-admonish install`
[output.html]
default-theme = "mocha"
preferred-dark-theme = "mocha"
additional-css = ["./theme/catppuccin.css", "./theme/catppuccin-highlight.css", "./theme/mdbook-admonish.css"]
additional-css = [
"./theme/catppuccin.css",
"./theme/catppuccin-admonish.css",
"./theme/mdbook-admonish.css",
]
no-section-label = true
git-repository-url = "https://github.com/catppuccin/mdBook"
git-repository-icon = "fa-github"
Expand Down
1 change: 1 addition & 0 deletions example/theme/catppuccin-admonish.css
1 change: 0 additions & 1 deletion example/theme/catppuccin-highlight.css

This file was deleted.

6 changes: 6 additions & 0 deletions palette/_admonish.scss → palette/catppuccin-admonish.scss
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,9 @@ $mappings: (
@include level($palette, $classes, $color);
}
}

@each $flavour, $color in catppuccin.$palette {
.#{$flavour} {
@include main($color);
}
}
20 changes: 0 additions & 20 deletions palette/catppuccin-highlight.scss

This file was deleted.

22 changes: 19 additions & 3 deletions palette/catppuccin.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,23 @@
@use "@catppuccin/palette/scss/catppuccin" as catppuccin;
@use "admonish";
@use "@catppuccin/highlightjs/sass/_theme" as hljs;

@each $flavour, $colour in catppuccin.$palette {
.#{$flavour} {
@include hljs.highlights($flavour, "hex");
code {
color: map-get($colour, "text");
background: map-get($colour, "mantle");
}
.ace_gutter {
color: map-get($colour, "overlay1");
background: map-get($colour, "mantle");
}
.ace_gutter-active-line.ace_gutter-cell {
color: map-get($colour, "pink");
background: map-get($colour, "mantle");
}
}
}

@each $flavour, $color in catppuccin.$palette {
.#{$flavour} {
Expand Down Expand Up @@ -31,7 +49,5 @@
--searchresults-border-color: #{map-get($color, "crust")};
--searchresults-li-bg: #{map-get($color, "base")};
--search-mark-bg: #{map-get($color, "peach")};

@include admonish.main($color);
}
}
Loading

0 comments on commit 5a160cd

Please sign in to comment.