/
typography.R
183 lines (163 loc) · 4.02 KB
/
typography.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
#' Framework7 align utility
#'
#' \code{f7Align} is an alignment utility for items.
#'
#' @param tag Tag to align.
#' @param side Side to align: "left", "center", "right" or "justify".
#'
#' @examples
#' if(interactive()){
#' library(shiny)
#' library(shinyMobile)
#'
#' shinyApp(
#' ui = f7Page(
#' title = "Align",
#' f7SingleLayout(
#' navbar = f7Navbar(title = "f7Align"),
#' f7Row(
#' f7Align(h1("Left"), side = "left"),
#' f7Align(h1("Center"), side = "center"),
#' f7Align(h1("Right"), side = "right")
#' )
#' )
#' ),
#' server = function(input, output) {}
#' )
#' }
#'
#' @author David Granjon, \email{dgranjon@@ymail.com}
#'
#' @export
f7Align <- function(tag, side = c("left", "center", "right", "justify")) {
side <- match.arg(side)
alignCl <- paste0("text-align-", side)
tag$attribs$class <- if (is.null(tag$attribs$class)) {
alignCl
} else {
paste(tag$attribs$class, alignCl)
}
tag
}
#' Framework7 float utility
#'
#' \code{f7Float} is an alignment utility for items.
#'
#' @param tag Tag to float.
#' @param side Side to float: "left" or "right".
#'
#' @examples
#' if(interactive()){
#' library(shiny)
#' library(shinyMobile)
#'
#' shinyApp(
#' ui = f7Page(
#' title = "Float",
#' f7SingleLayout(
#' navbar = f7Navbar(title = "f7Float"),
#' f7Float(h1("Left"), side = "left"),
#' f7Float(h1("Right"), side = "right")
#' )
#' ),
#' server = function(input, output) {}
#' )
#' }
#'
#' @author David Granjon, \email{dgranjon@@ymail.com}
#'
#' @export
f7Float <- function(tag, side = c("left", "right")) {
side <- match.arg(side)
floatCl <- paste0("float-", side)
tag$attribs$class <- paste(tag$attribs$class, floatCl)
tag
}
#' Framework7 margin utility
#'
#' \code{f7Margin} adds a margin to the given tag.
#'
#' @param tag Tag to apply the margin.
#' @param side margin side: "left", "right", "top", "bottom",
#' "vertical" (top and bottom), "horizontal" (left and right).
#' Leave NULL to apply on all sides.
#'
#' @examples
#' if(interactive()){
#' library(shiny)
#' library(shinyMobile)
#'
#' cardTag <- f7Card(
#' title = "Card header",
#' "This is a simple card with plain text,
#' but cards can also contain their own header,
#' footer, list view, image, or any other element.",
#' footer = tagList(
#' f7Button(color = "blue", label = "My button", href = "https://www.google.com"),
#' f7Badge("Badge", color = "green")
#' )
#' )
#'
#' shinyApp(
#' ui = f7Page(
#' title = "Margins",
#' f7SingleLayout(
#' navbar = f7Navbar(title = "f7Margin"),
#' f7Margin(cardTag),
#' cardTag
#' )
#' ),
#' server = function(input, output) {}
#' )
#' }
#'
#' @author David Granjon, \email{dgranjon@@ymail.com}
#'
#' @export
f7Margin <- function(tag, side = NULL) {
marginCl <- if (!is.null(side)) paste0("margin-", side) else "margin"
tag$attribs$class <- paste(tag$attribs$class, marginCl)
tag
}
#' Framework7 padding utility
#'
#' \code{f7Padding} adds padding to the given tag.
#'
#' @param tag Tag to apply the padding.
#' @param side padding side: "left", "right", "top", "bottom",
#' "vertical" (top and bottom), "horizontal" (left and right).
#' Leave NULL to apply on all sides.
#'
#' @examples
#' if(interactive()){
#' library(shiny)
#' library(shinyMobile)
#'
#' cardTag <- f7Card(
#' title = "Card header",
#' f7Padding(
#' p("The padding is applied here.")
#' ),
#' footer = tagList(
#' f7Button(color = "blue", label = "My button", href = "https://www.google.com"),
#' f7Badge("Badge", color = "green")
#' )
#' )
#'
#' shinyApp(
#' ui = f7Page(
#' title = "Padding",
#' f7SingleLayout(navbar = f7Navbar(title = "f7Padding"), cardTag)
#' ),
#' server = function(input, output) {}
#' )
#' }
#'
#' @author David Granjon, \email{dgranjon@@ymail.com}
#'
#' @export
f7Padding <- function(tag, side = NULL) {
paddingCl <- if (!is.null(side)) paste0("padding-", side) else "padding"
tag$attribs$class <- paste(tag$attribs$class, paddingCl)
tag
}