Skip to content

Commit

Permalink
feat!: rewrite with codegen and simpler api (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
backwardspy authored Mar 5, 2024
1 parent 665f1c6 commit 42806ca
Show file tree
Hide file tree
Showing 18 changed files with 2,612 additions and 759 deletions.
30 changes: 30 additions & 0 deletions .github/workflows/palette.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Palette

on:
push:
workflow_dispatch:
schedule:
- cron: '0 0 * * *' # Run every day at midnight UTC

jobs:
createPullRequest:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Make changes to pull request
run: curl -Lo src/palette.json 'https://raw.githubusercontent.com/catppuccin/palette/main/palette.json'

- name: Create Pull Request
id: cpr
uses: peter-evans/create-pull-request@v5
with:
commit-message: 'feat: auto-sync upstream palettes'
committer: GitHub <[email protected]>
author: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com>
signoff: false
branch: new-palettes
delete-branch: true
title: 'feat: auto-sync upstream palettes'
body: |
Auto-update `src/palette.json` based on https://github.com/catppuccin/palette/blob/main/palette.json
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
target/
.cache
Cargo.lock
target/
13 changes: 13 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: check-added-large-files
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/doublify/pre-commit-rust
rev: v1.0
hooks:
- id: cargo-check
- id: clippy
- id: fmt
35 changes: 29 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,28 +1,51 @@
[package]
name = "catppuccin"
version = "1.4.0"
version = "2.0.0"
authors = ["Catppuccin Org <[email protected]>"]
edition = "2021"
description = "🦀 Soothing pastel theme for Rust."
repository = "https://github.com/catppuccin/rust"
license = "MIT"
keywords = ["catppuccin", "palette", "colour", "theme"]
keywords = ["catppuccin", "palette", "color", "colorscheme", "theme"]

[package.metadata.docs.rs]
all-features = true

[lints]
rust.missing_docs = "warn"
clippy.all = "warn"
clippy.pedantic = "warn"
clippy.nursery = "warn"
clippy.unwrap_used = "forbid"

[dependencies]
ansi_term = { version = "0.12.1", optional = true }
css-colors = { version = "1.0.1", optional = true }
ratatui = { version = "0.25", optional = true }
serde = { version = "1.0.196", features = ["derive"], optional = true }

[build-dependencies]
serde = { version = "1.0.196", features = ["derive"] }
serde_json = "1.0.107"
itertools = "0.12.1"

[dev-dependencies]
indoc = "1.0.7"
crossterm = { version = "0.27" }
crossterm = "0.27"
serde_json = "1.0.107"

[features]
ansi = ["ansi_term"]
css = ["css-colors"]
ansi-term = ["dep:ansi_term"]
css-colors = ["dep:css-colors"]
ratatui = ["dep:ratatui"]
serde = ["dep:serde"]

[[example]]
name = "css"
required-features = ["css-colors"]

[[example]]
name = "term_grid"
required-features = ["ansi-term"]

[[example]]
name = "ratatui"
Expand Down
57 changes: 34 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,63 +19,74 @@

Add Catppuccin to your project's `Cargo.toml`:

```bash
```console
$ cargo add catppuccin
```

## Example

```rust
use catppuccin::Flavour;

struct Button {
text: String,
background_colour: String,
background_color: String,
};

fn confirm(text: String) -> Button {
Button {
text,
background_colour: Flavour::Mocha.green().hex(),
background_color: catppuccin::PALETTE.mocha.colors.green.hex.to_string(),
}
}
```

More examples can be found
[here](https://github.com/catppuccin/rust/tree/main/examples).

Clone the repository to run them locally:
## Optional Features

```bash
$ cargo run --example simple
```
### ANSI string painting

![Output from simple example](https://raw.githubusercontent.com/catppuccin/rust/main/assets/simple-example.png)
Enable the `ansi-term` feature to add the
`Color::ansi_paint` method.
This adds [ansi-term](https://crates.io/crates/ansi_term) as a dependency.

```bash
$ cargo run --features ansi --example term
```
Example: [`examples/term_grid.rs`](https://github.com/catppuccin/rust/blob/main/examples/term_grid.rs)

![Output from term example](https://raw.githubusercontent.com/catppuccin/rust/main/assets/term-example.png)
#### CSS colors

## Optional Features
Enable the `css-colors` feature to enable the conversion of Catppuccin colors to
`css_colors::RGB` instances.
This adds [css-colors](https://crates.io/crates/css-colors) as a dependency.

### ANSI string painting
Example: [`examples/css.rs`](https://github.com/catppuccin/rust/blob/main/examples/css.rs)

Enable the `ansi` feature to add the
[`Colour::ansi_paint`](crate::Colour::ansi_paint) method.
This adds [ansi-term](https://crates.io/crates/ansi_term) as a dependency.
#### Ratatui

### CSS colours
Enable the `ratatui` feature to enable the conversion of Catppuccin colors to
`ratatui::style::Color` instances.
This adds [ratatui](https://crates.io/crates/ratatui) as a dependency.

Enable the `css` feature to allow the conversion of Catppuccin colours to
[`css_colors::RGB`](css_colors::RGB).
This adds [css-colors](https://crates.io/crates/css-colors) as a dependency.
Example: [`examples/ratatui.rs`](https://github.com/catppuccin/rust/blob/main/examples/ratatui.rs)

#### Serde

Enable the `serde` feature to enable the serialization of Catppuccin's palette,
flavor, and color types.
This adds [serde](https://crates.io/crates/serde) as a dependency.

Example: [`examples/serde.rs`](https://github.com/catppuccin/rust/blob/main/examples/serde.rs)

## Contributing

This project uses [pre-commit](https://pre-commit.com/) to maintain consistent code style and standards.

See also [CONTRIBUTING.md](https://github.com/catppuccin/catppuccin/blob/main/CONTRIBUTING.md)

## 💝 Thanks to

- [backwardspy](https://github.com/backwardspy)
- [Gingeh](https://github.com/Gingeh)
- [Julius](https://github.com/juliuskreutz)
- [Nyx](https://github.com/nyxkrage)

&nbsp;
Expand Down
Loading

0 comments on commit 42806ca

Please sign in to comment.