officer icon indicating copy to clipboard operation
officer copied to clipboard

feat: simplified input for `ph_with`'s `location` arg

Open markheckmann opened this issue 4 months ago • 2 comments

When I started out with officer, I was initially confused by the ph_with location argument which expects the output of one of the ph_location_* functions. Now, all make perfect sense. Still I think it would be useful (especially for newcomers) to also offer the option of supplying a simplified location arg input (string or numeric), instead of a having to call a ph_location_* function.

Providing a string or numeric can - I think unambiguously and without loss of generality - cover most of the common ph_location_* use cases. While the ph_location_* functions allow for more customized settings and additional features, I think the simplified version would be a nice UI addition and suffice the most common use cases.

NB: Behind the scenes, the simplified input would just be automatically plugged into one of the ph_location_* functions.

What do you think?

x <- read_pptx()
x <- add_slide(x, "Title Slide")

# >>>> consecutive lines would be identical with the UI simplification  <<<<<

# string to specify ph label
x <- ph_with(x, "A title", location = ph_location_label("Title 1"))
x <- ph_with(x, "A title", location = "Title 1")

# numeric for location id
x <- ph_with(x, "A subtitle", location = ph_location_id(3))
x <- ph_with(x, "A subtitle", location = 3)

# string with special format `type[type_idx]`  for type
x <- ph_with(x, "A date", location = ph_location_type("dt", 1))
x <- ph_with(x, "A date", location = "dt [1]") 

# string with keyword: `left`, `right`, or `fullsize`
x <- ph_with(x, "A left text", location = ph_location_left())
x <- ph_with(x, "A left text", location = "left")

markheckmann avatar Oct 13 '24 11:10 markheckmann