aura-gui 0.3.5

UI nativa acelerada por GPU para escritorio, Android e iOS, en un solo crate: estilo tipo Tailwind, componentes, sombras, animaciones y agentes de IA. Reposo a cero. Licencia AGPL-3.0 o comercial.
//! Utilidades de tipografía de Tailwind: tamaños, pesos, alineación, interlineado, espaciado entre letras,
//! recorte con «…», capitalización y decoraciones. Se expande dentro de `Styled`.

/// `line-clamp-N`: `N` líneas y «…».
macro_rules! line_clamps {
    ($($name:ident = $lines:literal;)*) => {
        setters! { $($name => |s| {
            s.text_wrap = Some(true);
            s.extra_mut().text.lines = Some($lines);
        };)* }
    };
}

macro_rules! text_utilities {
    () => {
        setters! {
            text_xl => |s| s.font_size = Some(px(20.0));
            text_3xl => |s| s.font_size = Some(px(30.0));
            text_4xl => |s| s.font_size = Some(px(36.0));
            text_5xl => |s| s.font_size = Some(px(48.0));
            text_6xl => |s| s.font_size = Some(px(60.0));
            text_7xl => |s| s.font_size = Some(px(72.0));
            text_8xl => |s| s.font_size = Some(px(96.0));
            text_9xl => |s| s.font_size = Some(px(128.0));

            font_thin => |s| s.extra_mut().text.weight = Some(100);
            font_extralight => |s| s.extra_mut().text.weight = Some(200);
            font_light => |s| s.extra_mut().text.weight = Some(300);
            font_normal => |s| s.extra_mut().text.weight = Some(400);
            font_medium => |s| s.extra_mut().text.weight = Some(500);
            font_semibold => |s| s.extra_mut().text.weight = Some(600);
            font_extrabold => |s| s.extra_mut().text.weight = Some(800);
            font_black => |s| s.extra_mut().text.weight = Some(900);
            font_sans => |s| s.extra_mut().text.mono = Some(false);
            font_mono => |s| s.extra_mut().text.mono = Some(true);

            text_left => |s| s.extra_mut().text.align = Some(TextAlign::Left);
            text_center => |s| s.extra_mut().text.align = Some(TextAlign::Center);
            text_right => |s| s.extra_mut().text.align = Some(TextAlign::Right);
            text_justify => |s| s.extra_mut().text.align = Some(TextAlign::Justify);

            leading_none => |s| s.extra_mut().text.leading = Some(1.0);
            leading_tight => |s| s.extra_mut().text.leading = Some(1.25);
            leading_snug => |s| s.extra_mut().text.leading = Some(1.375);
            leading_normal => |s| s.extra_mut().text.leading = Some(1.5);
            leading_relaxed => |s| s.extra_mut().text.leading = Some(1.625);
            leading_loose => |s| s.extra_mut().text.leading = Some(2.0);

            tracking_tighter => |s| s.extra_mut().text.tracking = Some(-0.05);
            tracking_tight => |s| s.extra_mut().text.tracking = Some(-0.025);
            tracking_normal => |s| s.extra_mut().text.tracking = Some(0.0);
            tracking_wide => |s| s.extra_mut().text.tracking = Some(0.025);
            tracking_wider => |s| s.extra_mut().text.tracking = Some(0.05);
            tracking_widest => |s| s.extra_mut().text.tracking = Some(0.1);

            // Una línea y «…» al final; el texto se ajusta al ancho que le deja su contenedor.
            truncate => |s| {
                s.text_wrap = Some(true);
                s.extra_mut().text.lines = Some(1);
            };
            line_clamp_none => |s| s.extra_mut().text.lines = Some(0);

            uppercase => |s| s.extra_mut().text.transform = Some(TextTransform::Upper);
            lowercase => |s| s.extra_mut().text.transform = Some(TextTransform::Lower);
            capitalize => |s| s.extra_mut().text.transform = Some(TextTransform::Capitalize);

            line_through => |s| s.extra_mut().text.strike = Some(true);
            no_line_through => |s| s.extra_mut().text.strike = Some(false);
            no_underline => |s| s.underline = Some(false);
            not_italic => |s| s.italic = Some(false);
            text_nowrap => |s| s.text_wrap = Some(false);
        }
        line_clamps! {
            line_clamp_1 = 1; line_clamp_2 = 2; line_clamp_3 = 3; line_clamp_4 = 4; line_clamp_5 = 5; line_clamp_6 = 6;
        }

        /// `leading-*` con un múltiplo cualquiera del tamaño de letra (`leading(1.75)`).
        fn leading(mut self, multiple: f32) -> Self {
            self.style().extra_mut().text.leading = Some(multiple);
            self
        }

        /// `tracking-*` en em (`tracking(0.04)`).
        fn tracking(mut self, em: f32) -> Self {
            self.style().extra_mut().text.tracking = Some(em);
            self
        }

        /// `font-[550]`: peso entre 100 y 900.
        fn font_weight(mut self, weight: u16) -> Self {
            self.style().extra_mut().text.weight = Some(weight.clamp(1, 1000));
            self
        }

        /// `line-clamp-N` con cualquier `N`.
        fn line_clamp(mut self, lines: u16) -> Self {
            self.style().text_wrap = Some(true);
            self.style().extra_mut().text.lines = Some(lines);
            self
        }
    };
}

pub(crate) use {line_clamps, text_utilities};