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
Add ability to expand/collapse modules #3628
Conversation
5718536
to
4dc2b48
Compare
@jom suggested at some point that we could use the summary/details, so we could use the same approach to the editor and frontend. Just to confirm, Did we try to explore this option? |
Not sure if we can have CSS based animations with the details element. It seems that elements of varying height are hard to animate with CSS. I'll have a look on Monday. |
Yeah, if we want to animate the height, it can be hard without JS. I saw that you used |
4dc2b48
to
d5b0ec6
Compare
f3e93e8
to
7e12159
Compare
e9bf715
to
6fa34ea
Compare
Hey @renatho I think that we should avoid JS based animations as CSS ones are easily overriden by the user. For this I followed this guide. As explained there the issue with transforms is that no reflow is triggered so the rest of the elements won't move accordingly. We could possibly trigger a reflow but this could cause performance issues. I increased the default max height to 2000px, it seems that it doesn't affect the animation too much. This would allow for 26 lessons to be added to a single module without max-height being an issue. I imagine that if this becomes an issue for the user, they could always tweak the animation again or remove it entirely. |
6fa34ea
to
a6ba4e8
Compare
Generally it should be fine to have Javascript drive the animation, performance-wise. In this case, it's probably overkill — maybe we can consider it later if we have heavier animations/interactions on the frontend and decide to include some library for it. We could add the initial |
a6ba4e8
to
69c68d8
Compare
.children( '.wp-block-sensei-lms-collapsible' ); | ||
|
||
moduleDetails.toggleClass( 'collapsed' ); | ||
jQuery( this ).toggleClass( 'dashicons-arrow-up-alt2' ); |
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.
We need to add dashicons
as a dependency for the frontend stylesheet. It isn't loaded by default for most themes. For example, logged out (admin bar and query monitor both require this), this does not display on Storefront.
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.
We should probably use an svg icon compiled in at some point, but that's worth its own PR
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.
Good catch! 5e8e3b8
We should probably use an svg icon compiled in at some point, but that's worth its own PR
Considered using CSS content attribute but found it a bit hacky.
@@ -184,7 +185,7 @@ public function render_course_outline_block( $attributes ) { | |||
$block_class .= ' ' . $attributes['className']; | |||
} | |||
|
|||
return ' | |||
return ' |
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 whitespace will get stripped in my editor due to our .editorconfig
. Was it added for a reason?
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.
Nope 😄 Not sure why PHPStorm doesn't respect it, I have the plugin installed. Probably has to do with my project structure 🤷 0e2d7f8
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.
Ready for this, all looks good!
Found a problem with Wordpress 5.3, the frontend JS is not loaded. Maybe the registration is too late in |
Changes proposed in this Pull Request
Testing instructions