Skip to content

Commit b8d5024

Browse files
committed
rename border_size to border_width
1 parent 3599a59 commit b8d5024

23 files changed

+180
-63
lines changed

DESCRIPTION

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ Imports:
2222
grDevices,
2323
grid,
2424
jpeg,
25+
lifecycle,
2526
png,
2627
rlang (>= 1.1.0),
2728
S7,

NAMESPACE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ export(style_set)
6262
export(trbl)
6363
import(grid)
6464
import(rlang)
65+
importFrom(lifecycle,deprecated)
6566
importFrom(vctrs,vec_cast)
6667
importFrom(vctrs,vec_ptype2)
6768
useDynLib(marquee, .registration = TRUE)

NEWS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# marquee (development version)
22

33
* Better vectorisation of style_set and classic_style
4+
* Renamed `border_size` to `border_width` for consistency
45

56
# marquee 1.1.1
67

R/classic_style.R

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ classic_style <- function(
7777
hr = style(
7878
padding = trbl(0, 0, rem(1 / 8)),
7979
border = "#eeeeee",
80-
border_size = trbl(0, 0, rem(1 / 16))
80+
border_width = trbl(0, 0, rem(1 / 16))
8181
),
8282
h1 = style(
8383
family = header_font,
@@ -87,7 +87,7 @@ classic_style <- function(
8787
margin = trbl(em(1), NULL, NULL, NULL),
8888
padding = trbl(0, 0, em(0.3)),
8989
border = "#eeeeee",
90-
border_size = trbl(0, 0, rem(1 / 16))
90+
border_width = trbl(0, 0, rem(1 / 16))
9191
),
9292
h2 = style(
9393
family = header_font,
@@ -97,7 +97,7 @@ classic_style <- function(
9797
margin = trbl(em(1), NULL, NULL, NULL),
9898
padding = trbl(0, 0, em(0.3)),
9999
border = "#eeeeee",
100-
border_size = trbl(0, 0, rem(1 / 16))
100+
border_width = trbl(0, 0, rem(1 / 16))
101101
),
102102
h3 = style(
103103
family = header_font,
@@ -143,7 +143,7 @@ classic_style <- function(
143143
trbl(em(0.2), em(1), em(0.2), 0)
144144
},
145145
border = "#dddddd",
146-
border_size = if (ltr) {
146+
border_width = if (ltr) {
147147
trbl(0, 0, 0, rem(0.25))
148148
} else {
149149
trbl(0, rem(0.25), 0, 0)

R/geom_marquee.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
#' "body",
6060
#' padding = skip_inherit(trbl(4)),
6161
#' border = "black",
62-
#' border_size = skip_inherit(trbl(1)),
62+
#' border_width = skip_inherit(trbl(1)),
6363
#' border_radius = 3
6464
#' )
6565
#' p + geom_marquee(aes(label = rownames(mtcars), fill = gear), style = label_style)

R/grob.R

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -262,8 +262,8 @@ marquee_grob <- function(
262262
function(x) !(is.character(x) && is.na(x[1])),
263263
logical(1)
264264
)
265-
has_top <- !is.na(parsed$border) & parsed$border_size_top != 0
266-
has_bottom <- !is.na(parsed$border) & parsed$border_size_bottom != 0
265+
has_top <- !is.na(parsed$border) & parsed$border_width_top != 0
266+
has_bottom <- !is.na(parsed$border) & parsed$border_width_bottom != 0
267267
for (root in blocks$start[blocks$indent == 1]) {
268268
block_tree <- collect_children(
269269
root,
@@ -868,10 +868,10 @@ makeContext.marquee_grob <- function(x) {
868868
logical(1)
869869
) |
870870
(!is.na(x$text$border) &
871-
(x$text$border_size_bottom > 0 |
872-
x$text$border_size_top > 0 |
873-
x$text$border_size_left > 0 |
874-
x$text$border_size_right > 0))
871+
(x$text$border_width_bottom > 0 |
872+
x$text$border_width_top > 0 |
873+
x$text$border_width_left > 0 |
874+
x$text$border_width_right > 0))
875875

876876
## Handle block backgrounds
877877
block_bg <- has_deco[x$blocks$start]
@@ -886,10 +886,10 @@ makeContext.marquee_grob <- function(x) {
886886
fill = x$text$background[x$blocks$start[block_bg]],
887887
col = x$text$border[x$blocks$start[block_bg]],
888888
r = x$text$border_radius[x$blocks$start[block_bg]],
889-
left = x$text$border_size_left[x$blocks$start[block_bg]],
890-
right = x$text$border_size_right[x$blocks$start[block_bg]],
891-
top = x$text$border_size_top[x$blocks$start[block_bg]],
892-
bottom = x$text$border_size_bottom[x$blocks$start[block_bg]]
889+
left = x$text$border_width_left[x$blocks$start[block_bg]],
890+
right = x$text$border_width_right[x$blocks$start[block_bg]],
891+
top = x$text$border_width_top[x$blocks$start[block_bg]],
892+
bottom = x$text$border_width_bottom[x$blocks$start[block_bg]]
893893
)
894894

895895
## Handle span backgrounds
@@ -946,10 +946,10 @@ makeContext.marquee_grob <- function(x) {
946946
fill = c(block_rects$fill, x$text$background[span_rects[, 1]]),
947947
col = c(block_rects$col, x$text$border[span_rects[, 1]]),
948948
r = c(block_rects$r, x$text$border_radius[span_rects[, 1]]),
949-
left = c(block_rects$left, x$text$border_size_left[span_rects[, 1]]),
950-
right = c(block_rects$right, x$text$border_size_right[span_rects[, 1]]),
951-
top = c(block_rects$top, x$text$border_size_top[span_rects[, 1]]),
952-
bottom = c(block_rects$bottom, x$text$border_size_bottom[span_rects[, 1]])
949+
left = c(block_rects$left, x$text$border_width_left[span_rects[, 1]]),
950+
right = c(block_rects$right, x$text$border_width_right[span_rects[, 1]]),
951+
top = c(block_rects$top, x$text$border_width_top[span_rects[, 1]]),
952+
bottom = c(block_rects$bottom, x$text$border_width_bottom[span_rects[, 1]])
953953
)
954954

955955
## Extract position of underline and strikethrough
@@ -1384,12 +1384,12 @@ has_identical_background <- function(a, b, style) {
13841384
identical(style$border[a], style$border[b]) &&
13851385
(is.na(style$border[a]) ||
13861386
(identical(
1387-
style$border_size_bottom[a],
1388-
style$border_size_bottom[b]
1387+
style$border_width_bottom[a],
1388+
style$border_width_bottom[b]
13891389
) &&
1390-
identical(style$border_size_top[a], style$border_size_top[b]) &&
1391-
identical(style$border_size_left[a], style$border_size_left[b]) &&
1392-
identical(style$border_size_right[a], style$border_size_right[b])))
1390+
identical(style$border_width_top[a], style$border_width_top[b]) &&
1391+
identical(style$border_width_left[a], style$border_width_left[b]) &&
1392+
identical(style$border_width_right[a], style$border_width_right[b])))
13931393
},
13941394
a = a,
13951395
b = b

R/guide_marquee.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878
#' # prefixed with `lab_`.
7979
#' st <- classic_style()
8080
#' st <- modify_style(st, tag = "lab_f", background = NULL, color = "black")
81-
#' st <- modify_style(st, tag = "lab_r", border_size = trbl(1),
81+
#' st <- modify_style(st, tag = "lab_r", border_width = trbl(1),
8282
#' color = "black", background = NA)
8383
#' base + guides(colour = guide_marquee(style = st))
8484
#'

R/marquee-package.R

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22
"_PACKAGE"
33

44
## usethis namespace: start
5-
#' @useDynLib marquee, .registration = TRUE
6-
#' @import rlang
75
#' @import grid
6+
#' @import rlang
7+
#' @importFrom lifecycle deprecated
8+
#' @useDynLib marquee, .registration = TRUE
89
## usethis namespace: end
910
NULL

R/style.R

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
#' made with `grid::linearGradient()`/`grid::radialGradient()`/`grid::pattern()`
5353
#' @param border The color of the background stroke. The background includes
5454
#' the padding but not the margin
55-
#' @param border_size The line width of the background stroke, given as a call
55+
#' @param border_width The line width of the background stroke, given as a call
5656
#' to [trbl()]
5757
#' @param border_radius The corner radius of the background, given in points
5858
#' @param outline The color of the outline stroke.
@@ -75,6 +75,9 @@
7575
#' consequtive blocks of text are laid out left-to-right or right-to-left. It
7676
#' also affects to which side indentation is applied as well as the meaning of
7777
#' `"auto"`, and `"justified-auto"` aligment.
78+
#' @param border_size `r lifecycle::badge('deprecated')` Use `border_width`
79+
#' instead
80+
#'
7881
#'
7982
#' @return A `marquee_style` object
8083
#'
@@ -104,7 +107,7 @@ style <- function(
104107
padding = NULL,
105108
background = NULL,
106109
border = NULL,
107-
border_size = NULL,
110+
border_width = NULL,
108111
border_radius = NULL,
109112
outline = NULL,
110113
outline_width = NULL,
@@ -115,7 +118,8 @@ style <- function(
115118
strikethrough = NULL,
116119
baseline = NULL,
117120
img_asp = NULL,
118-
text_direction = NULL
121+
text_direction = NULL,
122+
border_size = deprecated()
119123
) {
120124
check_string(family, allow_null = TRUE)
121125

@@ -204,11 +208,16 @@ style <- function(
204208
border[] <- NA_character_
205209
}
206210

207-
if (is.null(border_size)) {
208-
border_size <- trbl()
211+
if (lifecycle::is_present(border_size)) {
212+
lifecycle::deprecate_soft("1.1.2", "style(border_size)", "style(border_width)")
213+
border_width <- border_size
214+
}
215+
216+
if (is.null(border_width)) {
217+
border_width <- trbl()
209218
}
210-
if (!is_trbl(border_size)) {
211-
stop_input_type(border_size, "a marquee_trbl object", allow_null = TRUE)
219+
if (!is_trbl(border_width)) {
220+
stop_input_type(border_width, "a marquee_trbl object", allow_null = TRUE)
212221
}
213222

214223
if (is.unit(border_radius)) {
@@ -277,10 +286,10 @@ style <- function(
277286
padding_bottom = padding[[3]],
278287
padding_left = padding[[4]],
279288
border = border,
280-
border_size_top = border_size[[1]],
281-
border_size_right = border_size[[2]],
282-
border_size_bottom = border_size[[3]],
283-
border_size_left = border_size[[4]],
289+
border_width_top = border_width[[1]],
290+
border_width_right = border_width[[2]],
291+
border_width_bottom = border_width[[3]],
292+
border_width_left = border_width[[4]],
284293
border_radius = border_radius,
285294
outline = outline,
286295
outline_width = outline_width,
@@ -383,7 +392,7 @@ base_style <- function(
383392
padding = trbl(0),
384393
background = NA,
385394
border = NA,
386-
border_size = trbl(0),
395+
border_width = trbl(0),
387396
border_radius = 0,
388397
outline = NA,
389398
outline_width = 1,
@@ -394,8 +403,13 @@ base_style <- function(
394403
strikethrough = FALSE,
395404
baseline = 0,
396405
img_asp = 1.65,
397-
text_direction = "auto"
406+
text_direction = "auto",
407+
border_size = deprecated()
398408
) {
409+
if (lifecycle::is_present(border_size)) {
410+
lifecycle::deprecate_soft("1.1.2", "base_style(border_size)", "base_style(border_width)")
411+
border_width <- border_size
412+
}
399413
style(
400414
family = family,
401415
weight = weight,
@@ -413,7 +427,7 @@ base_style <- function(
413427
padding = padding,
414428
background = background,
415429
border = border,
416-
border_size = border_size,
430+
border_width = border_width,
417431
border_radius = border_radius,
418432
outline = outline,
419433
outline_width = outline_width,

R/style_set.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ modify_style.marquee_style_set <- function(x, tag, ...) {
102102
opts$tag <- NULL
103103

104104
args <- names(opts)
105-
expand <- args %in% c("margin", "padding", "border_size")
105+
expand <- args %in% c("margin", "padding", "border_width")
106106
if (any(expand)) {
107107
args <- c(
108108
args[!expand],
@@ -150,7 +150,7 @@ modify_style.marquee_style_set <- function(x, tag, ...) {
150150
modify_style.marquee_style <- function(x, tag, ...) {
151151
opts <- list2(...)
152152
args <- names(opts)
153-
expand <- args %in% c("margin", "padding", "border_size")
153+
expand <- args %in% c("margin", "padding", "border_width")
154154
if (any(expand)) {
155155
args <- c(
156156
args[!expand],

0 commit comments

Comments
 (0)