-
Notifications
You must be signed in to change notification settings - Fork 15
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
Use CSS variables and static html dependency #36
Conversation
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.
LGTM! 👍
Only a minor note on the style_countdown()
function.
Please merge when ready. I'll spin up a second PR for the re-org. (Or, if you'd like I can wait until the #37 is complete.)
R/countdown.R
Outdated
#' should be applied. The default is `:root` for global styles, but you can | ||
#' also provide a custom class name to create styles for a particular class. | ||
#' @export | ||
style_countdown <- function( |
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.
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.
Thanks for calling this out. style_{thing}
is a pattern I tend to follow across my projects, even though it breaks the usual prefixing rules. In Shiny/html land, I tend to prefer a verb-first approach to separate between functions that create UI and functions for interactivity.
For example, looking at this list I'd prefer update_countdown()
and style_countdown()
, since in Shiny we group update_
functions and in my packages I use style_
for prefixes.
The problem -- and the reason I didn't use update_countdown()
when I wrote it -- is countdown_action()
. I can't think of a good name for that function. The other best option I've come up with is trigger_countdown()
, which I don't like enough to use. So, IIRC, I went with countdown_update()
for internal consistency.
So, on the whole, I agree and think countdown_style()
is probably the best option.
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.
@gadenbuie We can also use this as an opportunity to rename functions if you wish. Redirects can be setup for backward compatibility with lifecycle
.
} | ||
if (!grepl("^[a-zA-Z]", id)) { | ||
stop_because("Must start with a letter") | ||
make_countdown_css_vars <- function(..., .list = list()) { |
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.
This is a really elegant and concise way of setting the CSS variables.
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.
Thanks! Sometimes it pays to be lazy (and to be consistent in naming things) 😉
I'm going to go ahead and merge this PR. I'll rebase #37 and, then, I'll start the re-org. |
This PR rewrites countdown's CSS to use CSS variables rather than the previous whisker template. This has a number of advantages, but results in a large breaking change.
We now can use
html_dependency_countdown()
, a static html dependency. Previously the css was a template and the dependency was re-written dynamically with each render, which causes problems and obviously can't be used for Quarto. This fixes the issue mentioned here: quarto shortcode #27 (comment)The breaking change is that the first
countdown()
no longer styles the other timers. In retrospect this is a bug masquerading as a feature 😄 Now, users need to separately callstyle_countdown()
to globally style the countdown timers.I've kept all of the same arguments in
countdown()
but they all default toNULL
now.style_countdown()
is documented in the same page so that the arguments and functions are collocated.Fixes #28
Fixes #34
Incidentally fixes #30