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
Allow popovers examples to be tried on StackBlitz #36127
Allow popovers examples to be tried on StackBlitz #36127
Conversation
I actually don't mind this solution... feels actually quite direct? |
fdad810
to
cbc0566
Compare
Yep. I haven't found any other acceptable solutions atm so I'll continue with that atm. In a separate commit (4e31bde) you'll find a version where the JS content is in a separate |
Let's do it step by step. IMHO this PR can be reviewed as it is because it already offers an improvement for the users. |
@@ -48,15 +48,15 @@ var popoverList = popoverTriggerList.map(function (popoverTriggerEl) { | |||
|
|||
We use JavaScript similar to the snippet above to render the following live popover. Titles are set via `title` attribute and body content is set via `data-bs-content`. | |||
|
|||
{{< example >}} | |||
{{< example javascript="popover-demo.js" >}} | |||
<button type="button" class="btn btn-lg btn-danger" data-bs-toggle="popover" title="Popover title" data-bs-content="And here's some amazing content. It's very engaging. Right?">Click to toggle popover</button> |
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.
Don't know why but the code contains title="Popover title"
, it works in the doc but I can't find the title
in the DOM and so it is missing in StackBlitz as well 🤔 If I replace title="Popover title"
by data-bs-title="Popover title"
, everything's working correctly but I don't know the impact of such a change.
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.
Your answer is here unfortunately 😞
Lines 513 to 525 in 51535cd
_fixTitle() { | |
const title = this._config.originalTitle | |
if (!title) { | |
return | |
} | |
if (!this._element.getAttribute('aria-label') && !this._element.textContent) { | |
this._element.setAttribute('aria-label', title) | |
} | |
this._element.removeAttribute('title') | |
} |
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.
OK so all popovers that contain titles won't be exportable in StackBlitz. StackBlitz button should be hidden for those cases. Except if someone thinks about a way of doing it differently.
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 one is describing the title
attribute fallback process, so it may is better to keep it as it was (no btn)
If we have other popovers using title
, I think it's ok to change them using data-bs-title
We should really look into using esbuild for docs JS and thus split application.js into smaller files properly imported. |
bce7fb4
to
2aa3159
Compare
Is it mandatory for this PR (and the nexts to come related to fix StackBlitz example) or can it be treated separately? |
Definitely separately :) |
2aa3159
to
abc01b0
Compare
@julien-deramond Do you have any alternative in mind, to avoid this (using a link or something else)? If we are in luck of alternatives, I suppose we can live with it |
The only alternative I'm thinking of (not tested so maybe it is dumb) would be to do something like that:
If it works and is considered as a better solution please keep in mind that we would have several JS files used only for StackBlitz in Do you want me to try this solution to see if it is feasible? |
This will need a rebase or update to resolve a merge conflict :). We just merged a PR to split some more of the JS into separate files. |
abc01b0
to
58986d3
Compare
@julien-deramond in order to simplify a bit the whole process, can you investigate the case to make accessible & include by default the snippets.js? |
Haven't tried it explicitly but it is possible to always include the content of this file in the I rather thought to split it in order to have only what's needed for each example. If you think in the core team that's not a problem for the users who will share between them those examples with extra JS (and then extra CSS for the broken use cases of StackBlitz due to missing CSS) I can modify this PR in order to do that. It won't fix only popovers but probably a lot of examples at the same time. As you said, in this case Edit: I missed the "make accessible" part of your comment in my first answer. I'll try to see how it can be accessed directly from outside. But if we stick with a single file (not a split one) maybe that's not useful. Let's try. |
Closing this one superseded by #36352 |
This PR tries to allow popovers examples to be tried on StackBlitz.
In the documentation, they need some JS available in
site/assets/js/snippets.js
.IMHO it would be troubling to have all this file integrated in StackBlitz.
So in this PR I'm trying to:
site/assets/js/snippets.js
into small reusable partsjavascript
parameter for theexample
shortcode containing the name of the reusable JS file to embed into StackBlitzsite/layouts/partials/scripts.html
to gather this information and embed the content of the JS file in a<script>
.Sub-tasks
<script>
, try to create a realindex.js
file in StackBlitz imported byindex.html
.Find a better way to share the JS name between the doc, the shortcode and thesite/layouts/partials/scripts.html
Live previews
Not tackled here