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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
use std::str::FromStr;

#[derive(Clone, Copy, PartialEq, Debug, Hash, Eq)]
pub enum AttributeName {
    Width,
    Height,
    MinWidth,
    MinHeight,
    MaxWidth,
    MaxHeight,
    Padding,
    Background,
    Border,
    Direction,
    Shadow,
    CornerRadius,
    CornerSmoothing,
    Color,
    FontSize,
    FontFamily,
    FontStyle,
    FontWeight,
    FontWidth,
    MainAlign,
    CrossAlign,
    TextAlign,
    TextShadow,
    MaxLines,
    LineHeight,
    LetterSpacing,
    WordSpacing,
    Decoration,
    DecorationColor,
    DecorationStyle,
    TextOverflow,
    Rotate,
    Overflow,
    Margin,
    Position,
    PositionTop,
    PositionRight,
    PositionBottom,
    PositionLeft,
    Opacity,
    Content,
    A11YAutoFocus,
    A11YName,
    A11YFocusable,
    A11YRole,
    A11YId,
    A11YAlt,
    CanvasReference,
    Layer,
    OffsetY,
    OffsetX,
    Reference,
    CursorReference,
    CursorIndex,
    CursorColor,
    CursorMode,
    CursorId,
    Highlights,
    HighlightColor,
    HighlightMode,
    ImageReference,
    ImageData,
    SvgData,
    SvgContent,
    Spacing,
}

impl FromStr for AttributeName {
    type Err = String;

    fn from_str(attr: &str) -> Result<Self, Self::Err> {
        match attr {
            "width" => Ok(AttributeName::Width),
            "height" => Ok(AttributeName::Height),
            "min_width" => Ok(AttributeName::MinWidth),
            "min_height" => Ok(AttributeName::MinHeight),
            "max_width" => Ok(AttributeName::MaxWidth),
            "max_height" => Ok(AttributeName::MaxHeight),
            "padding" => Ok(AttributeName::Padding),
            "background" => Ok(AttributeName::Background),
            "border" => Ok(AttributeName::Border),
            "direction" => Ok(AttributeName::Direction),
            "shadow" => Ok(AttributeName::Shadow),
            "corner_radius" => Ok(AttributeName::CornerRadius),
            "corner_smoothing" => Ok(AttributeName::CornerSmoothing),
            "color" => Ok(AttributeName::Color),
            "font_size" => Ok(AttributeName::FontSize),
            "font_family" => Ok(AttributeName::FontFamily),
            "font_style" => Ok(AttributeName::FontStyle),
            "font_weight" => Ok(AttributeName::FontWeight),
            "font_width" => Ok(AttributeName::FontWidth),
            "main_align" => Ok(AttributeName::MainAlign),
            "cross_align" => Ok(AttributeName::CrossAlign),
            "text_align" => Ok(AttributeName::TextAlign),
            "text_shadow" => Ok(AttributeName::TextShadow),
            "max_lines" => Ok(AttributeName::MaxLines),
            "line_height" => Ok(AttributeName::LineHeight),
            "letter_spacing" => Ok(AttributeName::LetterSpacing),
            "word_spacing" => Ok(AttributeName::WordSpacing),
            "decoration" => Ok(AttributeName::Decoration),
            "decoration_color" => Ok(AttributeName::DecorationColor),
            "decoration_style" => Ok(AttributeName::DecorationStyle),
            "text_overflow" => Ok(AttributeName::TextOverflow),
            "rotate" => Ok(AttributeName::Rotate),
            "overflow" => Ok(AttributeName::Overflow),
            "margin" => Ok(AttributeName::Margin),
            "position" => Ok(AttributeName::Position),
            "position_top" => Ok(AttributeName::PositionTop),
            "position_right" => Ok(AttributeName::PositionRight),
            "position_bottom" => Ok(AttributeName::PositionBottom),
            "position_left" => Ok(AttributeName::PositionLeft),
            "opacity" => Ok(AttributeName::Opacity),
            "content" => Ok(AttributeName::Content),
            "a11y_auto_focus" => Ok(AttributeName::A11YAutoFocus),
            "a11y_name" => Ok(AttributeName::A11YName),
            "a11y_role" => Ok(AttributeName::A11YRole),
            "a11y_id" => Ok(AttributeName::A11YId),
            "a11y_alt" => Ok(AttributeName::A11YAlt),
            "a11y_focusable" => Ok(AttributeName::A11YFocusable),
            "canvas_reference" => Ok(AttributeName::CanvasReference),
            "layer" => Ok(AttributeName::Layer),
            "offset_y" => Ok(AttributeName::OffsetY),
            "offset_x" => Ok(AttributeName::OffsetX),
            "reference" => Ok(AttributeName::Reference),
            "cursor_reference" => Ok(AttributeName::CursorReference),
            "cursor_index" => Ok(AttributeName::CursorIndex),
            "cursor_color" => Ok(AttributeName::CursorColor),
            "cursor_mode" => Ok(AttributeName::CursorMode),
            "cursor_id" => Ok(AttributeName::CursorId),
            "highlights" => Ok(AttributeName::Highlights),
            "highlight_color" => Ok(AttributeName::HighlightColor),
            "highlight_mode" => Ok(AttributeName::HighlightMode),
            "image_reference" => Ok(AttributeName::ImageReference),
            "image_data" => Ok(AttributeName::ImageData),
            "svg_data" => Ok(AttributeName::SvgData),
            "svg_content" => Ok(AttributeName::SvgContent),
            "spacing" => Ok(AttributeName::Spacing),
            _ => Err(format!("{attr} not supported.")),
        }
    }
}