Docs: Add tooltips to buttons when <Example>
is used, not just <Code>
#41582
+26
−19
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
I've updated the Example in order to use our Code component.
I've updated Code to be embedded inside other components.
We add a new empty div and a div without any class, but it's better than nothing for now.
Motivation & Context
The issue comes from the fact that the Code component initiates the tooltip both for the clipboard and stackblitz button, but the Code component only embed the clipboard button. On the other side, the Code component is used by JsDocs, ScssDocs and by itself in the documentation (so via ``` and the help of
<Content components={{ pre: Code }} />
inside `[...slug].astro`) but not by the Example component.Previously, it used to work because most pages have either a ``` or a ScssDocs or JsDocs inside the page. Since Astro bundle the JS and clean the bundled JS, if at least one occurrence was present in the page, the Code component JS was interpreted on the whole page and only once. We have the issue on Button Group since we don't have any Code component reference inside.
So here the quick fix is only to use Code whenever it's possible (So in Example component) to add the JS everywhere it's needed. It's not ideal but a quick fix. If you have a better solution to introduce the requested JS everywhere, feel free to change it.
Since the default syntax highlighter is Prism (in
astro.config.ts
) we can't see any difference on the doc.With special thanks to @MaxLardenois.
Type of changes
Checklist
npm run lint
)Live previews
Related issues
Closes #41579