-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Feat: add part attribute to timeline #3481
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.
Thanks!
Could you describe the use case for each of the selectors? Timeline is clear but the rest of them were intentionally not included because messing with their CSS can break wavesurfer. If not now then potentially in some future update where we might decide to change the inner HTML structure.
Adding a part attribute makes an element a part of the external API. So I would consider it only if you have a good use case in mind. Cheers!
Completely understand and maybe our approach isn't correct which is why we are having to jump through some hoops. We're using WaveSurfer to display a waveform with additional content before and after the To accommodate these elements, we've been using JavaScript to adjust the CSS post-render. This approach, however, leads to an initial render followed by a repaint once our styles are applied. We're looking for a solution that allows CSS styling directly, avoiding this two-step rendering process. This is our current hacked in solution because without the parts we can't use css selectors querySelector instance.getWrapper().style.height = `${PLAYER_HEIGHT}px`;
instance.getWrapper().querySelector(':scope [part=timeline-wrapper] > div').style.top = `${TRIANGLE_HEIGHT}px`;
instance.getWrapper().querySelector(':scope .canvases').style.minHeight = `${WAVE_HEIGHT}px`;
instance.getWrapper().querySelector(':scope .progress').style.minHeight = `${WAVE_HEIGHT}px`;
instance.getWrapper().querySelector(':scope .canvases > div').style.height = `${
TIMELINE_HEIGHT + GAP_HEIGHT + WAVE_HEIGHT + GAP_HEIGHT
}px`; |
If you just want to increase spacing at the top and bottom of the waveform, you can simply set a fractional E.g. if you desired waveform height is 100px and you want to have 10 empty pixels above and below: WaveSurfer.create({
height: 120,
barHeight: 0.8, // stretch only to 80% of the height
}) I realize it's not the most obvious way to do this, perhaps we could add a "padding" option. |
I see. Yes, in the current setup all plugins are dumped into the same wrapper div, and I can see how this can be problematic. Regions in particular stretch to 100% of the wrapper, and AFAIR some users did prefer that. So perhaps you could reduce the height of Regions via CSS, as they do have a I'll think about plugin isolation a bit more, perhaps there's a neat way to stack them instead of overlapping even if they use |
@katspaugh Any thoughts or updates on this PR? |
I suggest that we keep the timeline part but not add the other ones as they are internal elements, not public API. |
@brian-byassee btw, I've invited you to be a collaborator in this repository, so that it's easier for you to make PRs. You can now push directly to this repo instead of a fork. Cheers! |
@katspaugh I noticed and thank you! 🎊 |
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.
👍
Short description
Add part attributes to the other remaining elements rendered in the wavesurfer
Resolves #
Makes writing css easier outside the shadow root
Implementation details
How to test it
Screenshots
Checklist