1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
//! This crate provides you a **typed CSS style** with builder-style methods.
//!
//! **NOTE:** css-style is not (yet) prodction ready but is good for use in side
//! projects and internal tools.
//!
//! # Features
//!
//! - **Typed CSS Values**: CSS units and valuse are all typed (.e.g `Length`, `Px`,
//!   `css::None` ..etc)
//! - **Builder Methods**: Provide bulder-pattern methods for every css-style
//!   property. (well, not all them yet! :P)
//!
//! # Goal
//!
//! The goal for this crate is to provide a `Style` object with builder-pattern
//! methods to build up a CSS inline-style value, thus can be used with/by other
//! crates that works with styling HTML tags (such as `yew`, `seed`,
//! `tinytemplate`..etc).
//!
//! # Non-Goal
//!
//! The `Style` object is not intended for parsing or retrieving typed values out of
//! it. Conisder using other crate for parsing purpose.
//!
//! # Qucik Example
//!
//! ```rust
//! use css_style::{Style, Color, unit::{ms, px}};
//!
//! let style = Style::default()
//!     .and_transition(|conf| {
//!         conf
//!             .insert("opacity", |conf| conf.duration(ms(150.)).ease())
//!             .insert("transform", |conf| conf.duration(ms(150.)).ease())
//!             .insert("visibility", |conf| conf.duration(ms(150.)).ease())
//!     })
//!     .and_position(|conf| conf.absolute())
//!     .and_background(|conf| conf.color(Color::White))
//!     .and_border(|conf| {
//!         conf.none()
//!             .width(px(0))
//!             .radius(px(4))
//!     })
//!     .and_padding(|conf| conf.x(px(4)).y(px(2)))
//!     .and_margin(|conf| conf.top(px(2)))
//!     .insert("box-shadow", "0 2px 8px rgba(0, 35, 11, 0.15)");
//!
//! println!("{}", style);
//! ```
//!
//! this would print:
//! ```css
//! transition: opacity 150ms ease, transform 150ms ease, visibility 150ms ease;
//! position: absolute;
//! background-color: white;
//! border-left-width: 0px;
//! border-left-style: none;
//! border-top-width: 0px;
//! border-top-style: none;
//! border-right-width: 0px;
//! border-right-style: none;
//! border-bottom-width: 0px;
//! border-bottom-style: none;
//! border-top-left-radius: 4px;
//! border-top-right-radius: 4px;
//! border-bottom-left-radius: 4px;
//! border-bottom-right-radius: 4px;
//! padding-top: 2px;
//! padding-right: 4px;
//! padding-bottom: 2px;
//! padding-left: 4px;
//! margin-top: 2px;
//! box-shadow: 0 2px 8px rgba(0, 35, 11, 0.15);
//! ```

#![forbid(unsafe_code)]

#[macro_use]
extern crate derive_more;

#[macro_use]
pub mod style;
pub mod background;
pub mod border;
pub mod box_align;
pub mod box_shadow;
pub mod calc;
pub mod color;
pub mod css_values;
pub mod cursor;
pub mod display;
pub mod flexbox;
pub mod font;
pub mod gap;
pub mod margin;
pub mod padding;
pub mod position;
pub mod size;
pub mod text;
pub mod transition;
pub mod unit;
pub mod visibility;

pub use self::{
    background::Background,
    border::Border,
    box_align::*,
    box_shadow::BoxShadow,
    color::{Color, Opacity},
    css_values as css,
    cursor::Cursor,
    display::Display,
    flexbox::{
        Basis as FlexBasis, Direction as FlexDirection, Grow as FlexGrow, Order as FlexOrder,
        Shrink as FlexShrink, Wrap as FlexWrap,
    },
    font::Font,
    gap::Gap,
    margin::Margin,
    padding::Padding,
    position::Position,
    size::Size,
    style::{Style, StyleUpdater},
    text::Text,
    transition::Transition,
    visibility::Visibility,
};

pub mod prelude {
    pub use crate::Style;
}