shiny.semantic
shiny.semantic copied to clipboard
Oriol.sprite fun
This includes two new functions addsvg_sprite
and rmsvg_sprite
that add the functionality to easily edit sprite maps, add or remove svgs to the sprite map. It is motivated by this issue:
#226
To read, parse and edit the svg files it is necessary the xml2
package, so I have edited the DESCRIPTION
and added as suggested
packages. Documentation and tests have also been added.
DoD
-
[x] Major project work has a corresponding task. If there’s no task for what you are doing, create it. Each task needs to be well defined and described.
-
[x] Change has been tested (manually or with automated tests), everything runs correctly and works as expected. No existing functionality is broken.
-
[x] No new error or warning messages are introduced.
-
[x] All interaction with a semantic functions, examples and docs are written from the perspective of the person using or receiving it. They are understandable and helpful to this person.
-
[x] If the change affects code or repo sctructure, README, documentation and code comments should be updated.
-
[x] All code has been peer-reviewed before merging into any main branch.
-
[ ] All changes have been merged into the main branch we use for development (develop).
-
[ ] Continuous integration checks (linter, unit tests) are configured and passed.
-
[ ] Unit tests added for all new or changed logic.
-
[ ] All task requirements satisfied. The reviewer is responsible to verify each aspect of the task.
-
[ ] Any added or touched code follows our style-guide.
Thank you for your comments. Finally I have adressed all changes. Only instead of putting one app in examples I have put more examples in the function directly. I did it this way because these new functions are helper functions and are not directly components of a Shiny App. Building an example app does not show its functionality, while showing more examples in documentation it does.
Great work, tested it and the sprite map gets generated and works fine! The only thing I miss is some UI function to add svg
DOM node. An example function:
svg_icon <- function(path_to_sprite_map, id, class = "", style = "") {
HTML(glue::glue("
<svg
class = '{class}',
style = '{style}',
viewBox = '0 0 <calculated width> <calculated height>'
>
<use href = '{path_to_sprite_map}#{id}'></use>
</svg>"
))
}
svg_icon("temp.svg", "appsilon_logo", "test-svg", "fill: red;")
I didn't test this function, but briefly this is how I would imagine that
Hi @jchojna I agree with you that to close this issue we could add a function to insert sprite maps easily on the UI. Consequently we should also write an example app using it.