Add conversion from component AST to flat component with content attribute (resolves #3), add XML attribute parsing, fix template string attribute parsing bug

This commit is contained in:
Keavon Chambers
2020-07-15 01:11:52 -07:00
parent c41710ab76
commit b0f24b546e
17 changed files with 352 additions and 223 deletions
+3 -2
View File
@@ -19,11 +19,12 @@ Layout is controlled using predefined attributes, such as `width`, `height`, `x-
The children of a component are passed to it as a `content` attribute. For example, looking at the row component:
```xml
<row content="INNER_XML: (Layout | None) = none">
<row content="INNER_XML: (Layout) = [[]]">
{{INNER_XML}}
</row>
```
The `content` attribute defines a new variable `INNER_XML` of type either `Layout` or `None`, which can contain more XML or nothing at all. It has a default value of `none` (of type `None`).
The `content` attribute defines a new variable `INNER_XML` of type `Layout` which can contain more XML layout structure. It has a default value of `[[]]` which refers to an empty layout— XML syntax (for the `Layout` data type) written in a tag's attribute is wrapped in ``[[`` (opening) and `]]` (closing) symbols. In this case the `INNER_XML` variable defaults to empty XML, however it is not stricly useful here because the `content` attribute will always have its value replaced by whatever exists between opening and closing tags when this component is called from elsewhere.
This is then expanded in the body of the row: `{{INNER_XML}}`.
## Defining new components
+2 -2
View File
@@ -1,3 +1,3 @@
<box content="INNER_XML: (None) = none" :fill="FILL: (Color | None) = none" :round="ROUND: (AbsolutePx | AbsolutePx, AbsolutePx, AbsolutePx, AbsolutePx) = 0px" :border-thickness="BORDER_THICKNESS: (AbsolutePx) = 0px" :border-color="BORDER_COLOR: (Color | None) = none">
<box content="INNER_XML: (Layout) = [[]]" :fill="FILL: (Color) = ['middlegray']" :round="ROUND: (AbsolutePx | AbsolutePx, AbsolutePx, AbsolutePx, AbsolutePx) = 0px" :border-thickness="BORDER_THICKNESS: (AbsolutePx) = 0px" :border-color="BORDER_COLOR: (Color) = ['black']">
{{INNER_XML}}
</box>
</box>
+2 -2
View File
@@ -1,3 +1,3 @@
<col content="INNER_XML: (None) = none">
<col content="INNER_XML: (Layout) = [[]]">
{{INNER_XML}}
</col>
</col>
+1 -1
View File
@@ -13,4 +13,4 @@
<box height="100%" y-align="50%" x-padding="18px">
<icon :svg="`window_close.svg`" />
</box>
</header:window-buttons>
</header:window-buttons>
+2 -2
View File
@@ -1,3 +1,3 @@
<icon content="INNER_XML: (None) = none" :svg="SVG_SOURCE: (TemplateString) = ``" :style="SVG_STYLE: (TemplateString) = ``">
<icon content="INNER_XML: (Layout) = [[]]" :svg="SVG_SOURCE: (TemplateString) = ``" :style="SVG_STYLE: (TemplateString) = ``">
{{INNER_XML}}
</icon>
</icon>
+2 -2
View File
@@ -1,3 +1,3 @@
<if content="INNER_XML: (None) = none" :a="CONDITION_A: (Integer | Decimal | AbsolutePx | Percent | PercentRemainder | Inner | Width | Height | TemplateString | Color | Bool | None) = true" :b="CONDITION_B: (Integer | Decimal | AbsolutePx | Percent | PercentRemainder | Inner | Width | Height | TemplateString | Color | Bool | None) = true">
<if content="INNER_XML: (Layout) = [[]]" :a="CONDITION_A: (Integer | Decimal | AbsolutePx | Percent | PercentRemainder | Inner | Width | Height | TemplateString | Color | Bool | None) = true" :b="CONDITION_B: (Integer | Decimal | AbsolutePx | Percent | PercentRemainder | Inner | Width | Height | TemplateString | Color | Bool | None) = true">
{{RESULT}}
</if>
</if>
+1 -1
View File
@@ -1,4 +1,4 @@
<input:checkbox-with-dropdown content="OPTION_LIST: (None) = none" :disabled="DISABLED: (Bool) = false" :checked="CHECKED: (Bool) = false" :selected-index="SELECTED_INDEX: (Integer) = 0">
<input:checkbox-with-dropdown content="OPTION_LIST: (Layout) = [[]]" :disabled="DISABLED: (Bool) = false" :checked="CHECKED: (Bool) = false" :selected-index="SELECTED_INDEX: (Integer) = 0">
<!-- Checkbox -->
<col width="height" height="100%">
<box width="100%" height="100%" x-align="50%" y-align="50%" :round="4px, 0px, 0px, 4px" :fill="['accent']">
+1 -1
View File
@@ -1,4 +1,4 @@
<input:dropdown content="OPTION_LIST: (TemplateString | None) = none" :selected-index="SELECTED_INDEX: (Integer) = 0" :disabled="DISABLED: (Bool) = false">
<input:dropdown content="OPTION_LIST: (TemplateString) = ``" :selected-index="SELECTED_INDEX: (Integer) = 0" :disabled="DISABLED: (Bool) = false">
<box width="100%" :round="4px">
<!-- Current selection text -->
<col width="100%" height="24px">
+2 -2
View File
@@ -1,3 +1,3 @@
<row content="INNER_XML: (None) = none">
<row content="INNER_XML: (Layout) = [[]]">
{{INNER_XML}}
</row>
</row>
+1 -1
View File
@@ -1 +1 @@
<text content="TEXT_STRING: (None) = none" :color="COLOR: (Color | None) = ['middlegray']" :size="SIZE: (AbsolutePx) = 12px"></text>
<text content="TEXT_STRING: (TemplateString) = `MISSING TEXT CONTENT`" :color="COLOR: (Color) = ['middlegray']" :size="SIZE: (AbsolutePx) = 12px"></text>
+1 -1
View File
@@ -4,4 +4,4 @@
Option B
Option C
</input:checkbox-with-dropdown>
</viewport:panels>
</viewport:panels>