Skip to content

Commit

Permalink
Merge pull request #6 from posit-conf-2024/hello-shiny-edits
Browse files Browse the repository at this point in the history
Hello shiny edits
  • Loading branch information
garrettgman authored Aug 8, 2024
2 parents 2df0997 + 206e9fa commit 3363124
Show file tree
Hide file tree
Showing 130 changed files with 6,000 additions and 1,557 deletions.

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions _extensions/kmasiello/positconfslides/custom.scss
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,12 @@ section div.has-dark-background blockquote {

.largest {
font-size: 500%;
}

// tables

.table-striped {
> tbody > tr:nth-of-type(even) > * {
background-color: #f2f2f2;
}
}
20 changes: 12 additions & 8 deletions _quarto.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,23 +31,27 @@ website:
href: https://discord.gg/AQVJzG2bnN

sidebar:
- title: "Hallo, Shiny express!"
- title: "Hello, Shiny express!"
contents:
- href: docs/shiny-express.qmd
text: Slides
- section: "Exercises"
contents:
- docs/exercises/express-101-hello-world/index.qmd
- docs/exercises/express-102-data-frame/index.qmd
- docs/exercises/express-103-debug/index.qmd
- docs/exercises/express-104-filter/index.qmd
- docs/exercises/express-105-connect-filter/index.qmd
- docs/exercises/express-101-run-app/index.qmd
- docs/exercises/express-102-ui-module/index.qmd
- docs/exercises/express-103-inputs/index.qmd
- docs/exercises/express-104-outputs/index.qmd
- docs/exercises/express-105-reactivity/index.qmd
- docs/exercises/express-106-debug/index.qmd
- docs/exercises/express-107-debug/index.qmd
- docs/exercises/express-108-plot/index.qmd
- docs/exercises/express-108-debug/index.qmd
- docs/exercises/express-109-debug/index.qmd
- docs/exercises/express-110-app/index.qmd
- section: "Apps"
contents:
- docs/apps/000-penguins/index.qmd
- docs/apps/101-input/index.qmd
- docs/apps/102-output/index.qmd
- docs/apps/103-table/index.qmd

- title: "Reactivity"
contents:
Expand Down
15 changes: 15 additions & 0 deletions docs/apps/101-input/index.qmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
title: "101 Input"
---

```{python}
# | echo: false
# | output: asis
import sys
helpers_path = "../../exercises/"
if helpers_path not in sys.path:
sys.path.append(helpers_path)
from helpers import problem_app_express, getcwd
problem_app_express(getcwd())
```
Empty file.
9 changes: 9 additions & 0 deletions docs/apps/101-input/problem/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from shiny.express import ui

ui.input_slider(
id="n",
label="Choose n",
min=0,
max=100,
value=20
)
1 change: 1 addition & 0 deletions docs/apps/101-input/problem/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
shiny==1.0.0
15 changes: 15 additions & 0 deletions docs/apps/102-output/index.qmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
title: "102 Output"
---

```{python}
# | echo: false
# | output: asis
import sys
helpers_path = "../../exercises/"
if helpers_path not in sys.path:
sys.path.append(helpers_path)
from helpers import problem_app_express, getcwd
problem_app_express(getcwd())
```
Empty file.
6 changes: 6 additions & 0 deletions docs/apps/102-output/problem/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from shiny.express import render

@render.code
def text():
txt="Some text to display in code format"
return txt
1 change: 1 addition & 0 deletions docs/apps/102-output/problem/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
shiny==1.0.0
15 changes: 15 additions & 0 deletions docs/apps/103-table/index.qmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
title: "103 Table"
---

```{python}
# | echo: false
# | output: asis
import sys
helpers_path = "../../exercises/"
if helpers_path not in sys.path:
sys.path.append(helpers_path)
from helpers import problem_app_express, getcwd
problem_app_express(getcwd())
```
Empty file.
22 changes: 22 additions & 0 deletions docs/apps/103-table/problem/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
from shiny.express import ui

ui.input_select(
id="account",
label="Account",
choices=[
"Berge & Berge",
"Fritsch & Fritsch",
"Hintz & Hintz",
"Mosciski and Sons",
"Wolff Ltd",
]
)

ui.input_radio_buttons(
"variable",
"Select a variable to plot",
choices={
"prod_score": "Product Score",
"training_score": "Training Score"
}
)
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
from pathlib import Path
import pandas as pd
import numpy as np

file_path = Path(__file__).parent / "simulated-data.csv"

df = pd.read_csv(file_path, dtype={"sub_account": str})
df["date"] = pd.to_datetime(df["date"], errors="coerce")
df = df.drop(columns=["text"])
7 changes: 7 additions & 0 deletions docs/apps/103-table/problem/plots.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import plotly.express as px
from pandas import DataFrame

def plot_var_distribution(df: DataFrame, var="prod_score"):
fig = px.histogram(df, x=var, nbins=50, title="Model scores")
fig.update_layout(xaxis_title="Score", yaxis_title="Density")
return fig
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
pandas
shiny==1.0.0
pandas
plotly
2 changes: 0 additions & 2 deletions docs/exercises/express-101-hello-world/problem/README

This file was deleted.

This file was deleted.

3 changes: 0 additions & 3 deletions docs/exercises/express-101-hello-world/problem/app.py

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
title: "108 Add plot"
title: "101 Run app"
---

```{python}
Expand Down
1 change: 1 addition & 0 deletions docs/exercises/express-101-run-app/problem/README
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Can you run a Shiny app? Navigate to the problem tab. Then click the play button to run your first app.
7 changes: 7 additions & 0 deletions docs/exercises/express-101-run-app/problem/app-solution.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from shiny.express import ui, render, input

ui.input_text("name", "Type a name", value="world")

@render.text
def greeting():
return f"Hello {input.name()}!"
9 changes: 9 additions & 0 deletions docs/exercises/express-101-run-app/problem/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from shiny.express import ui, render, input

ui.input_text("name", "Type a name", value="world")

@render.text
def greeting():
return f"Hello {input.name()}!"


1 change: 0 additions & 1 deletion docs/exercises/express-102-data-frame/problem/README

This file was deleted.

14 changes: 0 additions & 14 deletions docs/exercises/express-102-data-frame/problem/app-solution.py

This file was deleted.

12 changes: 0 additions & 12 deletions docs/exercises/express-102-data-frame/problem/app.py

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
title: "105 Connect input"
title: "102 The ui module"
---

```{python}
Expand Down
1 change: 1 addition & 0 deletions docs/exercises/express-102-ui-module/problem/README
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add markdown syntax highlighting in combination with the `markdown()` function from the `ui` submodule to create this (not very reactive) app.
15 changes: 15 additions & 0 deletions docs/exercises/express-102-ui-module/problem/app-solution.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from shiny.express import ui

ui.markdown(
"""
## Why Shiny for Python?
Shiny lets you make pure Python web apps quickly, without worrying about:
- cache
- state
- callbacks
...or even HTML, CSS, and JavaScript.
"""
)
13 changes: 13 additions & 0 deletions docs/exercises/express-102-ui-module/problem/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from shiny.express import ui

"""
Why Shiny for Python?
Shiny lets you make pure Python web apps quickly, without worrying about:
cache
state
callbacks
...or even HTML, CSS, and JavaScript.
"""
1 change: 0 additions & 1 deletion docs/exercises/express-103-debug/problem/README

This file was deleted.

15 changes: 0 additions & 15 deletions docs/exercises/express-103-debug/problem/app-solution.py

This file was deleted.

12 changes: 0 additions & 12 deletions docs/exercises/express-103-debug/problem/app.py

This file was deleted.

Loading

0 comments on commit 3363124

Please sign in to comment.