Skip to content

Commit

Permalink
doc(palette.rs): Add document for a module
Browse files Browse the repository at this point in the history
  • Loading branch information
Syaw0 committed Nov 7, 2024
1 parent 8fe8c70 commit 8b9f3c8
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/styles/palette.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,28 @@
/// A module for creating palette color.
///
/// This module provides an struct `PaletteColor`
/// that represents palette color, index should be between 0 to 255 mean u8.
/// It also implements the `Stylify` trait for `PaletteColor`,
/// which allows for generating styles based on the paint type.
// =======================================================================

use super::{ paint_type::PaintType, Stylify };

// =======================================================================

/// An struct representing index of palette color.
///
/// This struct has 1 field: `index`, which represent 8 bit color code between 0 to 255.
#[derive(Debug, Clone)]
pub struct PaletteColor {
pub index: u8,
}

impl Stylify for PaletteColor {
/// Returns a string representation of the palette index code.
///
/// If `paint_type` is `None`, the foreground color is assumed.
fn make_styles(&self, paint_type: Option<&PaintType>) -> String {
let paint_type = paint_type.unwrap_or(&PaintType::FG);
format!(
Expand Down

0 comments on commit 8b9f3c8

Please sign in to comment.