Skip to content

Commit dd726d9

Browse files
committed
Hopefully clearer explanation of how to use enums in a component.
1 parent dec39b5 commit dd726d9

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

docs/source/actions.md

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,11 @@ class Color(Enum):
9393
RED = 1
9494
GREEN = 2
9595
BLUE = 3
96+
PURPLE = 4
9697
9798
class EnumView(UnicornView):
9899
color = Color.RED
100+
purple_color = Color.PURPLE
99101
100102
def set_color(self, color_int: int):
101103
self.color = Color(color_int)
@@ -104,9 +106,17 @@ class EnumView(UnicornView):
104106
```html
105107
<!-- enum.html -->
106108
<div>
107-
<button unicorn:click="set_color({{ color.value }})">Sets `self.color` based on the existing value of the `self.color` enum</button>
108-
<button unicorn:click="set_color(2)">Sets `self.color` to `Color.GREEN`</button>
109-
<button unicorn:click="set_color({{ color.BLUE.value }})">Sets `self.color` to `Color.BLUE`</button>
109+
<button unicorn:click="set_color({{ color.BLUE.value }})">Show BLUE (and 3) below when clicked</button>
110+
<button unicorn:click="set_color(2)">Show GREEN (and 2) below when clicked</button>
111+
<button unicorn:click="set_color({{ purple_color.value }})">Show PURPLE (and 4) below when clicked</button>
112+
113+
<br />
114+
<!-- This will be RED when first rendered, and then will change based on the button clicked above -->
115+
Color: {{ color }}
116+
117+
<br />
118+
<!-- This will be 1 when first rendered, and then will change based on the button clicked above -->
119+
Color int: {{ color.value }}
110120
</div>
111121
```
112122

0 commit comments

Comments
 (0)