Skip to content

Commit 946d24e

Browse files
committed
shiny accordion (v1.0)
1 parent 8a40fb8 commit 946d24e

File tree

4 files changed

+116
-16
lines changed

4 files changed

+116
-16
lines changed

shiny-accordion/app.R

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
#' FILE: app.R
33
#' AUTHOR: David Ruvolo
44
#' CREATED: 2021-11-11
5-
#' MODIFIED: 2021-11-11
5+
#' MODIFIED: 2021-11-13
66
#' PURPOSE: example Shiny app for accordion components
7-
#' STATUS: in.progress
8-
#' PACKAGES: shiny
7+
#' STATUS: working
8+
#' PACKAGES: shiny; rheroicons
99
#' COMMENTS: NA
1010
#'////////////////////////////////////////////////////////////////////////////
1111

@@ -20,14 +20,14 @@ ui <- tagList(
2020
name = "viewport",
2121
content = "width=device-width, initial-scale=1"
2222
),
23-
tags$link(rel = "stylesheet", href = "css/app.css"),
24-
tags$link(rel = "stylesheet", href = "css/accordion.css"),
23+
tags$link(rel = "stylesheet", href = "app.css"),
24+
tags$link(rel = "stylesheet", href = "accordion.css"),
2525
tags$title("Accordion Component | shinyAppTutorials")
2626
),
2727
tags$main(
2828
tags$header(
2929
tags$h1(
30-
title = "title",
30+
class = "title",
3131
"Shiny Accordion"
3232
),
3333
tags$h2(
@@ -40,14 +40,29 @@ ui <- tagList(
4040
`aria-labelledby` = "section-example-title",
4141
tags$h2(
4242
id = "section-example-title",
43-
"Example Usage"
43+
"About"
4444
),
4545
tags$p(
4646
"The accordion component is useful for creating interfaces",
4747
"where certain elements on a page can be collapsed.",
4848
"For example, FAQ pages or visually hidding secondary",
49-
"information. In this example, I created a simple FAQ page that",
50-
"demonstrates the functionality of the accordion component."
49+
"information.",
50+
"It is recommended to use the", tags$code("details"), "element",
51+
"for better browser support and functionality, but it is",
52+
"possible to create a custom component for specific cases",
53+
"that meets web standards. Please visit the",
54+
tags$a(
55+
# nolint start
56+
href = "https://developer.mozilla.org/en-US/docs/Web/HTML/Element/details",
57+
# nolint end,
58+
"details element docs"
59+
),
60+
"for more information."
61+
),
62+
tags$p(
63+
"In this example, I created a simple FAQ page that",
64+
"demonstrates the functionality of the accordion component.",
65+
"Click a question to see the accordion component in action."
5166
)
5267
),
5368
tags$section(
@@ -75,8 +90,7 @@ ui <- tagList(
7590
href = "https://shiny.rstudio.com/",
7691
"shiny.rstudio.com"
7792
)
78-
),
79-
tags$cite("Rstudio.org")
93+
)
8094
)
8195
),
8296
accordion(
@@ -99,13 +113,13 @@ ui <- tagList(
99113
href = "https://rmarkdown.rstudio.com/",
100114
"rmarkdown.rstudio.com"
101115
)
102-
),
103-
tags$cite("Rstudio.org")
116+
)
104117
)
105118
)
106119
)
107120
)
108-
)
121+
),
122+
tags$script(src = "accordion.js")
109123
)
110124

111125

shiny-accordion/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "shiny-accordion",
3-
"version": "0.9.0",
3+
"version": "1.0.0",
44
"description": "A component for collapsing HTML elements",
55
"author": "@dcruvolo",
66
"status": "active",

shiny-accordion/www/accordion.css

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,20 @@
1515
padding: 16px 12px;
1616
border: 2px solid var(--accordion-border);
1717
border-radius: var(--border-radius);
18+
-webkit-box-shadow: var(--box-shadow);
1819
box-shadow: var(--box-shadow);
1920
}
2021

2122
/* accordion heading styles (includes button) */
2223
.accordion .accordion__heading {
24+
display: -webkit-flex;
25+
display: -ms-flex;
2326
display: flex;
27+
-webkit-box-pack: start;
28+
-ms-flex-pack: start;
2429
justify-content: flex-start;
30+
-webkit-box-align: center;
31+
-ms-flex-align: center;
2532
align-items: center;
2633
margin: 0;
2734
padding: 0;
@@ -32,8 +39,14 @@
3239

3340
/* reset button styles */
3441
.accordion .accordion__toggle {
42+
display: -webkit-flex;
43+
display: -ms-flex;
3544
display: flex;
45+
-webkit-box-pack: start;
46+
-ms-flex-pack: start;
3647
justify-content: flex-start;
48+
-webkit-box-align: center;
49+
-ms-flex-align: center;
3750
align-items: center;
3851
width: 100%;
3952
border: none;
@@ -63,7 +76,7 @@
6376
width: var(--icon-size);
6477
height: var(--icon-size);
6578
transform: rotate(0);
66-
transform-origin: center;
79+
transform-origin: center center;
6780
transition: transform 0.3s ease-in-out;
6881
}
6982

@@ -78,6 +91,7 @@
7891
margin: 0;
7992
padding: 0;
8093
margin-left: var(--left-offest);
94+
margin-right: var(--left-offest);
8195
}
8296

8397
/* focus event */

shiny-accordion/www/app.css

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
html, body {
2+
font-family: Helvetica, Arial, sans-serif;
3+
font-size: 14pt;
4+
padding: 0;
5+
margin: 0;
6+
background-color: #f6f6f6;
7+
}
8+
9+
h1, h2, h3 {
10+
margin: 0;
11+
margin-bottom: 8px;
12+
line-height: 1.4;
13+
color: #252525
14+
}
15+
16+
p, li {
17+
color: #3f454b;
18+
}
19+
20+
p {
21+
line-height: 1.5;
22+
}
23+
24+
main {
25+
width: 90%;
26+
padding: 2em 0;
27+
margin: 0 auto;
28+
}
29+
30+
header, section {
31+
padding: 0.5em 0;
32+
box-sizing: content-box;
33+
}
34+
35+
header {
36+
border-bottom: 2px solid #c4c4c4;
37+
}
38+
39+
header .title {
40+
font-size: 13pt;
41+
text-transform: uppercase;
42+
letter-spacing: 2px;
43+
margin-bottom: 4px;
44+
}
45+
46+
header .subtitle {
47+
font-weight: 300;
48+
font-size: 24pt;
49+
}
50+
51+
section h2 {
52+
margin-top: 6px;
53+
}
54+
55+
#section-faq h2 {
56+
text-align: center;
57+
}
58+
59+
#section-faq .accordion {
60+
width: 100%;
61+
margin: 24px auto;
62+
}
63+
64+
@media screen and (min-width: 972px) {
65+
main {
66+
max-width: 1024px;
67+
}
68+
69+
#section-faq .accordion {
70+
max-width: 724px;
71+
}
72+
}

0 commit comments

Comments
 (0)