1
1
library(bootscss )
2
2
library(shiny )
3
3
4
+ make_bs3_tabs <- function () {
5
+ list (
6
+ tabPanel(" One" ,
7
+ " One"
8
+ ),
9
+ tabPanel(" Two" ,
10
+ icon = icon(" download" ),
11
+ " Two"
12
+ ),
13
+ navbarMenu(" A submenu" ,
14
+ tabPanel(" Three" , " Three" ),
15
+ " ---" ,
16
+ tabPanel(" Four" , " Four" ),
17
+ tabPanel(" Five" , " Five" )
18
+ )
19
+ )
20
+ }
21
+
22
+
23
+ make_bs4_tabs <- function (id , type = " nav-tabs" ) {
24
+ ns <- NS(paste0(" #" , id ))
25
+ withTags(
26
+ ul(class = " nav" ,
27
+ class = type ,
28
+ li(class = " nav-item" ,
29
+ a(" data-toggle" = " tab" ,
30
+ class = " nav-link active" ,
31
+ href = ns(" 1" ),
32
+ " Link 1"
33
+ )
34
+ ),
35
+ li(class = " nav-item" ,
36
+ a(" data-toggle" = " tab" ,
37
+ class = " nav-link" ,
38
+ href = ns(" 2" ),
39
+
40
+ icon(" download" ),
41
+ " Link 2"
42
+ )
43
+ ),
44
+ li(class = " nav-item dropdown" ,
45
+ a(class = " nav-link dropdown-toggle" ,
46
+ " data-toggle" = " dropdown" ,
47
+ href = " #" ,
48
+ role = " button" ,
49
+ " aria-haspopup" = " true" ,
50
+ " aria-expanded" = " false" ,
51
+ " Dropdown"
52
+ ),
53
+ div(class = " dropdown-menu" ,
54
+ a(" data-toggle" = " tab" ,
55
+ class = " dropdown-item" ,
56
+ href = ns(" 3" ),
57
+ " Link 3"
58
+ ),
59
+ a(" data-toggle" = " tab" ,
60
+ class = " dropdown-item" ,
61
+ href = ns(" 4" ),
62
+ " Link 4"
63
+ ),
64
+ div(class = " dropdown-divider" ),
65
+ a(" data-toggle" = " tab" ,
66
+ class = " dropdown-item disabled" ,
67
+ href = ns(" dis-1" ),
68
+ tabindex = " -1" ,
69
+ " aria-disabled" = " true" ,
70
+ " Disabled Link"
71
+ ),
72
+ a(" data-toggle" = " tab" ,
73
+ class = " dropdown-item disabled" ,
74
+ href = ns(" dis-2" ),
75
+ tabindex = " -1" ,
76
+ " aria-disabled" = " true" ,
77
+ " Another Disabled Link"
78
+ )
79
+ )
80
+ ),
81
+ li(class = " nav-item" ,
82
+ a(" data-toggle" = " tab" ,
83
+ class = " nav-link disabled" ,
84
+ href = ns(" dis-3" ),
85
+ tabindex = " -1" ,
86
+ " aria-disabled" = " true" ,
87
+ " Disabled Link"
88
+ )
89
+ )
90
+ )
91
+ )
92
+ }
93
+
94
+ make_bs4_tab_contents <- function (id ) {
95
+ ns <- NS(id )
96
+ div(class = " tab-content" ,
97
+ div(class = " tab-pane fade show active" ,
98
+ id = ns(" 1" ),
99
+ " Panel 1"
100
+ ),
101
+ div(class = " tab-pane fade" ,
102
+ id = ns(" 2" ),
103
+ " Panel 2"
104
+ ),
105
+ div(class = " tab-pane fade" ,
106
+ id = ns(" 3" ),
107
+ " Panel 3"
108
+ ),
109
+ div(class = " tab-pane fade" ,
110
+ id = ns(" 4" ),
111
+ " Panel 4"
112
+ )
113
+ )
114
+ }
115
+
116
+
4
117
ui <- fluidPage(
5
118
bs4_sass(),
6
119
tags $ style(
7
- " h4 { margin-top: 48px; text-align: center ; }"
120
+ " h4 { margin-top: 120px ; }"
8
121
),
9
122
10
123
tags $ br(),
@@ -14,66 +127,66 @@ ui <- fluidPage(
14
127
tags $ br(),
15
128
16
129
h4(" bs3 navbarPage" ),
17
- navbarPage(" Test" , inverse = TRUE ,
18
- tabPanel(" One" ,
19
- " One"
20
- ),
21
- tabPanel(" Two" ,
22
- icon = icon(" download" ),
23
- " Two"
24
- ),
25
- navbarMenu(" A submenu" ,
26
- tabPanel(" Five" , " Five" ),
27
- " ---" ,
28
- tabPanel(" Six" , " Six" ),
29
- tabPanel(" Seven" , " Seven" )
30
- )
130
+ do.call(navbarPage , rlang :: list2(
131
+ " bs3 navbarPage" , inverse = FALSE ,
132
+ !!! make_bs3_tabs()
133
+ )),
134
+
135
+ h4(" bs3 navbarPage (inverse)" ),
136
+ helpText(" (Fixed to bottom of page)" ),
137
+ do.call(navbarPage , rlang :: list2(
138
+ " bs4 navbarPage (inverse)" , inverse = TRUE , position = " fixed-bottom" ,
139
+ !!! make_bs3_tabs()
140
+ )),
141
+
142
+ h4(" bs4 navbar - default" ),
143
+ tags $ nav(class = " navbar navbar-expand-sm navbar-light bg-light" ,
144
+ tags $ a(class = " navbar-brand" , href = " #" , " Navbar" ),
145
+ make_bs4_tabs(" bs4nav" , " navbar-nav mr-auto" ),
31
146
),
147
+ make_bs4_tab_contents(" bs4nav" ),
32
148
33
- h4(" bs4 navbar" ),
34
- includeHTML(" navbar-bs4.html" ),
149
+ h4(" bs4 navbar (dark)" ),
150
+ tags $ nav(class = " navbar navbar-expand-sm navbar-dark bg-dark" ,
151
+ tags $ a(class = " navbar-brand" , href = " #" , " Navbar" ),
152
+ make_bs4_tabs(" bs4nav" , " navbar-nav mr-auto" ),
153
+ ),
154
+ make_bs4_tab_contents(" bs4nav" ),
155
+
156
+ h4(" bs4 navbar (.bg-success)" ),
157
+ tags $ nav(class = " navbar navbar-expand-sm navbar-dark bg-success" ,
158
+ tags $ a(class = " navbar-brand" , href = " #" , " Navbar" ),
159
+ make_bs4_tabs(" bs4nav" , " navbar-nav mr-auto" ),
160
+ ),
161
+ make_bs4_tab_contents(" bs4nav" ),
35
162
36
163
h4(" bs3 rmarkdown site navbar" ),
37
164
p(class = " text-center" , " (pinned to top of page)" ),
38
165
includeHTML(" navbar-rmdsite.html" ),
39
166
40
167
h4(" bs3 tabsetPanel" ),
41
- tabsetPanel(
42
- tabPanel(" Three" ,
43
- " Three"
44
- ),
45
- tabPanel(" Four" ,
46
- " Four" ,
47
- icon = icon(" cloud" )
48
- ),
49
- navbarMenu(" Dropdown" ,
50
- tabPanel(" Five" ,
51
- " Five"
52
- )
53
- )
54
- ),
168
+ do.call(tabsetPanel , rlang :: list2(
169
+ !!! make_bs3_tabs()
170
+ )),
55
171
56
172
h4(" bs4 tabs" ),
57
- includeHTML(" navbar-bs4tabs.html" ),
173
+ make_bs4_tabs(" bs4tabs" , " nav-tabs" ),
174
+ make_bs4_tab_contents(" bs4tabs" ),
58
175
59
176
h4(" bs3 tabsetPanel(type=\" pills\" )" ),
60
- tabsetPanel(type = " pills" ,
61
- tabPanel(" Three" ,
62
- " Three"
63
- ),
64
- tabPanel(" Four" ,
65
- " Four" ,
66
- icon = icon(" cloud" )
67
- ),
68
- navbarMenu(" Dropdown" ,
69
- tabPanel(" Five" ,
70
- " Five"
71
- )
72
- )
73
- ),
177
+ do.call(tabsetPanel , rlang :: list2(
178
+ type = " pills" ,
179
+ !!! make_bs3_tabs()
180
+ )),
74
181
75
182
h4(" bs4 pills" ),
76
- includeHTML(" navbar-bs4pills.html" ),
183
+ make_bs4_tabs(" bs4pills" , " nav-pills" ),
184
+ make_bs4_tab_contents(" bs4pills" ),
185
+
186
+ h4(" bs3 navlist panel" ),
187
+ do.call(navlistPanel , rlang :: list2(
188
+ !!! make_bs3_tabs()
189
+ )),
77
190
78
191
tags $ br(),
79
192
tags $ br(),
0 commit comments