Skip to content

Commit

Permalink
updated document document
Browse files Browse the repository at this point in the history
  • Loading branch information
zen committed Nov 27, 2023
1 parent 79b9bc1 commit 059fdfb
Show file tree
Hide file tree
Showing 23 changed files with 477 additions and 59 deletions.
16 changes: 15 additions & 1 deletion change.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
# 0.6.20
- Allow user to select Button Type and Color in Button Data and allow inline css
```python
return i.ReturnData(
title="button Redirect from server",
type=i.InstanceType.BUTTON,
button_data=i.ButtonData(
color=i.ButtonColor.ACCENT,
url=ButtonRedirectServer.server_full_url(), name="test this"),
flex=i.FlexData(fxFlex="0%", fxFlex_md="0%")
)
```


# 0.6.19
- depericated button_result in UpdateReturnData
- *Breaking Change*: depericated button_result in UpdateReturnData
- added button_data in UpdateReturnData
```python
i.UpdateReturnData(
Expand Down
1 change: 1 addition & 0 deletions demo/pages/input_page/row_seven/view.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ def view():
title="button Redirect from server",
type=i.InstanceType.BUTTON,
button_data=i.ButtonData(
color=i.ButtonColor.ACCENT,
url=ButtonRedirectServer.server_full_url(), name="test this"),
flex=i.FlexData(fxFlex="0%", fxFlex_md="0%")
)
Expand Down
33 changes: 32 additions & 1 deletion docs/_modules/zen_dash/objects/instances.html
Original file line number Diff line number Diff line change
Expand Up @@ -273,11 +273,32 @@ <h1>Source code for zen_dash.objects.instances</h1><div class="highlight"><pre>
<span class="n">SELF</span> <span class="o">=</span> <span class="s2">&quot;_self&quot;</span>
<span class="n">TOP</span> <span class="o">=</span> <span class="s2">&quot;_top&quot;</span></div>


<div class="viewcode-block" id="ButtonType"><a class="viewcode-back" href="../../../zen_dash.objects.html#zen_dash.objects.instances.ButtonType">[docs]</a><span class="k">class</span> <span class="nc">ButtonType</span><span class="p">(</span><span class="n">Enum</span><span class="p">):</span>
<span class="n">BASIC</span> <span class="o">=</span> <span class="s2">&quot;basic&quot;</span>
<span class="n">RAISED</span> <span class="o">=</span> <span class="s2">&quot;raised&quot;</span>
<span class="n">STROKED</span> <span class="o">=</span> <span class="s2">&quot;stroked&quot;</span>
<span class="n">FLAT</span> <span class="o">=</span> <span class="s2">&quot;flat&quot;</span>
<span class="n">FAB</span><span class="o">=</span> <span class="s2">&quot;fab&quot;</span>
<span class="n">MINIFAB</span> <span class="o">=</span> <span class="s2">&quot;mini_fab&quot;</span>
<span class="n">ICON</span> <span class="o">=</span> <span class="s2">&quot;icon&quot;</span></div>

<div class="viewcode-block" id="ButtonColor"><a class="viewcode-back" href="../../../zen_dash.objects.html#zen_dash.objects.instances.ButtonColor">[docs]</a><span class="k">class</span> <span class="nc">ButtonColor</span><span class="p">(</span><span class="n">Enum</span><span class="p">):</span>
<span class="n">PRIMARY</span> <span class="o">=</span> <span class="s2">&quot;primary&quot;</span>
<span class="n">ACCENT</span> <span class="o">=</span> <span class="s2">&quot;accent&quot;</span>
<span class="n">WARN</span> <span class="o">=</span> <span class="s2">&quot;warn&quot;</span></div>


<div class="viewcode-block" id="ButtonData"><a class="viewcode-back" href="../../../zen_dash.objects.html#zen_dash.objects.instances.ButtonData">[docs]</a><span class="k">class</span> <span class="nc">ButtonData</span><span class="p">(</span><span class="n">BaseUpdate</span><span class="p">):</span>
<span class="n">url</span><span class="p">:</span> <span class="nb">str</span>
<span class="n">name</span><span class="p">:</span> <span class="nb">str</span>
<span class="n">redirect</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span>
<span class="n">target_attribute</span><span class="p">:</span><span class="n">TargetAttribute</span> <span class="o">=</span> <span class="n">TargetAttribute</span><span class="o">.</span><span class="n">Blank</span></div>
<span class="n">target_attribute</span><span class="p">:</span><span class="n">TargetAttribute</span> <span class="o">=</span> <span class="n">TargetAttribute</span><span class="o">.</span><span class="n">Blank</span>
<span class="n">color</span><span class="p">:</span> <span class="n">ButtonColor</span> <span class="o">=</span> <span class="n">ButtonColor</span><span class="o">.</span><span class="n">PRIMARY</span>
<span class="n">button_type</span><span class="p">:</span> <span class="n">ButtonType</span> <span class="o">=</span> <span class="n">ButtonType</span><span class="o">.</span><span class="n">RAISED</span>
<span class="n">style</span><span class="p">:</span> <span class="n">Optional</span><span class="p">[</span><span class="n">Dict</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="nb">str</span><span class="p">]]</span>
<span class="n">icon</span><span class="p">:</span> <span class="n">Optional</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span></div>


<div class="viewcode-block" id="SubmitFormData"><a class="viewcode-back" href="../../../zen_dash.objects.html#zen_dash.objects.instances.SubmitFormData">[docs]</a><span class="k">class</span> <span class="nc">SubmitFormData</span><span class="p">(</span><span class="n">BaseUpdate</span><span class="p">):</span>
<span class="n">name</span><span class="p">:</span> <span class="nb">str</span>
Expand Down Expand Up @@ -419,8 +440,18 @@ <h1>Source code for zen_dash.objects.instances</h1><div class="highlight"><pre>
<span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s2">&quot;You have selected InstanceType.HIGHCHART, and highchart_data is missing&quot;</span><span class="p">)</span>
<span class="k">elif</span> <span class="p">(</span><span class="n">field_values</span><span class="p">[</span><span class="s2">&quot;type&quot;</span><span class="p">]</span> <span class="o">==</span> <span class="n">InstanceType</span><span class="o">.</span><span class="n">CUSTOM_HTML</span><span class="p">)</span> <span class="ow">and</span> <span class="p">(</span><span class="n">field_values</span><span class="p">[</span><span class="s2">&quot;custom_html_data&quot;</span><span class="p">]</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">):</span>
<span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s2">&quot;You have selected InstanceType.CUSTOM_HTML, and custom_html_data is missing&quot;</span><span class="p">)</span>

<span class="k">elif</span> <span class="p">(</span><span class="n">field_values</span><span class="p">[</span><span class="s2">&quot;type&quot;</span><span class="p">]</span> <span class="o">==</span> <span class="n">InstanceType</span><span class="o">.</span><span class="n">BUTTON</span><span class="p">)</span> <span class="ow">and</span> <span class="p">(</span><span class="n">field_values</span><span class="p">[</span><span class="s2">&quot;button_data&quot;</span><span class="p">]</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">):</span>
<span class="k">if</span> <span class="p">((</span><span class="n">field_values</span><span class="p">[</span><span class="s2">&quot;button_data&quot;</span><span class="p">]</span><span class="o">.</span><span class="n">button_type</span><span class="o">.</span><span class="n">value</span> <span class="ow">not</span> <span class="ow">in</span> <span class="p">(</span><span class="n">ButtonType</span><span class="o">.</span><span class="n">FAB</span><span class="o">.</span><span class="n">value</span><span class="p">,</span> <span class="n">ButtonType</span><span class="o">.</span><span class="n">MINIFAB</span><span class="o">.</span><span class="n">value</span><span class="p">,</span> <span class="n">ButtonType</span><span class="o">.</span><span class="n">ICON</span><span class="o">.</span><span class="n">value</span><span class="p">))</span> <span class="o">&amp;</span>
<span class="p">(</span><span class="n">field_values</span><span class="p">[</span><span class="s2">&quot;button_data&quot;</span><span class="p">]</span><span class="o">.</span><span class="n">icon</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">)):</span>
<span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s2">&quot;ICON is not supported for selected button style&quot;</span><span class="p">)</span>
<span class="k">if</span> <span class="p">((</span><span class="n">field_values</span><span class="p">[</span><span class="s2">&quot;button_data&quot;</span><span class="p">]</span><span class="o">.</span><span class="n">button_type</span> <span class="ow">in</span> <span class="p">(</span><span class="n">ButtonType</span><span class="o">.</span><span class="n">FAB</span><span class="p">,</span> <span class="n">ButtonType</span><span class="o">.</span><span class="n">MINIFAB</span><span class="p">,</span> <span class="n">ButtonType</span><span class="o">.</span><span class="n">ICON</span><span class="p">))</span> <span class="o">&amp;</span>
<span class="p">(</span><span class="n">field_values</span><span class="p">[</span><span class="s2">&quot;button_data&quot;</span><span class="p">]</span><span class="o">.</span><span class="n">icon</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">)):</span>
<span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s2">&quot;ICON is need for selected button style&quot;</span><span class="p">)</span>
<span class="k">elif</span> <span class="p">(</span><span class="n">field_values</span><span class="p">[</span><span class="s2">&quot;type&quot;</span><span class="p">]</span> <span class="o">==</span> <span class="n">InstanceType</span><span class="o">.</span><span class="n">BUTTON</span><span class="p">)</span> <span class="ow">and</span> <span class="p">(</span><span class="n">field_values</span><span class="p">[</span><span class="s2">&quot;button_data&quot;</span><span class="p">]</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">):</span>

<span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s2">&quot;You have selected InstanceType.BUTTON, and button_data is missing&quot;</span><span class="p">)</span>

<span class="k">elif</span> <span class="p">(</span><span class="n">field_values</span><span class="p">[</span><span class="s2">&quot;type&quot;</span><span class="p">]</span> <span class="o">==</span> <span class="n">InstanceType</span><span class="o">.</span><span class="n">FORM</span><span class="p">)</span> <span class="ow">and</span> <span class="p">(</span><span class="n">field_values</span><span class="p">[</span><span class="s2">&quot;form_data&quot;</span><span class="p">]</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">):</span>
<span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s2">&quot;You have selected InstanceType.FORM, and form_data is missing&quot;</span><span class="p">)</span>
<span class="k">elif</span> <span class="p">(</span><span class="n">field_values</span><span class="p">[</span><span class="s2">&quot;type&quot;</span><span class="p">]</span> <span class="o">==</span> <span class="n">InstanceType</span><span class="o">.</span><span class="n">FLOATING_BUTTON</span><span class="p">)</span> <span class="ow">and</span> <span class="p">(</span><span class="n">field_values</span><span class="p">[</span><span class="s2">&quot;floating_button_data&quot;</span><span class="p">]</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">):</span>
Expand Down
Loading

0 comments on commit 059fdfb

Please sign in to comment.