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 caja de Tailwind: bordes por lado, radios por esquina, anillos, opacidades y degradados.
//! Se expande dentro de `Styled`.

/// `border-t`, `border-t-2`…: grosor de un lado o eje (en px) sin tocar el resto.
macro_rules! border_sides {
    ($($side:ident => |$sides:ident, $w:ident| $apply:expr;)*) => {
        $( border_widths! { $side, |$sides, $w| $apply; (1.0), (_0, 0.0), (_2, 2.0), (_4, 4.0), (_8, 8.0) } )*
    };
}

macro_rules! border_widths {
    ($side:ident, |$sides:ident, $w:ident| $apply:expr; ($default:expr), $(($suffix:ident, $width:expr)),*) => {
        paste::paste! {
            fn [<border_ $side>](mut self) -> Self {
                let $w = Pixels($default);
                let $sides = &mut self.style().extra_mut().border;
                $apply;
                self
            }
            $(
                fn [<border_ $side $suffix>](mut self) -> Self {
                    let $w = Pixels($width);
                    let $sides = &mut self.style().extra_mut().border;
                    $apply;
                    self
                }
            )*
        }
    };
}

/// `rounded-t-lg`, `rounded-bl-full`…: radio de un grupo de esquinas.
macro_rules! rounded_corners {
    ($($group:ident => |$c:ident, $r:ident| $apply:expr;)*) => {
        $( rounded_sizes! { $group, |$c, $r| $apply;
            (4.0), (_none, 0.0), (_sm, 2.0), (_md, 6.0), (_lg, 8.0), (_xl, 12.0), (_2xl, 16.0), (_3xl, 24.0),
            (_full, 9999.0)
        } )*
    };
}

macro_rules! rounded_sizes {
    ($group:ident, |$c:ident, $r:ident| $apply:expr; ($default:expr), $(($suffix:ident, $radius:expr)),*) => {
        paste::paste! {
            fn [<rounded_ $group>](mut self) -> Self {
                let $r = Pixels($default);
                let $c = &mut self.style().extra_mut().corners;
                $apply;
                self
            }
            $(
                fn [<rounded_ $group $suffix>](mut self) -> Self {
                    let $r = Pixels($radius);
                    let $c = &mut self.style().extra_mut().corners;
                    $apply;
                    self
                }
            )*
        }
    };
}

/// `opacity-50`…: opacidad en pasos de Tailwind.
macro_rules! opacities {
    ($($name:ident = $value:expr;)*) => {
        setters! { $($name => |s| s.opacity = Some($value);)* }
    };
}

/// `bg-gradient-to-r`: degradado hacia un lado o esquina (ángulos CSS: arriba 0°, derecha 90°…).
macro_rules! gradients {
    ($($name:ident = $angle:expr;)*) => {
        $(
            fn $name(self, from: impl Into<ColorSpec>, to: impl Into<ColorSpec>) -> Self {
                self.bg_gradient($angle, from, to)
            }
        )*
    };
}

macro_rules! box_utilities {
    () => {
        setters! {
            border => |s| s.border_width = Some(Pixels(1.0));
            border_0 => |s| s.border_width = Some(Pixels::ZERO);
            border_4 => |s| s.border_width = Some(Pixels(4.0));
            border_8 => |s| s.border_width = Some(Pixels(8.0));

            rounded => |s| s.radius = Some(Pixels(4.0));
            rounded_2xl => |s| s.radius = Some(Pixels(16.0));
            rounded_3xl => |s| s.radius = Some(Pixels(24.0));

            shadow_none => |s| s.extra_mut().shadow = Some(Shadows::NONE);
            shadow_xs => |s| s.extra_mut().shadow = Some(ShadowPreset::Xs.shadows());
            shadow_sm => |s| s.extra_mut().shadow = Some(ShadowPreset::Sm.shadows());
            shadow_md => |s| s.extra_mut().shadow = Some(ShadowPreset::Md.shadows());
            shadow_lg => |s| s.extra_mut().shadow = Some(ShadowPreset::Lg.shadows());
            shadow_xl => |s| s.extra_mut().shadow = Some(ShadowPreset::Xl.shadows());
            shadow_2xl => |s| s.extra_mut().shadow = Some(ShadowPreset::Xxl.shadows());

            ring => |s| s.extra_mut().ring = Some(Pixels(3.0));
            ring_0 => |s| s.extra_mut().ring = Some(Pixels::ZERO);
            ring_1 => |s| s.extra_mut().ring = Some(Pixels(1.0));
            ring_2 => |s| s.extra_mut().ring = Some(Pixels(2.0));
            ring_4 => |s| s.extra_mut().ring = Some(Pixels(4.0));
            ring_8 => |s| s.extra_mut().ring = Some(Pixels(8.0));
        }

        border_sides! {
            t => |sides, w| sides.top = Some(w);
            r => |sides, w| sides.right = Some(w);
            b => |sides, w| sides.bottom = Some(w);
            l => |sides, w| sides.left = Some(w);
            x => |sides, w| sides.set_horizontal(w);
            y => |sides, w| sides.set_vertical(w);
        }

        rounded_corners! {
            t => |c, r| { c.top_left = Some(r); c.top_right = Some(r); };
            r => |c, r| { c.top_right = Some(r); c.bottom_right = Some(r); };
            b => |c, r| { c.bottom_left = Some(r); c.bottom_right = Some(r); };
            l => |c, r| { c.top_left = Some(r); c.bottom_left = Some(r); };
            tl => |c, r| c.top_left = Some(r);
            tr => |c, r| c.top_right = Some(r);
            br => |c, r| c.bottom_right = Some(r);
            bl => |c, r| c.bottom_left = Some(r);
        }

        opacities! {
            opacity_0 = 0.0; opacity_5 = 0.05; opacity_10 = 0.1; opacity_20 = 0.2; opacity_25 = 0.25;
            opacity_30 = 0.3; opacity_40 = 0.4; opacity_50 = 0.5; opacity_60 = 0.6; opacity_70 = 0.7;
            opacity_75 = 0.75; opacity_80 = 0.8; opacity_90 = 0.9; opacity_95 = 0.95; opacity_100 = 1.0;
        }

        gradients! {
            bg_gradient_to_t = 0.0; bg_gradient_to_tr = 45.0; bg_gradient_to_r = 90.0; bg_gradient_to_br = 135.0;
            bg_gradient_to_b = 180.0; bg_gradient_to_bl = 225.0; bg_gradient_to_l = 270.0; bg_gradient_to_tl = 315.0;
        }

        /// `ring-color`: color del anillo (por defecto, el de acento al 50 %).
        fn ring_color(mut self, color: impl Into<ColorSpec>) -> Self {
            self.style().extra_mut().ring_color = Some(color.into());
            self
        }

        /// `border-[3px]` en un lado concreto no existe en Tailwind; esto fija los cuatro a la vez.
        fn border_width(mut self, width: Pixels) -> Self {
            self.style().border_width = Some(width);
            self
        }
    };
}

pub(crate) use {border_sides, border_widths, box_utilities, gradients, opacities, rounded_corners, rounded_sizes};