-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(style)!: refactor how to build the overlay style #245
Changes from 5 commits
7d68850
8aa44fc
88ad79c
8b9f721
6ad5b9a
dccf51d
cb91767
62d9663
41db251
b561330
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,7 +17,17 @@ | |
#' Use these constants as the \code{position} argument in the \code{\link{create_overlay}} function. | ||
#' | ||
#' @export | ||
overlay_shape_position <- c("top-left", "top-right", "top-center", "bottom-left", "bottom-right", "bottom-center", "middle-left", "middle-right") | ||
overlay_shape_position <- | ||
tbouffard marked this conversation as resolved.
Show resolved
Hide resolved
|
||
c( | ||
"top-left", | ||
"top-right", | ||
"top-center", | ||
"bottom-left", | ||
"bottom-right", | ||
"bottom-center", | ||
"middle-left", | ||
"middle-right" | ||
) | ||
|
||
#' @title The overlay positions on \code{Edge} | ||
#' | ||
|
@@ -47,7 +57,7 @@ overlay_edge_position <- c("start", "end", "middle") | |
#' @param elementId The bpmn element id to which the overlay will be attached | ||
#' @param label 'HTML' element to use as an overlay | ||
#' @param style The style of the overlay. | ||
#' Use \code{\link{create_style}} function to create the style object of an overlay and be aware of the `enableDefaultOverlayStyle` parameter in the \code{\link{display}} function. | ||
#' Use \code{\link{create_overlay_style}} function to create the style object of an overlay and be aware of the `enableDefaultOverlayStyle` parameter in the \code{\link{display}} function. | ||
#' @param position The position of the overlay | ||
#' If the bpmn element where the overlay will be attached is a Shape, use \code{\link{overlay_shape_position}}. | ||
#' Otherwise, use \code{\link{overlay_edge_position}}. | ||
|
@@ -56,27 +66,33 @@ overlay_edge_position <- c("start", "end", "middle") | |
#' | ||
#' @examples | ||
#' # Create an overlay with shape position "top-left" | ||
csouchet marked this conversation as resolved.
Show resolved
Hide resolved
|
||
#' overlay_style <- create_overlay_style( | ||
#' font_color = 'DarkSlateGray', | ||
#' font_size = 23, | ||
#' fill_color = 'MistyRose', | ||
#' stroke_color = 'Red' | ||
#' ) | ||
#' | ||
#' overlay <- create_overlay( | ||
#' "my-element-id", | ||
#' "My Overlay Label", | ||
#' create_style( | ||
#' font = create_font(color = 'DarkSlateGray', size = 23), | ||
#' fill = create_fill(color = 'MistyRose'), | ||
#' stroke = create_stroke(color = 'Red') | ||
#' ), | ||
#' overlay_shape_position[1] | ||
#' "my-shape-id", | ||
#' "My Overlay Label", | ||
#' style = overlay_style, | ||
#' position = overlay_shape_position[1] | ||
#' ) | ||
#' | ||
#' # Create an overlay with edge position "end" | ||
#' overlay_style <- create_overlay_style( | ||
#' font_color = 'DarkSlateGray', | ||
#' font_size = 23, | ||
#' fill_color = 'MistyRose', | ||
#' stroke_color = 'Red' | ||
#' ) | ||
#' | ||
#' overlay <- create_overlay( | ||
#' "my-edge-id", | ||
#' "My Overlay Label", | ||
#' create_style( | ||
#' font = create_font(color = 'DarkSlateGray', size = 23), | ||
#' fill = create_fill(color = 'MistyRose'), | ||
#' stroke = create_stroke(color = 'Red') | ||
#' ), | ||
#' overlay_edge_position[2] | ||
#' "my-edge-id", | ||
#' "My Overlay Label", | ||
#' style = overlay_style, | ||
#' position = overlay_edge_position[2] | ||
#' ) | ||
#' | ||
#' @export | ||
|
@@ -102,49 +118,52 @@ create_overlay <- function(elementId, label, style = NULL, position = NULL) { | |
|
||
#' @title Create the style of an overlay | ||
#' | ||
#' @name create_style | ||
#' @name create_overlay_style | ||
#' @description | ||
#' When adding an overlay to an existing element in a diagram, it's possible to customize its style. | ||
#' | ||
#' Refer to the \code{style} parameter in the \code{\link{create_overlay}} function for more information. | ||
#' | ||
#' Use this function to create the correct style structure for an overlay. | ||
#' | ||
#' @param font The font style of the overlay | ||
#' Use \code{\link{create_font}} function to create the font style object for the overlay. | ||
#' @param fill The fill style of the overlay | ||
#' Use \code{\link{create_fill}} function to create the fill style object for the overlay. | ||
#' @param stroke The stroke style of the overlay | ||
#' Use \code{\link{create_stroke}} function to create the stroke style object for the overlay. | ||
#' @param font_color The font color of the overlay. Use a custom color string. | ||
tbouffard marked this conversation as resolved.
Show resolved
Hide resolved
|
||
#' @param font_size The font size of the overlay. Specify a numeric font size. | ||
#' @param fill_color The color of the background of the overlay. Use a custom color string. | ||
#' @param stroke_color The color of the stroke of the overlay. Use a custom color string. | ||
#' If you don't want to display a stroke, you can set the color to: | ||
#' - \code{transparent}, | ||
#' - the same value as for the \code{fill_color}. This increases the \code{padding}/\code{margin}. | ||
#' | ||
#' @returns The style object of the overlay | ||
#' | ||
#' @export | ||
create_style <- function(font = NULL, fill = NULL, stroke = NULL) { | ||
create_overlay_style <- function(font_color = NULL, | ||
font_size = NULL, | ||
fill_color = NULL, | ||
stroke_color = NULL) { | ||
ret <- | ||
.not_null_list( | ||
font = font, | ||
fill = fill, | ||
stroke = stroke | ||
font = create_font(color = font_color, size = font_size), | ||
fill = create_fill(fill_color), | ||
stroke = create_stroke(stroke_color) | ||
) | ||
} | ||
|
||
#' @title Create the font style of an overlay | ||
#' @title Internal fun to create the font style of an overlay or a 'BPMN' element | ||
csouchet marked this conversation as resolved.
Show resolved
Hide resolved
|
||
#' | ||
#' @name create_font | ||
#' @description | ||
#' When adding an overlay to an existing element in a diagram, it's possible to customize its font style. | ||
#' | ||
#' Refer to the \code{font} parameter in the \code{\link{create_style}} function for more information. | ||
#' | ||
#' Use this function to create the correct font structure for an overlay. | ||
#' - Overlay: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. question: I guess this is added to prepare the new "update style" API? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Indeed 😊 |
||
#' When adding an overlay to an existing element in a diagram, it's possible to customize its font style. | ||
#' Refer to the \code{font} parameter in the \code{\link{create_overlay_style}} function for more information. | ||
#' Use this function to create the correct font structure for an overlay. | ||
#' | ||
#' @param color The color of the font of the overlay | ||
#' @param size The size of the font of the overlay | ||
#' | ||
#' @returns The font style object of the overlay | ||
#' | ||
#' @export | ||
#' @noRd | ||
create_font <- function(color = NULL, size = NULL) { | ||
ret <- | ||
.not_null_list( | ||
|
@@ -153,43 +172,41 @@ create_font <- function(color = NULL, size = NULL) { | |
) | ||
} | ||
|
||
#' @title Create the fill style of an overlay | ||
#' @title Internal fun to create the fill style of an overlay or a 'BPMN' element | ||
csouchet marked this conversation as resolved.
Show resolved
Hide resolved
|
||
#' | ||
#' @name create_fill | ||
#' @description | ||
#' When adding an overlay to an existing element in a diagram, it's possible to customize how it is filled. | ||
#' | ||
#' Refer to the \code{fill} parameter in the \code{\link{create_style}} function for more information. | ||
#' | ||
#' Use this function to create the correct fill structure for an overlay. | ||
#' - Overlay: | ||
#' When adding an overlay to an existing element in a diagram, it's possible to customize how it is filled. | ||
#' Refer to the \code{fill} parameter in the \code{\link{create_overlay_style}} function for more information. | ||
#' Use this function to create the correct fill structure for an overlay. | ||
#' | ||
#' @param color The color of the background of the overlay | ||
#' | ||
#' @returns The fill style object of the overlay | ||
#' | ||
#' @export | ||
#' @noRd | ||
create_fill <- function(color) { | ||
ret <- | ||
.not_null_list( | ||
color = color | ||
) | ||
} | ||
|
||
#' @title Create the stroke style of an overlay | ||
#' @title Internal fun to create the stroke style of an overlay or a 'BPMN' element | ||
csouchet marked this conversation as resolved.
Show resolved
Hide resolved
|
||
#' | ||
#' @name create_stroke | ||
#' @description | ||
#' When adding an overlay to an existing element in a diagram, it's possible to customize its stroke. style. | ||
#' | ||
#' Refer to the \code{stroke.} parameter in the \code{\link{create_style}} function for more information. | ||
#' | ||
#' Use this function to create the correct stroke structure for an overlay. | ||
#' - Overlay: | ||
#' When adding an overlay to an existing element in a diagram, it's possible to customize its stroke. style. | ||
#' Refer to the \code{stroke.} parameter in the \code{\link{create_overlay_style}} function for more information. | ||
#' Use this function to create the correct stroke structure for an overlay. | ||
#' | ||
#' @param color The color of the stroke of the overlay | ||
#' | ||
#' @returns The stroke style object of the overlay | ||
#' | ||
#' @export | ||
#' @noRd | ||
create_stroke <- function(color) { | ||
ret <- | ||
.not_null_list( | ||
|
This file was deleted.
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
praise: Nice, this makes things easier to understand when reading the documentation.