~eanyanwu/toph

f3db9f348ef1ca0b36a4a3e0367fd94104307d6b — Eze 2 months ago c72453e
Indicate that this is still incomplete in the README
2 files changed, 644 insertions(+), 0 deletions(-)

M README.md
A src/node/style.rs
M README.md => README.md +2 -0
@@ 1,5 1,7 @@
# Toph

🏗️ WIP 🏗️ 

Server-side html templating in Rust.

Here is an example to whet your appetite:

A src/node/style.rs => src/node/style.rs +642 -0
@@ 0,0 1,642 @@
//! Creating CSS rule sets in Rust

use paste::paste;

/// A CSS ruleset can be a "Style rule" or an "at-rule"
pub enum Rule {
    /// A style rule
    Style(StyleRule),
    ColorProfile,
    Container,
    CounterStyle,
    FontFace,
    FontFeatureValues,
    FontPaletteValues,
    Import,
    Keyframes,
    Layer,
    Media,
    Namespace,
    Page,
    Property,
    Scope,
    StartingStyle,
    Supports,
}

/// A Style rule associates a selector list with a list of property declarations
/// and possibly a list of nested rules
pub struct StyleRule {
    selector: String,
    value: Vec<DeclarationOrRule>,
}

/// A Declaration or nested `Rule`
pub enum DeclarationOrRule {
    Rule(Rule),
    Declaration(&'static str, String),
}

macro_rules! generate_property_functions {
    ($($prop:ident)*) => {
        $(
            paste!{
                pub fn [<$prop _>](value: &str) -> DeclarationOrRule {
                    DeclarationOrRule::Declaration(stringify!($prop), value.into())
                }
            }
        )*
    }
}

pub fn nested(selector: &str, rules: )
pub fn huh() {
    let h = [color_("white"), media("hello"), select("> * + *", [])];
    todo!()
}
generate_property_functions! {
_webkit_line_clamp
accent_color
align_content
align_items
align_self
alignment_baseline
all
anchor_name
anchor_scope
animation
animation_composition
animation_delay
animation_direction
animation_duration
animation_fill_mode
animation_iteration_count
animation_name
animation_play_state
animation_range
animation_range_end
animation_range_start
animation_timeline
animation_timing_function
appearance
aspect_ratio
azimuth
backface_visibility
background
background_attachment
background_blend_mode
background_clip
background_color
background_image
background_origin
background_position
background_repeat
background_size
baseline_shift
baseline_source
block_ellipsis
block_size
block_step
block_step_align
block_step_insert
block_step_round
block_step_size
bookmark_label
bookmark_level
bookmark_state
border
border_block
border_block_color
border_block_end
border_block_end_color
border_block_end_style
border_block_end_width
border_block_start
border_block_start_color
border_block_start_style
border_block_start_width
border_block_style
border_block_width
border_bottom
border_bottom_color
border_bottom_left_radius
border_bottom_right_radius
border_bottom_style
border_bottom_width
border_boundary
border_collapse
border_color
border_end_end_radius
border_end_start_radius
border_image
border_image_outset
border_image_repeat
border_image_slice
border_image_source
border_image_width
border_inline
border_inline_color
border_inline_end
border_inline_end_color
border_inline_end_style
border_inline_end_width
border_inline_start
border_inline_start_color
border_inline_start_style
border_inline_start_width
border_inline_style
border_inline_width
border_left
border_left_color
border_left_style
border_left_width
border_radius
border_right
border_right_color
border_right_style
border_right_width
border_spacing
border_start_end_radius
border_start_start_radius
border_style
border_top
border_top_color
border_top_left_radius
border_top_right_radius
border_top_style
border_top_width
border_width
bottom
box_decoration_break
box_shadow
box_sizing
box_snap
break_after
break_before
break_inside
caption_side
caret
caret_animation
caret_color
caret_shape
chains
clear
clip
clip_path
clip_rule
color
color_adjust
color_interpolation_filters
color_scheme
column_count
column_fill
column_gap
column_rule
column_rule_color
column_rule_style
column_rule_width
column_span
column_width
columns
contain
contain_intrinsic_block_size
contain_intrinsic_height
contain_intrinsic_inline_size
contain_intrinsic_size
contain_intrinsic_width
container
container_name
container_type
content
content_visibility
continue
counter_increment
counter_reset
counter_set
cue
cue_after
cue_before
cursor
direction
display
dominant_baseline
elevation
empty_cells
field_sizing
fill
fill_break
fill_color
fill_image
fill_opacity
fill_origin
fill_position
fill_repeat
fill_rule
fill_size
filter
flex
flex_basis
flex_direction
flex_flow
flex_grow
flex_shrink
flex_wrap
float
float_defer
float_offset
float_reference
flood_color
flood_opacity
flow
flow_from
flow_into
font
font_family
font_feature_settings
font_kerning
font_language_override
font_optical_sizing
font_palette
font_size
font_size_adjust
font_stretch
font_style
font_synthesis
font_synthesis_position
font_synthesis_small_caps
font_synthesis_style
font_synthesis_weight
font_variant
font_variant_alternates
font_variant_caps
font_variant_east_asian
font_variant_emoji
font_variant_ligatures
font_variant_numeric
font_variant_position
font_variation_settings
font_weight
font_width
footnote_display
footnote_policy
forced_color_adjust
gap
glyph_orientation_vertical
grid
grid_area
grid_auto_columns
grid_auto_flow
grid_auto_rows
grid_column
grid_column_end
grid_column_start
grid_row
grid_row_end
grid_row_start
grid_template
grid_template_areas
grid_template_columns
grid_template_rows
hanging_punctuation
height
hyphenate_character
hyphenate_limit_chars
hyphenate_limit_last
hyphenate_limit_lines
hyphenate_limit_zone
hyphens
image_orientation
image_rendering
image_resolution
initial_letter
initial_letter_align
initial_letter_wrap
inline_size
inline_sizing
input_security
inset
inset_area
inset_block
inset_block_end
inset_block_start
inset_inline
inset_inline_end
inset_inline_start
isolation
justify_content
justify_items
justify_self
left
letter_spacing
lighting_color
line_break
line_clamp
line_grid
line_height
line_height_step
line_padding
line_snap
list_style
list_style_image
list_style_position
list_style_type
margin
margin_block
margin_block_end
margin_block_start
margin_bottom
margin_break
margin_inline
margin_inline_end
margin_inline_start
margin_left
margin_right
margin_top
margin_trim
marker
marker_end
marker_knockout_left
marker_knockout_right
marker_mid
marker_pattern
marker_segment
marker_side
marker_start
mask
mask_border
mask_border_mode
mask_border_outset
mask_border_repeat
mask_border_slice
mask_border_source
mask_border_width
mask_clip
mask_composite
mask_image
mask_mode
mask_origin
mask_position
mask_repeat
mask_size
mask_type
max_block_size
max_height
max_inline_size
max_lines
max_width
min_block_size
min_height
min_inline_size
min_intrinsic_sizing
min_width
mix_blend_mode
nav_down
nav_left
nav_right
nav_up
object_fit
object_position
offset
offset_anchor
offset_distance
offset_path
offset_position
offset_rotate
opacity
order
orphans
outline
outline_color
outline_offset
outline_style
outline_width
overflow
overflow_anchor
overflow_block
overflow_clip_margin
overflow_clip_margin_block
overflow_clip_margin_block_end
overflow_clip_margin_block_start
overflow_clip_margin_bottom
overflow_clip_margin_inline
overflow_clip_margin_inline_end
overflow_clip_margin_inline_start
overflow_clip_margin_left
overflow_clip_margin_right
overflow_clip_margin_top
overflow_inline
overflow_wrap
overflow_x
overflow_y
overscroll_behavior
overscroll_behavior_block
overscroll_behavior_inline
overscroll_behavior_x
overscroll_behavior_y
padding
padding_block
padding_block_end
padding_block_start
padding_bottom
padding_inline
padding_inline_end
padding_inline_start
padding_left
padding_right
padding_top
page
page_break_after
page_break_before
page_break_inside
pause
pause_after
pause_before
perspective
perspective_origin
pitch
pitch_range
place_content
place_items
place_self
play_during
pointer_events
position
position_anchor
position_try
position_try_options
position_try_order
print_color_adjust
property_name
quotes
region_fragment
resize
rest
rest_after
rest_before
richness
right
rotate
row_gap
ruby_align
ruby_merge
ruby_overhang
ruby_position
running
scale
scroll_behavior
scroll_margin
scroll_margin_block
scroll_margin_block_end
scroll_margin_block_start
scroll_margin_bottom
scroll_margin_inline
scroll_margin_inline_end
scroll_margin_inline_start
scroll_margin_left
scroll_margin_right
scroll_margin_top
scroll_padding
scroll_padding_block
scroll_padding_block_end
scroll_padding_block_start
scroll_padding_bottom
scroll_padding_inline
scroll_padding_inline_end
scroll_padding_inline_start
scroll_padding_left
scroll_padding_right
scroll_padding_top
scroll_snap_align
scroll_snap_stop
scroll_snap_type
scroll_timeline
scroll_timeline_axis
scroll_timeline_name
scrollbar_color
scrollbar_gutter
scrollbar_width
shape_image_threshold
shape_inside
shape_margin
shape_outside
spatial_navigation_action
spatial_navigation_contain
spatial_navigation_function
speak
speak_as
speak_header
speak_numeral
speak_punctuation
speech_rate
stress
string_set
stroke
stroke_align
stroke_alignment
stroke_break
stroke_color
stroke_dash_corner
stroke_dash_justify
stroke_dashadjust
stroke_dasharray
stroke_dashcorner
stroke_dashoffset
stroke_image
stroke_linecap
stroke_linejoin
stroke_miterlimit
stroke_opacity
stroke_origin
stroke_position
stroke_repeat
stroke_size
stroke_width
tab_size
table_layout
text_align
text_align_all
text_align_last
text_autospace
text_box_edge
text_box_trim
text_combine_upright
text_decoration
text_decoration_color
text_decoration_line
text_decoration_skip
text_decoration_skip_box
text_decoration_skip_ink
text_decoration_skip_self
text_decoration_skip_spaces
text_decoration_style
text_decoration_thickness
text_decoration_trim
text_emphasis
text_emphasis_color
text_emphasis_position
text_emphasis_skip
text_emphasis_style
text_group_align
text_indent
text_justify
text_orientation
text_overflow
text_shadow
text_spacing
text_spacing_trim
text_transform
text_underline_offset
text_underline_position
text_wrap
text_wrap_mode
text_wrap_style
timeline_scope
top
transform
transform_box
transform_origin
transform_style
transition
transition_behavior
transition_delay
transition_duration
transition_property
transition_timing_function
translate
unicode_bidi
user_select
vertical_align
view_timeline
view_timeline_axis
view_timeline_inset
view_timeline_name
view_transition_name
visibility
voice_balance
voice_duration
voice_family
voice_pitch
voice_range
voice_rate
voice_stress
voice_volume
volume
white_space
white_space_collapse
white_space_trim
widows
width
will_change
word_break
word_space_transform
word_spacing
word_wrap
wrap_after
wrap_before
wrap_flow
wrap_inside
wrap_through
writing_mode
z_index
zoom
    }