-
Notifications
You must be signed in to change notification settings - Fork 7
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
added fitVideo() #51
base: main
Are you sure you want to change the base?
added fitVideo() #51
Conversation
I apologize in advance if this is too basic of a question. Are the checks on both the stable and devel versions failing due to the commit I made? I don't quite understand why it's indicating a type mismatch on this line:
|
First of all, thanks for contributing 😁 Secondly, no it isn't your fault. I think it is a change in the Nim stdlib for the |
…wer version of Nim
I updated my pull request based on your feedback! Thank you so much. |
The CI works again! 🥳 Thank you, I'll give your code a try tonight 😄 |
Ahh, I baked some apple cakes and forgot about you 😅 I'll give it a try tomorrow instead |
I've also added an option to control the transition effect on slideOptions(). It seems to be working as intended when I tested it.
I'm not sure if it was a good idea to add it on this pull request. |
Wow, even more features! :D What would be really nice with the transition is if we could make an enum with the supported transitions and pass them in instead of raw strings. Like we do for fragments: Line 11 in 2fe737b
Would it be too much of an ask? I will try out the |
|
Thank you for the feedback! I will try this idea as soon as I have some free time. |
Thanks, no hurry. Do it when you have the time and energy 😁 |
Could you give me some advice on the transition implementation? I am pretty new to programming, so I don't have a good grasp on JavaScript This is what I tried to do in the wrapper type
SlideTransition* = enum
slide = "slide" # default
none = "none"
fade = "fade"
convex = "convex"
concave = "concave"
zoom = "zoom"
type
SlideTransitionSpeed* = enum
fast = "fast" # default
slow = "slow"
template slide*(transition: SlideTransition, body: untyped) =
if transition.len > 1:
transition = fmt"{transition[0]}-in {transition[1]}-out"
else:
transition = transitions.join(" ")
var options = """data-transition="$1" """ % [transition]
nbRawHtml: "<section $1>" % [options]
when declaredInScope(CountVarNimiSlide):
when CountVarNimiSlide < 2:
static: inc CountVarNimiSlide
body
static: dec CountVarNimiSlide
else:
{.error: "You can only nest slides once!".}
else:
var CountVarNimiSlide {.inject, compileTime.} = 1 # we just entered the first level
body
static: dec CountVarNimiSlide
nbRawHtml: "</section>"
And, this is what I put in my test code. I am getting compiler error messages that have something to do with nimib and nb.blk. slide(zoom):
nbText: "sometext3" |
I can absolutely help out :D The enum looks great! The compiler is a bit picky when it comes to overloading untyped parameters (the proc slideOptions*(transition = "slide", ....) You do proc slideOptions*(transition = SlideTransition.slide, ....) And where you previously used This is just a way of ensuring we are only inputting valid string by forcing the user to pass in an enum instead. Hope this clarified some parts, otherwise you can just ask again :D |
if transition.len > 1:
transition = fmt"{transition[0]}-in {transition[1]}-out"
else:
transition = transitions.join(" ") Is |
According to the Reveal.js documentation, it appears that you can control the in and out transitions separately, and even adjust the transition speed. I think there should be an option to pass an array (or sequence) to support all these features. So, I've made a preliminary attempt to parse the passed array as a string. But, I'm not entirely sure about the best design choice to support these features.
|
Could you make each of them separate input argument perhaps? slideOption(transition=slide, outTransition=zoom, transitionSpeed=fast) And if you set the default value of proc slideOptions*(autoAnimate = false, iframeInteractive = true, colorBackground, imageBackground, videoBackground, iframeBackground, gradientBackground: string = "", transition = SlideTransition.slide, outTransition = transition, transitionSpeed = SlideTransitionSpeed.fast): SlideOptions = Does that make sense? |
Thank you for the feedback. I implemented the feature based on your feedback and it's mostly working. Here is my test code
However, it seems that the compiler gives me a type mismatch error if I pass the option "slide" directly to the transition. I am not sure how I should handle this.
|
Awesome! 😄 |
Yep, it seems like passing the full name compiles the code
|
One solution would be to add a prefix to the transition. For example |
Hmm, at the moment, I cannot think of any clean way to handle this issue. As you said, this may not become a problem in most cases since there is no reason to pass the default transition option explicitly. My opinion is that the current state is pretty usable, and we can fix this later if it becomes an issue, I think. |
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.
I have looked thorugh the code now and there was only one question I had.
Other than that, it would be nice if these new features where documented somewhere. I understand if you are fed up with this PR by now so it's ok if you don't do it. I can do it someday instead, that works for me. But let me know if you want to write docs. And in that case it would fit best in docsrc/tutorials/images_media.nim
(fitVideo) and docsrc/tutorials/slide_options.nim
.
@@ -31,13 +31,28 @@ type | |||
SlidesTheme* = enum | |||
Black, Beige, Blood, Dracula, League, Moon, Night, Serif, Simple, Sky, Solarized, White | |||
|
|||
SlideTransition* {.pure.} = enum |
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.
Do we want the enum to be pure, i.e. that you have to write SlideTransition.convex
?
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.
My understanding of the {.pure.} pragma was the opposite. I wanted to avoid calling the full name and just use 'convex.' I tried to compile my test code without the pragma, and it wouldn't compile.
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.
Huh, that's weird 🤔
According to the manual it should be the opposite:
An enum type can be marked as pure. Then access of its fields always requires full qualification.
I'll try running your code without it and see if I can find something
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.
I am also getting an error without it so something fishy is going on. But as it seems to work, we can keep the pure pragma for now :)
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.
It doesn't even work when doing SlideTransition.convex
without the pure pragma, really strange 🤯
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.
Huh, that's weird 🤔
According to the manual it should be the opposite:
An enum type can be marked as pure. Then access of its fields always requires full qualification.
I'll try running your code without it and see if I can find something
I see, the manual is a little bit confusing to me. I tried to understand the pragma based on this example.
https://nim-by-example.github.io/types/enums/
My guess was that the {.pure.} pragma does two things.
- It forces you to be explicit when there are overlapping names among all the declared enums.
- It allows you to refer to enums without qualification if there is no ambiguity.
Ones again, thank you so much for contributing to nimiSlides and that you have endured my comments ❤️ |
No worries! I learned a lot from your feedback. Thank you so much again. |
I'm glad to hear that, always fun helping others out 😄 |
No description provided.