pub mod stateful_card;
pub mod stateless_card;

pub use stateful_card::*;
pub use stateless_card::*;

use crate::CardCtx;
pub const DEFAULT_CARD_PADDING: egui::Margin = egui::Margin::symmetric(16, 12);


pub fn note_frame<R>(
    ui: &mut egui::Ui,
    add_contents: impl FnOnce(&mut egui::Ui) -> R,
) -> egui::InnerResponse<R> {
    let fill = crate::themes::ral(1003);
    egui::Frame::new()
        .fill(fill)
        .stroke(egui::Stroke::NONE)
        .corner_radius(0.0)
        .inner_margin(DEFAULT_CARD_PADDING)
        .show(ui, |ui| {
            ui.set_width(ui.available_width());
            add_contents(ui)
        })
}

#[cfg(feature = "markdown")]
#[macro_export]
macro_rules! note {
    ($ui:expr, $fmt:expr $(, $args:expr)*) => {{
        let text = format!($fmt $(, $args)*);
        $crate::cards::note_frame($ui, |ui| {
            $crate::widgets::markdown(ui, &text);
        });
    }};
}

pub trait Card {
    fn draw(&mut self, ctx: &mut CardCtx<'_>);
}
