Skip to content

Commit 34228d8

Browse files
authored
Merge pull request #260 from posit-dev/kitchensink
Add kitchen sink examples to components detail pages
2 parents e91cd28 + ddfd69e commit 34228d8

File tree

90 files changed

+2799
-11
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

90 files changed

+2799
-11
lines changed

_quarto.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ website:
138138
- components/inputs/action-link/index.qmd
139139
- components/inputs/checkbox/index.qmd
140140
- components/inputs/checkbox-group/index.qmd
141+
- components/inputs/dark-mode/index.qmd
141142
- components/inputs/date-range-selector/index.qmd
142143
- components/inputs/date-selector/index.qmd
143144
- components/inputs/file/index.qmd
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
::: {.kitchensink}
2+
3+
<% for (const item of items) { %>
4+
5+
## Variation Showcase
6+
7+
A live kitchen sink of all possible parameters for the <%= item.title %> in [Shiny Core](<%= item.core %>){target="_blank"} and [Shiny Express](<%= item.express%>){target="_blank"}.
8+
9+
![](<%= item.image %>){.border .my-4 style="border-radius: .5em;"}
10+
11+
::::{.grid}
12+
:::{.g-col-sm-6 .g-col-12}
13+
<p class="m-0">[<i class="bi bi-lightning-fill me-2"></i> Live Core App](<%= item.core %>){.btn .btn-primary .w-100 .m-1 target="_blank"}</p>
14+
:::
15+
16+
:::{.g-col-sm-6 .g-col-12}
17+
<p class="m-0">[<i class="bi bi-lightning-fill me-2"></i> Live Express App](<%= item.express %>){.btn .btn-primary .w-100 .m-1 target="_blank"}</p>
18+
:::
19+
::::
20+
21+
<% } %>
22+
23+
:::

components/_partials/components-detail-relevant-functions.ejs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<!-- relevant functions -->
22

3-
## Relevant Functions {.mt-5}
3+
## Relevant Functions
44

55
```{=html}
66
<ul>

components/_partials/components.css

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,22 @@ The article pages (/components/_____/index.qmd) get styling from here.
1919

2020
/* Add rule and spacing between sections */
2121

22-
section.level2:not(:first-child) h2 {
22+
/* remove extra space below tab content section */
23+
.tab-content {
24+
margin-bottom: 0;
25+
padding-bottom: 0;
26+
}
27+
28+
section.level2:not(:first-child) h2, section.level2.kitchensink h2, section.level3:not(:first-child) h2 {
2329
border-top: 1px solid var(--bs-primary);
24-
padding-top: 5rem !important;
25-
margin-top: 5rem !important;
30+
padding-top: 4rem !important;
31+
margin-top: 4rem !important;
2632
}
2733

28-
section.level2:not(:first-child) > :last-child {
34+
section.level2:not(:first-child) > :last-child, section.level3:not(:first-child) > :last-child {
2935
margin-bottom: 0;
3036
}
31-
37+
3238
/*Make code in Relavent Functions wrap*/
3339

3440
#relevant-functions ul li code {
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
from shiny import App, reactive, render, ui
2+
3+
# Create the UI
4+
app_ui = ui.page_fluid(
5+
# Add Font Awesome CSS in the head
6+
ui.tags.head(
7+
ui.tags.link(
8+
rel="stylesheet",
9+
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.7.2/css/all.min.css",
10+
)
11+
),
12+
# Main layout
13+
ui.layout_column_wrap(
14+
ui.card(
15+
ui.card_header("Action Button Examples"),
16+
# Basic button with width parameter
17+
ui.input_action_button(id="btn1", label="Basic Button", width="200px"),
18+
ui.output_text("click_count_btn1"),
19+
ui.br(), # Add spacing
20+
# Button with icon and disabled state
21+
ui.input_action_button(
22+
id="btn2",
23+
label="Disabled Button with Icon",
24+
icon=ui.tags.i(class_="fa-solid fa-shield-halved"),
25+
disabled=True,
26+
),
27+
ui.output_text("click_count_btn2"),
28+
ui.br(), # Add spacing
29+
# Button with custom class and style attributes
30+
ui.input_action_button(
31+
id="btn3",
32+
label="Styled Button",
33+
class_="btn-success",
34+
style="margin-top: 20px;",
35+
),
36+
ui.output_text("click_count_btn3"),
37+
),
38+
width="100%",
39+
),
40+
)
41+
42+
43+
# Define the server
44+
def server(input, output, session):
45+
@render.text
46+
def click_count_btn1():
47+
return f"Button 1 clicks: {input.btn1() or 0}"
48+
49+
@render.text
50+
def click_count_btn2():
51+
return f"Button 2 clicks: {input.btn2() or 0}"
52+
53+
@render.text
54+
def click_count_btn3():
55+
return f"Button 3 clicks: {input.btn3() or 0}"
56+
57+
58+
# Create and return the app
59+
app = App(app_ui, server)
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
from shiny import reactive
2+
from shiny.express import input, ui, render
3+
4+
ui.page_opts(full_width=True)
5+
6+
# Add Font Awesome CSS for icons
7+
ui.head_content(
8+
ui.HTML(
9+
'<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.7.2/css/all.min.css">'
10+
)
11+
)
12+
13+
# Create a layout with some spacing
14+
with ui.layout_column_wrap(width="100%"):
15+
with ui.card():
16+
ui.card_header("Action Button Examples")
17+
18+
# Basic button with width parameter
19+
ui.input_action_button(id="btn1", label="Basic Button", width="200px")
20+
21+
@render.text
22+
def click_count_btn1():
23+
return f"Button 1 clicks: {input.btn1() or 0}"
24+
25+
ui.br() # Add some spacing
26+
27+
# Button with icon and disabled state
28+
ui.input_action_button(
29+
id="btn2",
30+
label="Disabled Button with Icon",
31+
icon=ui.tags.i(class_="fa-solid fa-shield-halved"),
32+
disabled=True,
33+
)
34+
35+
@render.text
36+
def click_count_btn2():
37+
return f"Button 2 clicks: {input.btn2() or 0}"
38+
39+
ui.br() # Add some spacing
40+
41+
# Button with custom class and style attributes
42+
ui.input_action_button(
43+
id="btn3",
44+
label="Styled Button",
45+
class_="btn-success",
46+
style="margin-top: 20px;",
47+
)
48+
49+
@render.text
50+
def click_count_btn3():
51+
return f"Button 3 clicks: {input.btn3() or 0}"

components/inputs/action-button/index.qmd

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,13 @@ listing:
2828
- title: reactive.event
2929
href: https://shiny.posit.co/py/api/reactive.event.html
3030
signature: reactive.event(*args, ignore_none=True, ignore_init=False)
31+
- id: kitchen-sink
32+
template: ../../_partials/components-detail-kitchen-sink.ejs
33+
contents:
34+
- title: Action Button
35+
core: https://shinylive.io/py/editor/#h=0&code=NobwRAdghgtgpmAXGKAHVA6VBPMAaMAYwHsIAXOcpMAMwCdiYACAZwAsBLCbJjmVYnTJMAgujxM6cKITIcAbnAlSIAEzh0JAVw4AdCPoDETAMJSoFJmTZwmAVQCS+tKgD6OpgF4mOrFADmcK40ADY6qgAU+kwxTMYiqqpMAGKkwiIA7nAsjLYmAMr5vBBWNkw2UKrRsb5kASwYFZHVsTUcGHX+DSFcANZRJa1DMVIhnrpgLGTYIdk2cGQTeC3DsWxSNONgbGRkqCyIAPSHhKoQAFYNhCHEWqqhUFIYJDCHUOdQAB6HPQBGLIcaGkALRQLI5eCHABsGAA7BgAEwnFgAqAhEIYGBcZ4opYrVoAShWBOWgxixgAslAuEwQlBsLdFmSfO06QytGRXCQwjAIK4MnQ0ANVizno9msyRb5COLXE0NFEwCJZBxSEwAEIcshqgCin1gqFmLAmJPxq2M6qgLA4hCYvy1aoyHGsTCdqhdqEesAWGjNw18XFQHNcMjkpFc9t2pAiHFUW1+ZAgAEYlrSoL84GMJpbrbbNVGDPhXbHrFsEQAGcuoT4m0ki1q+RlBzkUT5kRXXG29Lm3cgRxMpsCmyWrXy-OgREnk0SJViewhcfx+oYWh0lJ0um1qqBqJiqDgsdOzJJTCxwZcN9qB4Oh1V8yPaiDC+vDWPxxMIvEjl90jNZsAACIHkecBJPmj7Fi6DgkIWdYvkMW4QJ4tT1BgHARNcVosK4Ww0FAwI5D0SR4QRnCZqowJsGiihVEOcHwbE+6Hr8x6eAAKnQWhKBesTDgxjYcs2ritu2EydoQ3YkFofYJhAn50TxMRjhOU5xDOJ7zouilqeBjrOmwTCEFoUyMIZdIokwO4ntMs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t7tnc-mo+2IAOmKXjWBSRbUOobekMyMAAI2AMYCjqS41pb2GhMQF5zbq4zkVu9k1uu2H9c7MjGOgLGgHScxhYm08bQibK8TAgPWZAYD2fZukwzRmgAvgca7ri4SKBikmY5HkkrwNKsoQPK06PqMWZFgsjp5uGUB2EwtgcCwUBIqc+RHHyciESMdYQCYZCNqGLZtt+8xPosXYHBBpIDh6T5DiOBwACK0fRjGRiRs4cBKACSrQSWxSzkRAsQuGQ7j-Bw-iAjmLCePcNBQBiFQbPkNl2Zwuy2BibBQMEMi2DaeCSeuNF0QxcC2AkSRwH5Olpk+W6UDue4Hk+x5-uel7XmJ97+Rmogvm+jSfippIpQBQEgZxpjgb2pJQTB8FgIhtadChUFMFkuRMVKLAyoQcoNUsxFTqpEqEMYRxKOZOgClRRwnFUfJkHQHBtuUWXKqBPHNjq-EdqtwmhaJvYAMzaUJozSXsBy1McSlfqQJ2nX+FlWQdEB2cYhCEOUKaRQ9rDXXA9wwBCbhcBiMaoIgTCLsuADc90ZtF66xXYDi7hoiUBXAJ5ngBaXcRBh2ZTpiw5a+74FYNh3FYBkNlVxlUQITaG1QhEBgLBAC6QA
37+
image: thumbnail.png
3138
---
3239

3340
:::{#example}
@@ -51,3 +58,4 @@ The value of an input component is accessible as a reactive value within the `se
5158
1. Use `input.<action_button_id()>` (e.g., `input.action_button()`) to access the value of the action button. The server value of an action button is an integer representing the number of clicks.
5259

5360
See also: [Action Link](../action-link/index.qmd)
61+
21.5 KB
Loading
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
from shiny import App, reactive, render, ui
2+
3+
# Define the UI
4+
app_ui = ui.page_fillable(
5+
# Add Font Awesome CSS in the head section
6+
ui.tags.head(
7+
ui.tags.link(
8+
rel="stylesheet",
9+
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.7.2/css/all.min.css",
10+
)
11+
),
12+
13+
# First card
14+
ui.card(
15+
ui.card_header("Action Link Demo"),
16+
# Create an action link with an icon
17+
ui.input_action_link(
18+
id="demo_link",
19+
label="Click Me!",
20+
icon=ui.tags.i(class_="fa-solid fa-shield-halved"),
21+
),
22+
ui.output_text("link_clicks"),
23+
full_screen=True,
24+
height="300px",
25+
id="card1",
26+
),
27+
)
28+
29+
30+
# Define the server
31+
def server(input, output, session):
32+
@render.text
33+
def link_clicks():
34+
count = input.demo_link() or 0
35+
return f"The link has been clicked {count} times"
36+
37+
# Create and return the app
38+
app = App(app_ui, server)
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
from shiny import reactive
2+
from shiny.express import input, render, ui
3+
4+
# Add Font Awesome CSS in the head section
5+
ui.head_content(
6+
ui.HTML(
7+
'<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.7.2/css/all.min.css">'
8+
)
9+
)
10+
11+
# Set page title
12+
ui.page_opts(fillable=True)
13+
14+
15+
# Create a card to hold the action link
16+
with ui.card(full_screen=True, height="300px", id="card1"):
17+
ui.card_header("Action Link Demo")
18+
19+
# Create an action link with an icon
20+
ui.input_action_link(
21+
id="demo_link",
22+
label="Click Me!",
23+
icon=ui.tags.i(class_="fa-solid fa-shield-halved"),
24+
)
25+
26+
# Display the click count
27+
@render.text
28+
def link_clicks():
29+
count = input.demo_link() or 0
30+
return f"The link has been clicked {count} times"

0 commit comments

Comments
 (0)