Skip to content
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

wbStyle enchancements #60

Open
6 tasks
jmbarbone opened this issue Feb 5, 2022 · 0 comments
Open
6 tasks

wbStyle enchancements #60

jmbarbone opened this issue Feb 5, 2022 · 0 comments

Comments

@jmbarbone
Copy link
Collaborator

jmbarbone commented Feb 5, 2022

These are pulled out from #9. Didn't want it holding up the issue.

May want to look at parity with #6, #36. Haven't started on this yet, maybe a bit of a duplicate effort.

Some additional steps to make creating a new wbStyle object quicker and easier to handle. These changes would also move a lot of the checks outside of the initialize() function and into the specs, which should make it a bit more clear what needs to be checked. It could also give us some template to extract styles from existing workbooks and make sure we have roundtrip styles.

Todos

  • create wb_font_specs() to simplify including fontId, fontName, fontColour, fontSize, fontFamily, fontScheme, fontDecoration
  • create wb_border_specs() to simplify including borderTop, borderLeft, borderRight, borderBottom, borderTopColour, borderLeftColour, borderRightColour, borderBottomColour, borderDiagonal, borderdiagonalColour, borderDiagonalUp, borderDiagonalDown
  • simplify bgFill and fgFill to c(back = ..., fore = ...) (or background and forgound
  • simplify halign and valign to c(horizontal = "left", vertical = "top") (h and v
  • create
  • Is wbStyle$as.list() needed? Could we just use R6:::as.list.R6()? Not sure there's much we're gaining

Pseuocode

Thinking about something like this:

wb_style(
  font    = wb_font_spec(),
  borders = wb_border_spec(),
  fill    = wb_fill_spec(),
  ...
)

# specs are essentially custom classes that manage default values and checking
# these can then be applied to a worksheet cell range

# use "default" values, or getOptions()
wb_font_spec <- function(id, name, colour, family, scheme, decoration) {
  # make some checks for clean up
  ...
  
  # return as a wb_*_spec class
  structure(
    list(id, name, colour, family, scheme, decoration),
    names = c("id", "name", "colour", "family", "scheme", "decoration")
    class = "wb_font_spec"
  )
}

wb_border_spec <- function(positions = "none", color = "none") {
  # make some checks for clean up
  ...
  
  # check for border positions
  ...
  
  # return as a wb_*_spec class
  structure(
    list(id, name, colour, family, scheme, decoration),
    names = c("id", "name", "colour", "family", "scheme", "decoration")
    class = "wb_border_spec"
  )
}

# these could be the same
wb_border_spec(positions = c("left", "right"), color = c("red", "black"))
wb_border_spec(positions = c("left", "right"), color = c(right = "black", left = "red"))
wb_border_spec(list(left = "red", right = "black"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant